一个网卡最多可以设置256个别名,这样一个C段的网络都可以设置到一个网卡上。
ifconfig eth0:0 192.168.1.109
#ifconfig eth0 192.168.6.99 netmask 255.255.255.0 up eth0 //机器的第一个网卡,有些机器有多个网卡,eth1、eth2... 192.168.6.99 //设置网卡的静态ip地址 netmask 255.255.255.0 //ip地址的子网掩码,无需多解释 up //表示立即激活该网卡
eth0是指第一个网卡,冒号后的0是指第一个别名,后面跟别名的ip
示例如下:
#ifconfig eth0:0 192.168.6.100 netmask 255.255.255.0 up #ifconfig eth0:1 173.173.173.173 netmask 255.255.255.0 up #ifconfig eth0:2 119.110.120.1 netmask 255.255.255.0 up ......
清除ip别名
#ifconfg eth0:0 down #ifconfg eth0:1 down #ifconfg eth0:2 down
ip别名重启后,会自动清除,需要重新添加,你也可以通过将添加命令