CentOS环境单网卡配置双IP方法

43 次查看 0 条评论

1、方法一

先配置一个静态IP,然后再拷贝一份配置文件稍作修改即可:

cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0a:f7:8d:dd:ac
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1

拷贝一份稍作修改:

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1
cat /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
HWADDR=00:0a:f7:8d:dd:ac
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.200
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

2、方法二(推荐)

配置都写在一个文件里:

cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0a:f7:8d:dd:ac
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
# IP1
IPADDR1=192.168.0.100
PREFIX1=24
GATEWAY1=192.168.0.1
# IP2
IPADDR2=192.168.1.200
PREFIX2=24
GATEWAY2=192.168.1.1
NetWork 网络

暂无评论,快来抢沙发。