当前位置: > Linux发行版 > FreeBSD >

freebsd 单一网卡配置多个IP

时间:2015-01-19 17:29来源:linux.it.net.cn 作者:IT
如果一块网卡以前的IP是192.168.30.3,现在在添加多个IP,可以rc.conf 中作如下设置,lnc0是设备名 
ifconfig_lnc0="inet 192.168.30.3 netmask 255.255.255.0" 
ifconfig_lnc0_alias0="inet 192.168.30.1 netmask 255.255.255.255" 
ifconfig_lnc0_alias1="inet 192.168.30.2 netmask 255.255.255.255" 



指定的IP地址和你在一个子网,别名后面的netmask应是255.255.255.255, 
如果指定IP位于不同子网,用相应子网的netmask. 


man ifconfig 有如下说明 


alias     Establish an additional network address for this interface.    This is sometimes useful when changing network numbers, and one wishes  to accept packets addressed to the old interface.    If the address is on the same subnet as the first network address for this interface, a non-conflicting netmask must be given.    Usually    0xffffffff is most appropriate.  (责任编辑:IT)
------分隔线----------------------------