配置IP别名

即为一个网卡设置多个IP地址

  1. 临时(即重启后失效)

    ifconfig eth0:1 192.168.1.110/24 up
    ifconfig eth0:2 192.168.1.111/24 up
    ifconfig eth0:3 192.168.1.112/24 up

    删除别名

    ifconfig eth0:1 down
    ifconfig eth0:2 down
    ifconfig eth0:3 down
  2. 永久(写入配置文件里)

手动将上述临时命令写入到`/etc/rc.local` 文件中(有时会失效,不推荐)

新建一个编写网卡配置文件

# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0 ifcfg-eth0:0
# cat ifcfg-eth0:0
  DEVICE=eth0:0     #网卡名
  TYPE=Ethernet
  ONBOOT=yes        #开机自启动
  BOOTPROTO=static
  IPADDR=192.168.1.100 #需要配置的IP地址
  GATEWAY=192.168.1.1

2017/5/2 14:53:32