FreeBSD修改ip地址和绑定多个IP地址

用ifconfig查看IP设置情况
dns# ifconfig
le0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 00:0c:29:62:80:2c
        inet 10.0.75.10 netmask 0xffffff00 broadcast 10.0.75.255
        media: Ethernet autoselect
        status: active
plip0: flags=108810<POINTOPOINT,SIMPLEX,MULTICAST,NEEDSGIANT> metric 0 mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
方法一:
dns# ifconfig le0 10.0.75.10 netmask 255.255.255.0
用此方法设置,重启后即会还原。
方法二:
打开/etc/rc.conf
加入或修改:ifconfig_网卡名称="inet x.x.x.x netmask x.x.x.x"
之后 reboot
dns# vi /etc/rc.conf
# -- sysinstall generated deltas -- # Fri Oct 16 11:04:09 2009
# Created: Fri Oct 16 11:04:09 2009
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
defaultrouter="10.0.64.1"
hostname="dns.kaoyan114.com"
ifconfig_le0="inet 10.0.75.10 netmask 255.255.255.0"
keymap="us.iso"
sshd_enable="YES"
这种方法,信息永久保留,但是修改完需要重启机器。
如果要设置多IP地址可用别名方式作修改如下
ifconfig_le0="inet 10.0.0.199 netmask 255.255.255.0"
改为
ifconfig_le0_alias0="inet 10.0.75.198 netmask 255.255.255.0"
ifconfig_le0_alias1="inet 10.0.75.197 netmask 255.255.255.0"

你可能感兴趣的:(职场,FreeBSD,休闲,修改ip地址,绑定多个IP地址)