您的位置:首页 > 其它

freebsd一块网卡添加多个ip地址

2008-11-05 15:19 351 查看
因业务需要。freebsd服务器在同一网卡下需要添加多个ip地址。登陆到服务器使用ifconfig 命令。 ifconfig {interface} {ip_addr_alias[/b]} netmask 255.255.255.255 alias[/b] 如:# ifconfig rl0 192.168.1.5 netmask 255.255.255.0 alias
# ifconfig
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=8<VLAN_MTU>
inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255
inet 192.168.1.5 netmask 0xffffff00 broadcast 192.168.1.255
ether 00:e0:4c:8c:59:75
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active

要去掉 alias[/b] : (就是把最后改为 -alias[/b])
ifconfig[/b] {interface} {ip_addr_alias[/b]} netmask 255.255.255.255 -alias[/b]
如:# ifconfig rl0 192.168.1.5 netmask 255.255.255.255 -alias
# ifconfig
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=8<VLAN_MTU>
inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255
ether 00:e0:4c:8c:59:75
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active

要想在开机时就自动设定IP Alias[/b],需要在/etc/rc.conf下加入:
ifconfig[/b]_rl0_alias[/b]0="inet xxx.xxx.xxx.xxx netmask 255.255.255.xxx"
^^^ ^^^^^^^^^^^^^^^
网络接口名称 这里是你希望使用的IP地址。
通过这种方式你可以给一块网卡设定很多IP地址。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: