如何在复制VM和VBOX虚拟机时重新配置网卡-创新互联

如何在复制VM和VBOX虚拟机时重新配置网卡?这个问题可能是我们日常学习或工作经常见到的。通过这个问题,希望你能收获更多。今天跟随小编一起来看解决方案吧。

网站设计制作过程拒绝使用模板建站;使用PHP+MYSQL原生开发可交付网站源代码;符合网站优化排名的后台管理系统;网站制作、成都网站建设收费合理;免费进行网站备案等企业网站建设一条龙服务.我们是一家持续稳定运营了10年的成都创新互联网站建设公司。

1、 新复制的虚拟机,请选择重新生成MAC地址,这个步骤在复制(克隆,WHATEVER)的时候,或者在复制完成,又或者完成后点配置,网卡属性,高级属性(各种平台各不相同,找到重新生成MAC地址,勾上或者刷新)。记录下这个MAC地址
2、新虚拟机启动以后,无论网络是否正常,停掉NetworkManager.Service...真的没有那么好用。
systemctl stop NetworkManager
systemctl disable NetworkManager
3、运行ifconfig -a, 得到新网卡的网卡名称,(也是设备名称,结合刚才记录下的MAC地址,很容易对上)
4、到/etc/sysconfig/network-scripts文件夹修改ifcfg-enxxx网卡启动配置文件
4.1、 强烈建议删除ifcfg-profile1类似这个脚本,这个是NetManager遗留。
4.2、 用uuidgen  enxxx这样的格式得到uuid写入配置档。
4.3、 写完配置档,重启网卡设备systemctl restart network。如果没有报错就完成了。

####举例:
###配置一个网卡最终要三个要素,设备名,MAC地址,UUID

eno16777736: flags=4163  mtu 1500
     inet 192.168.1.201  netmask 255.255.255.0  broadcast 192.168.1.255
     inet6 fe80::20c:29ff:fe4a:b12c  prefixlen 64  scopeid 0x20
     ether 00:0c:29:4a:b1:2c  txqueuelen 1000  (Ethernet)
     RX packets 3647  bytes 3417904 (3.2 MiB)
     RX errors 0  dropped 0  overruns 0  frame 0
     TX packets 142  bytes 18249 (17.8 KiB)
     TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno33554992: flags=4163  mtu 1500
     inet 192.168.199.241  netmask 255.255.255.0  broadcast 192.168.199.255
     inet6 fe80::20c:29ff:fe4a:b136  prefixlen 64  scopeid 0x20
     ether 00:0c:29:4a:b1:36  txqueuelen 1000  (Ethernet)
     RX packets 5605  bytes 3465915 (3.3 MiB)
     RX errors 0  dropped 0  overruns 0  frame 0
     TX packets 1400  bytes 322360 (314.8 KiB)
     TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

###uuidgen (注意,UUID每次生成都不同,但是每个生成的ID都是可以用的)

[root@mysql01 dev]# uuidgen eno16777736
fd32246b-c655-45c6-ab6a-7a6aa84faa72
[root@mysql01 network-scripts]# uuidgen eno33554992
44e70d2f-4bf1-4753-865b-8fb042ecc8d6
设备名MAC地址UUID
eno1677773600:0c:29:4a:b1:2cfd32246b-c655-45c6-ab6a-7a6aa84faa72
eno3355499200:0c:29:4a:b1:3644e70d2f-4bf1-4753-865b-8fb042ecc8d6

###停止NetworkManager

[root@mysql01 network-scripts]# systemctl stop NetworkManager
[root@mysql01 network-scripts]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.

[root@mysql01 network-scripts]# systemctl status NetworkManager
* NetworkManager.service - Network Manager
  Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; disabled; vendor preset: enabled)
  Active: inactive (dead) since 日 2020-01-26 14:22:15 CST; 36s ago
 Main PID: 8417 (code=exited, status=0/SUCCESS)

