1,临时增加一个IP别名:
#设置IP别名:
ifconfig eth0:1 192.168.78.116 netmask 255.255.255.0 up
ifconfig eth0:1
#设置路由:
netstat -rn
route -n
route add -net 192.168.78.0 netmask 255.255.255.0 gw 192.168.78.1 eth0:1
netstat -rn
#删除设置:
route del -net 192.168.78.0 netmask 255.255.255.0
ifconfig eth0:1 down
2,永久新增一个IP别名:
cp -av /etc/sysconfig/network-scripts/ifcfg-eth0{,:1}
sed -i 's/DEVICE=eth0/DEVICE=eth0:1/g' /etc/sysconfig/network-scripts/ifcfg-eth0:1
sed -i 's/IPADDR=.*/IPADDR=192.168.78.116/g' /etc/sysconfig/network-scripts/ifcfg-eth0:1
sed -i 's/GATEWAY=.*/GATEWAY=192.168.78.1/g' /etc/sysconfig/network-scripts/ifcfg-eth0:1
/etc/init.d/network restart
[TOC]