Centos 单网卡双IP配置

Centos 6.x 单网卡双IP配置

主IP设置

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=23.239.208.87
NETMASK=255.255.255.0
GATEWAY=23.239.208.1
onboot=YES

新ip配置

# vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=23.239.208.175
NETMASK=255.255.255.0
GATEWAY=23.239.208.1
onboot=YES

新增ip,只需要在/etc/sysconfig/network-scripts/ifcfg-eth0基础上按ifcfg-eth0:0、ifcfg-eth0:1增加即可。

Centos 7.x 单网卡双IP配置

# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO="static"
NAME=enp0s3
DEVICE=enp0s3
NM_CONTROLLED="no"
IPADDR0=192.168.1.10      # IP
IPADDR1=192.168.2.22
NETMASK=255.255.255.0   # 子网掩码
GATEWAY0=192.168.1.1     #网关
GATEWAY1=192.168.2.1
DNS1=119.29.29.29    # DNS
DNS2=223.5.5.5
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
PREFIX0=24
PREFIX2=16
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no
UUID=59504c7c-11b3-40c5-86a8-7bfbe7527109
ONBOOT=yes

There are no comment yet.

HTML tag cannot be used in this comment.