VMware虚拟机Centos7配置双网卡双IP踩坑
基础环境配置环境:Centos7配置:网卡1配置NAT模式,网卡二配置仅主机模式VMware新增网卡后,ifconfig网卡不显示问题copy网卡配置ifcfg-**重命名后,重启报错原因:修改:基础环境配置
环境:Centos7
配置:网卡1配置NAT模式,网卡二配置仅主机模式
VMware新增网卡后,ifconfig网卡不显示问题
判断网络适配器2(新网卡)是否添加成功;前往目录/proc/sys/net/ipv4/conf
下,查看是否存在新的网卡目录;即ens36
[root@centos7_phpstudy conf]# cd /proc/sys/net/ipv4/conf[root@centos7_phpstudy conf]# lltotal 0dr-xr-xr-x. 1 root root 0 Jan 20 22:24 alldr-xr-xr-x. 1 root root 0 Jan 20 22:24 defaultdr-xr-xr-x. 1 root root 0 Jan 20 22:25 docker0dr-xr-xr-x. 1 root root 0 Jan 20 22:25 ens33dr-xr-xr-x. 1 root root 0 Jan 20 22:25 ens36dr-xr-xr-x. 1 root root 0 Jan 20 22:25 lo[root@centos7_phpstudy conf]# pwd/proc/sys/net/ipv4/conf
copy网卡配置ifcfg-**重命名后,重启报错
在网卡配置目录/etc/sysconfig/network-scripts
下,复制已存在的ifcfg-ens33
配置;并重新启动;[root@centos7_phpstudy network-scripts]# service network restartRestarting network (via systemctl): Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details. [FAILED]
原因:
我们到/proc/sys/net/ipv4/conf
目录下查看网络设备,发现新增的网卡被Linux系统命名为ens36
;我们copy原先网卡配置ifcfg-ens33
,将其重命名为了ifcfg-ens22
;也就是说linux系统识别不到我们为设备ens36
配置的ifcfg-ens22
网卡配置;(也就是不能随便命名)
,ens36对应配置文件名称应为:ifcfg-ens36;因此将ifcfg-ens22,重命名为ifcfg-ens36
即可;修改:
查看并修改新增的网卡配置名称ifcfg-ens36
;[root@centos7_phpstudy network-scripts]#pwd/etc/sysconfig/network-scripts[root@centos7_phpstudy network-scripts]#
[root@centos7_phpstudy network-scripts]# ll ifcfg-*-rw-r--r--. 1 root root 419 May 14 ifcfg-ens33-rw-r--r--. 1 root root 353 Jan 20 23:16 ifcfg-ens36-rw-r--r--. 1 root root 254 May 22 ifcfg-lo
网卡ifcfg-ens36内的DEVICE
字段也需要修改为ens36
[root@centos7_phpstudy network-scripts]# vim ifcfg-ens36
TYPE="Ethernet"PROXY_METHOD="none"##ONBOOT="yes"BROWSER_ONLY="no"BOOTPROTO="static"DEFROUTE="yes"IPV4_FAILURE_FATAL="yes"IPV6INIT="yes"IPV6_AUTOCONF="yes"IPV6_DEFROUTE="yes"IPV6_FAILURE_FATAL="no"IPV6_ADDR_GEN_MODE="stable-privacy"DEVICE="ens36"ONBOOT="yes"IPADDR="192.168.22.129"NETMASK="255.255.255.0"DNS1=8.8.8.8DNS2=114.114.114.114~~
重启network;
[root@centos7_phpstudy network-scripts]# service network restartRestarting network (via systemctl): [ OK ]
查看网卡和IP
[root@centos7_phpstudy network-scripts]# ifconfigens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 192.168.138.20 netmask 255.255.255.0 broadcast 192.168.138.255inet6 fe80::250:56ff:fe2f:a86c prefixlen 64 scopeid 0x20<link>ether 00:50:56:2f:a8:6c txqueuelen 1000 (Ethernet)RX packets 937 bytes 222124 (216.9 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 688 bytes 95959 (93.7 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 192.168.22.129 netmask 255.255.255.0 broadcast 192.168.22.255inet6 fe80::20c:29ff:fe12:b11d prefixlen 64 scopeid 0x20<link>ether 00:0c:29:12:b1:1d txqueuelen 1000 (Ethernet)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 30 bytes 2152 (2.1 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 1111 bytes 68013 (66.4 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 1111 bytes 68013 (66.4 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@centos7_phpstudy network-scripts]#
如果觉得《VMware虚拟机Centos7配置双网卡双IP踩坑》对你有帮助,请点赞、收藏,并留下你的观点哦!