CentOS 6 单网卡绑定双IP

 CentOS 6 单网卡绑定双IP

OS:CnetOS 6.8

初始网卡配置文件
    
[ /]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
    
DEVICE=eth0
TYPE=Ethernet
UUID=d3fde489-9b67-453c-84df-4827f3becf1a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.1.110
PREFIX=24
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
name="System eth0"
HWADDR=00:0C:29:F6:F8:A8
LAST_CONNECT=1489157101

方法一:在原网卡配置文件直接增加新IP
    
[ /]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
    
DEVICE=eth0
TYPE=Ethernet
UUID=d3fde489-9b67-453c-84df-4827f3becf1a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.1.110
PREFIX=24
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no

name="System eth0"
IPADDR2=192.168.1.111
PREFIX2=24
HWADDR=00:0C:29:F6:F8:A8
LAST_CONNECT=1489129249

方法二:新增网卡配置文件:
    
[ /]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
[ /]# vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
    
DEVICE=eth0:0
TYPE=Ethernet
UUID=d3fde489-9b67-453c-84df-4827f3becf1a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.1.111
PREFIX=24
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
name="System eth0"
HWADDR=00:0C:29:F6:F8:A8
LAST_CONNECT=1489130355

修改网卡配置文件后,需要重启网络服务才会生效:
    
[ /]# service network restart

相关推荐