如何在Linux下一个网卡上配置多个IP

假设原来的 IP 是 192.168.0.1 ,现在要把 192.168.0.2 , 192.168.0.3 加上,编辑 /etc/rc.conf ,会看到原來的 IP 设定

ifconfig_fxp=”inet 192.168.0.1 netmask 255.255.255.255″

底下加上

ifconfig_fxp0_alias0=”inet 192.168.0.2  netmask 255.255.255.255”
ifconfig_fxp0_alias0=”inet 192.168.0.3  netmask 255.255.255.255”

新增加的 IP 的 netmask 要用 255.255.255.255!

接下來重新启用网卡配置 /etc/rc.d/netstart ,或是重启服务器即可。
注意:远程操作时候最好在本地先测试过。
原文地址:https://www.cnblogs.com/top5/p/1571569.html