1月 26 14:22:07 mysql01 NetworkManager[8417]:   (eno16777736): Activation: successful, device activated.
1月 26 14:22:07 mysql01 NetworkManager[8417]:   wpa_supplicant running
1月 26 14:22:07 mysql01 NetworkManager[8417]:   (virbr0): device state change: secondaries -> activated (reason 'none...100 0]
1月 26 14:22:07 mysql01 NetworkManager[8417]:   (virbr0): Activation: successful, device activated.
1月 26 14:22:15 mysql01 NetworkManager[8417]:   caught SIGTERM, shutting down normally.
1月 26 14:22:15 mysql01 NetworkManager[8417]:   (virbr0): bridge port virbr0-nic was detached
1月 26 14:22:15 mysql01 NetworkManager[8417]:   (virbr0-nic): released from master virbr0
1月 26 14:22:15 mysql01 systemd[1]: Stopping Network Manager...
1月 26 14:22:15 mysql01 NetworkManager[8417]:   exiting (success)
1月 26 14:22:15 mysql01 systemd[1]: Stopped Network Manager.
Hint: Some lines were ellipsized, use -l to show in full.
[root@mysql01 network-scripts]# ifconfig

###写配置档:(这里的UUID可能和我上面获得的不同,因为配置档是之前就写好的.)
-rw-r--r--. 1 root root  292 1月  24 14:52 ifcfg-eno16777736
-rw-r--r--. 1 root root  367 1月  26 13:29 ifcfg-eno33554992

[root@mysql01 network-scripts]# cat ifcfg-eno16777736
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=a808b074-580f-4ff7-b70a-e307769e8d96
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.1.201
PREFIX=24
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

[root@mysql01 network-scripts]# cat ifcfg-eno33554992
TYPE=Ethernet
BOOTPROTO=static
IPADDR0=192.168.199.241
PREFIXO0=24
GATEWAY=192.168.199.1
DNS1=192.168.199.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno33554992
UUID=9c7d8550-2d46-45c1-9c40-ef09570e1608
DEVICE=eno33554992
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

###重启网络服务:

[root@mysql01 network-scripts]# systemctl restart network.service
[root@mysql01 network-scripts]#

###没有报错

[root@mysql01 network-scripts]# systemctl status network.service
* network.service - LSB: Bring up/down networking
  Loaded: loaded (/etc/rc.d/init.d/network)
  Active: active (exited) since 日 2020-01-26 14:27:22 CST; 18s ago
   Docs: man:systemd-sysv-generator(8)
  Process: 8612 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
  Process: 8839 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)

1月 26 14:27:17 mysql01 systemd[1]: Starting LSB: Bring up/down networking...
1月 26 14:27:17 mysql01 network[8839]: [29B blob data]
1月 26 14:27:19 mysql01 network[8839]: [37B blob data]
1月 26 14:27:22 mysql01 network[8839]: [37B blob data]
1月 26 14:27:22 mysql01 systemd[1]: Started LSB: Bring up/down networking.
[root@mysql01 network-scripts]# 

###尝试ifup/ifdown脚本:

[root@mysql01 network-scripts]# ifdown eno16777736
[root@mysql01 network-scripts]# ifconfig eno16777736
eno16777736: flags=4098  mtu 1500
     ether 00:0c:29:4a:b1:2c  txqueuelen 1000  (Ethernet)
     RX packets 4359  bytes 4215191 (4.0 MiB)
     RX errors 0  dropped 0  overruns 0  frame 0
     TX packets 169  bytes 22144 (21.6 KiB)
     TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@mysql01 network-scripts]# ifup eno16777736
[root@mysql01 network-scripts]# ifconfig eno16777736
eno16777736: flags=4163  mtu 1500
     inet 192.168.1.201  netmask 255.255.255.0  broadcast 192.168.1.255
     inet6 fe80::20c:29ff:fe4a:b12c  prefixlen 64  scopeid 0x20
     ether 00:0c:29:4a:b1:2c  txqueuelen 1000  (Ethernet)
     RX packets 4362  bytes 4218484 (4.0 MiB)
     RX errors 0  dropped 0  overruns 0  frame 0
     TX packets 187  bytes 25011 (24.4 KiB)
     TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@mysql01 network-scripts]# 
[root@mysql01 network-scripts]# ifdown eno33554992
[root@mysql01 Desktop]# ifconfig eno33554992
eno33554992: flags=4098  mtu 1500
     ether 00:0c:29:4a:b1:36  txqueuelen 1000  (Ethernet)
     RX packets 7980  bytes 4516864 (4.3 MiB)
     RX errors 0  dropped 0  overruns 0  frame 0
     TX packets 2422  bytes 504771 (492.9 KiB)
     TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@mysql01 Desktop]# ifup eno33554992
[root@mysql01 Desktop]# ifconfig eno33554992
eno33554992: flags=4163  mtu 1500
     inet 192.168.199.241  netmask 255.255.255.0  broadcast 192.168.199.255
     inet6 fe80::20c:29ff:fe4a:b136  prefixlen 64  scopeid 0x20
     ether 00:0c:29:4a:b1:36  txqueuelen 1000  (Ethernet)
     RX packets 7982  bytes 4519567 (4.3 MiB)
     RX errors 0  dropped 0  overruns 0  frame 0
     TX packets 2440  bytes 507648 (495.7 KiB)
     TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@mysql01 Desktop]#

看完这篇文章,你们学会在复制VM和VBOX虚拟机时重新配置网卡了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读。

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享名称:如何在复制VM和VBOX虚拟机时重新配置网卡-创新互联
本文地址:http://pwwzsj.com/article/djsges.html