I have a non-gui CentOS 7 linux running in a VirtualBox on my (Windows) desktop computer. Recently, we had some trouble with our networking setup, making the DHCP-based networking fail; for a few days, I had trouble with my Linux box as well. During my struggle, I messed up the configuration of that box a little (experimenting with VirtualBox network adapters etc.).

Now, the "normal" networking works again, but in my vbox, I suddenly had trouble again; the time (which used to simply work) was behind the Windows machine by 6 days. And the route to important external resources was broken - I couldn't reach Github anymore, for example.

Obviously, the networking is managed by NetworkManager:

# LANG=C nmcli general
connected  full          enabled  enabled  enabled  enabled
# LANG=C nmcli device
enp0s8  ethernet  connected  Kabelgebundene Verbindung 1

The ifconfig command told me that in fact the enp0s8 was used; but the information didn't match. For example, according to ifconfig enp0s8, the IP4 address (inet) was, while the IPADDR values in the ifcfg-* files were different outdated values.

In my /etc/sysconfig/network-scripts/ directory, I had some garbage; among the ifcfg-* files I had an ifcfg-Kabelgebundene_Verbindung_1 file (with NAME="Kabelgebundene Verbindung 1", so this was the refered script); but the IP address etc. were outdated, and the matching route-Kabelgebundene_Verbindung_1 was empty. I had non-empty route-* files, though.

So my idea was to manually fix those files, using information from the ifconfig enp0s8 output.

First of all, I don't fully understand the information in the ifcfg-* files. There are HWADDR values, and there are (sometimes, different) MACADDR values. In an (outdated) ifcfg-enp0s3 file, I have both HWADDR and MACADDR, and the MACADDR here is the same as the HWADDR in ifcfg-Kabelgebundene_Verbindung_1 (which in turn doesn't contain a MACADDR value).

I expect the hardware address from ifconfig ("ether") to be correct under all circumstances, right?

So, my plan was:

  • Choose one set of scripts (in my case, {ifcfg,route}-Kabelgebundene_Verbindung_1), and throw away the others (preserving *-lo, of course).
  • In the ifcfg-* file,
    • set HWADDR to the ether value from ifconfig
    • set IPADDR to the inet value from ifconfig

It turned out that I was able to use BOOTPROTO=dhcp instead of setting IPADDR (and others) manually, since the DHCP server (in the other subnet, sigh ...) was found using the information in the corresponding route-* script.

I was not sure whether the adjusted scripts would have been used when doing something like ifconfig down enp0s8; ifconfig up enp0s8; so, after verifying my root password (to be sure I'd be able to login directly to the box, without ssh/PuTTY), I simply rebooted, and it worked.

What I couldn't work out yet:

  • What are these UUID values? I had different values, probably from different virtual network adapters, and I couldn't find them in the VBoxManage showvminfo "<vm name>" output. It was a matter of an "educated guess".
  • What would have been the best method to test my changes?

A simpler method to setup/restore networking on a headless server may be to use the "nmtui" interactive text-based menu.

$ yum install NetworkManager-tui
$ nmtui

                      │                           │ 
                      │ ┌─────────────┐           │ 
                      │ │ Ethernet  ↑ │ <Add>     │ 
                      │ │   enp4s0  ▒ │           │ 
                      │ │ Bridge    ▒ │ <Edit...> │ 
                      │ │   virbr0  ▮ │           │ 
                      │ │   cni0    ▒ │ <Delete>  │ 
                      │ │   br0     ▒ │           │ 
                      │ │           ▒ │           │ 
                      │ │           ▒ │           │ 
                      │ │           ▒ │           │ 
                      │ │           ▒ │           │ 
                      │ │           ↓ │ <Back>    │ 
                      │ └─────────────┘           │ 
                      │                           │ 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.