进入网卡配置目录
cd /etc/sysconfig/network-scripts[root@www network-scripts]# lsifcfg-em1 ifcfg-lo ..
运行ifconfig查看以后应用的网卡配置
[root@www network-scripts]# ifconfig em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.187.112.90 netmask 255.255.255.248 broadcast 192.187.112.95 inet6 fe80::226:6cff:fef0:1158 prefixlen 64 scopeid 0x20<link> ether 00:26:6c:f0:11:58 txqueuelen 1000 (Ethernet) RX packets 541372 bytes 746304201 (711.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 99758 bytes 28932462 (27.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0xfbde0000-fbdfffff em2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 00:26:6c:f0:11:59 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0xfbd20000-fbd3ffff lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 128 bytes 11776 (11.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 128 bytes 11776 (11.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
如上, 依据IP能够确认外网配置是em1
复制一个配置文件
cp ifcfg-em1 ifcfg-em1:1
批改几项配置
# Generated by dracut initrdNAME="em1"DEVICE="em1:1" # 前面加:1ONBOOT="yes"NETBOOT="yes"UUID="75e73492-9586-45fc-951f-3d99ab134668"IPV6INIT="yes"BOOTPROTO="none"TYPE="Ethernet"PROXY_METHOD="none"BROWSER_ONLY="no"IPADDR="192.187.112.91" # 改成其余IPPREFIX="29"GATEWAY="192.187.112.89"DNS1="127.0.0.1"DEFROUTE="yes"IPV4_FAILURE_FATAL="no"IPV6_AUTOCONF="yes"IPV6_DEFROUTE="yes"IPV6_FAILURE_FATAL="no"
如果须要配置更多IP, 能够持续复制ifcfg-em1文件为ifcfg-em1:2, 相应的批改复制后的文件, 示例:
DEVICE="em1:2" # 前面加:2IPADDR="192.187.112.92" # 改成其余IP
重启网卡使配置失效
systemctl restart network
查看是否失效
[root@www network-scripts]# ifconfig em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.187.112.90 netmask 255.255.255.248 broadcast 192.187.112.95 inet6 fe80::226:6cff:fef0:1158 prefixlen 64 scopeid 0x20<link> ether 00:26:6c:f0:11:58 txqueuelen 1000 (Ethernet) RX packets 542683 bytes 746406082 (711.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 100544 bytes 29029241 (27.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0xfbde0000-fbdfffff em1:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.187.112.91 netmask 255.255.255.248 broadcast 192.187.112.95 ether 00:26:6c:f0:11:58 txqueuelen 1000 (Ethernet) device memory 0xfbde0000-fbdfffff em2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 00:26:6c:f0:11:59 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0xfbd20000-fbd3ffff lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 128 bytes 11776 (11.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 128 bytes 11776 (11.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
em1:1就是新增的虚构网卡