共计 2813 个字符,预计需要花费 8 分钟才能阅读完成。
-
进入网卡配置目录
cd /etc/sysconfig/network-scripts [root@www network-scripts]# ls ifcfg-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 initrd NAME="em1" DEVICE="em1:1" # 前面加:1 ONBOOT="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" # 改成其余 IP PREFIX="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" # 前面加:2 IPADDR="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 就是新增的虚构网卡
正文完