标签:
一、方式一
1.修改/etc/sysconfig/network-scripts/ifcfg-enp2s0 为:(注意:文件名一定要为网卡设备名)
DEVICE=enp2s0
BOOTPROTO=static
ONBOOT=yes
DNS1=10.0.10.10
DNS2=8.8.8.8
HWADDR=B8:88:E3:73:7A:7B
IPADDR=10.0.57.114
PREFIX=24
GATEWAY=10.0.57.1
2.cp ifcfg-enp2s0 为 ifcfg-enp2s0:1,并修该ifcfg-enp2s0:1 内容为:
DEVICE=enp2s0:1
BOOTPROTO=static
ONBOOT=yes
DNS1=10.0.10.10
DNS2=8.8.8.8
HWADDR=B8:88:E3:73:7A:7B
IPADDR=10.0.57.115
PREFIX=24
GATEWAY=10.0.57.1
3.重启网卡,然后ifconfig就可以看到。?
二、方式二
1.直接配置多个网卡在/etc/sysconfig/network-scripts/ifcfg-enp2s0 里,
不过要用ip addr才能看到多个ip信息,配置如下:
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=za209
UUID=7e917b8e-2d35-4630-b314-2d64a2f1f52f
ONBOOT=no
DNS1=10.0.10.10
DOMAIN=10.0.15.11
HWADDR=B8:88:E3:73:7A:7B
IPADDR=10.0.57.230
PREFIX=24
GATEWAY=10.0.57.1
IPADDR1=10.0.57.231
PREFIX1=24
GATEWAY1=10.0.57.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
2.重启网卡,用ip addr命令查看,显示如下:
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether b8:88:e3:73:7a:7b brd ff:ff:ff:ff:ff:ff
inet 10.0.57.230/24 brd 10.0.57.255 scope global enp2s0
valid_lft forever preferred_lft forever
inet 10.0.57.231/24 brd 10.0.57.255 scope global secondary enp2s0
valid_lft forever preferred_lft forever
inet6 fe80::ba88:e3ff:fe73:7a7b/64 scope link
valid_lft forever preferred_lft forever
标签:
原文地址:http://www.cnblogs.com/weibingkitty/p/4446645.html