VM, CentOS 7 Configuration Network Card in VBOX

We often need to copy the virtual machines of VM and VBOX. One of the steps we can't take is to reconfigure the network card.
Sometimes it's very cumbersome.
A slightly simpler operation is recorded here, with no udev device bound to various sauce operations.

1. For newly replicated virtual machines, please choose to regenerate the MAC address. This step is when replication (cloning, WHATEVER) is completed, or when replication is completed, or after point configuration is completed, network card properties, advanced properties (different platforms, find the regenerated MAC address, tick or refresh).Record this MAC address
2. Stop NetworkManager.Service after the new virtual machine starts, whether the network is working or not. It's really not that useful.
systemctl stop NetworkManager
systemctl disable NetworkManager
3. Run ifconfig-a to get the name of the network card of the new network card. (This is also the name of the device, combined with the MAC address just recorded, it is easy to access)
4. Modify ifcfg-enxxx network card boot profile to/etc/sysconfig/network-scripts folder
4.1. It is strongly recommended that ifcfg-profile1 be deleted similar to this script, which is a legacy of NetManager.
4.2. Write the uuid to the configuration file in a format such as uuidgen enxxx.
4.3. Finish writing the configuration file and restart the network card device systemctl restart network.Complete without error.

Examples of ####
Configuring a network card ultimately requires three elements: device name, MAC address, UUID

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
        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<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
        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 (Note that UUID s are generated differently each time, but each generated ID is available)

[root@mysql01 dev]# uuidgen eno16777736
fd32246b-c655-45c6-ab6a-7a6aa84faa72
[root@mysql01 network-scripts]# uuidgen eno33554992
44e70d2f-4bf1-4753-865b-8fb042ecc8d6
Device Name MAC Address UUID
eno16777736 00:0c:29:4a:b1:2c fd32246b-c655-45c6-ab6a-7a6aa84faa72
eno33554992 00:0c:29:4a:b1:36 44e70d2f-4bf1-4753-865b-8fb042ecc8d6

Stop 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 Day 2020-01-26 14:22:15 CST; 36s ago
 Main PID: 8417 (code=exited, status=0/SUCCESS)

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

###Write profile: (The UUID here may be different from what I got above, because the profile was written before.)
-rw-r--r--. 1 root 292 January 24 14:52 ifcfg-eno16777736
-rw-r--r--. 1 root 367 January 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

Restart Network Service:

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

No error reported

[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 Day 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 February 2614:27:17 mysql01 systemd[1]: Starting LSB: Bring up/down networking...
1 February 2614:27:17 mysql01 network[8839]: [29B blob data]
1 February 2614:27:19 mysql01 network[8839]: [37B blob data]
1 February 2614:27:22 mysql01 network[8839]: [37B blob data]
1 February 2614:27:22 mysql01 systemd[1]: Started LSB: Bring up/down networking.
[root@mysql01 network-scripts]# 

###Try the ifup/ifdown script:

[root@mysql01 network-scripts]# ifdown eno16777736
[root@mysql01 network-scripts]# ifconfig eno16777736
eno16777736: flags=4098<BROADCAST,MULTICAST>  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<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
        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<BROADCAST,MULTICAST>  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<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
        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]# 

complete

Keywords: Linux network Mac DBus

Added by JMJimmy on Sun, 26 Jan 2020 09:18:45 +0200