(偶然发现的虚拟机复制导致linux网卡eth0+1网络问题,记录一下)
(Unfortunately discovered virtual machine copying leads to linux webcaeth0+1 network problems, recording)
我发现刚安装好的虚拟机在配置无误时,能够保证正常上网功能。
I found that the virtual machine that had just been installed was correctly configured to ensure normal Internet access.
但在虚拟机每次经过克隆后,每次ifconfig扫描到的网卡会由eth0变为eth1,而且这个数字随克隆次数递增,观察一次克隆后的网卡信息 [root@XX]# ifconfig -a 发现原本的eth0网卡被eth1取代,查看网卡配置文件,进入目录/ect/sysconfig/network-scripts,发现eth0配置文件依旧存在,而eth1却找不到。vi进入文件发现空空如也,怪哉。
But every time the virtual machine is cloned, the net card that is scanned by ifconfig is changed from eth0 to eth1, and that number increases with the number of clones, observing the information of a cloned web card [root@XX]#ifconfig-a finds that the original eth0 web card was replaced by eth1, looking at the network card configuration file, entering the directory/ect/sysconfig/network-scripts, finding that the eth0 configuration file still exists, but not eth1.
考虑到问题发生在虚拟机复制过程重,故去/etc/udev/rules.d目录下查找由于安装系统后人为修改的规则,找到70-persistent-net.rules文件,查看网卡设备名称与mac地址的对应关系,发现问题:
In view of the weight of the problem during the virtual machine reproduction process, the search under the /etc/udev/rules.d catalogue for the rules that were artificially modified as a result of the installation of the system, the location of the 70-persistent-net.rules file, and the correspondence of the card device name to the Mac address, revealed the problem:
删除或注释后,保留NAME为"eth0"的网卡,回到/ect/sysconfig/network-scripts目录打开eth0配置文件,重写:
After deletion or comment, retain the net card for NAME as 34; eth034; return to /ect/sysconfig/network-scripts directory to open the eth0 profile file and rewrite:
要注意本机使用的NAT模式共享了主机的IP地址,我们可以在BOOTPROTO直接设置dhcp(意为自动检测IP地址),除此之外static和none都表示手工分配,若为手工分配则对应桥接或仅主机模式,需要手动填写(在网络连接详细信息中查看IP与掩码);DEVICE表示网卡设备名,它的值必须设置与编辑文件名中的"ifcfg-"后面的网卡名称相同,否则修改操作将不会生效;ONBOOT表示eth0是否随网络服务启动而生效,完成后保存退出。
To note that the NAT mode used by this machine shares the IP address of the host, we can set dhcp (meaning an automatic IP detection address) directly in BOOTPROTO, with the exception of a manual distribution of static and none, which needs to be filled in manually (see IP and mask in network connection details) if the matching bridge or only host mode is assigned manually; DEVICE means the network card device name, which must be set at the same value as 34; ifcffg-" the name of the back web card, otherwise the modification operation will not take effect; ONBOT indicates whether Eth0 will be effective as network service starts and will be saved after completion.
重启网络服务?[root@XX]# service network restart,在启动前确保网卡开启 [root@XX]# ifconfig eth0 up,ping百度查看是否成功,ping通完事儿,不通reboot重启再ping,解决问题,不知道算不算是虚拟机的复制bug,可能随学习深入发现小丑竟是我自己……
Reboot network service? [root@XX]#service network start, make sure the net card is open before startup [root@XX]#ifconfig eth0 up, ping 100 degrees to see if it's a success, ping finishes, doesn't reboot reping, solves the problem and wonders if it's a virtual machine copy bug and may learn to find out that the clown is me...
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论