how to deal with ubuntu 18.04 network issues

URL Link //n.sfs.tw/13351

2019-06-21 11:44:50 By

As easy as usual, I moved one hard drive to a different physical machine with ubuntu installed first,

in older versions of ubuntu distributions, it is easy, the OS will determinate what interfaces on the new machine, and bring them up,

if not, just fix these configuration files using command line editor, the problems can be sloved easily.

However, after upgrading to 18.04, the fussy yaml took the place and made network settings more difficult,

I ran into first issue is, the network interface did not bring up automatically,

if you check by using "ip addr", the result is interface "DOWN",

then the "lshw -C network", the result is "*-network DISABLED",

you will have to fix "/usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf",

make the content modified to this below:

[keyfile]
unmanaged-devices=*,except:type:ethernet,except:type:wifi,except:type:wwan
 

then restart the service by using command as "service network-manager restart".

If you did it sucessfully, the network configuration will prompt on your desktop settings on the up right side in your desktop version,

then you can modify it based on visual graphical window user interface,

but I want to check yaml,

so the only issue I had is the "indentation",

indentation is everything in a yaml network configuration file,

if your indentation is wrong, the error message instead of telling you anything about your false setting, it just keep saying things like "Error in network definition:","unknown key","expected mapping",

just like JAVA error messages, you just don't know what's wrong with it,

finally, I figured out the great "indentation",

first layer is network, then you have to indent the every setting line below it, no mater two space or one, just remember it,

second layer is renderer, version and ethernets, some examples on search results might tell you that there is no need of these two lines, but it depends on you,

just remeber to indent! they should be placed on same level,

the third layer is the interface name, like enps02, etc.,

indent,

the fourth layer is dhcp4 or dhcp6, and static addresses, gateway,

then the nameservers, if you want to setup nameserver ip addresses, need to "indent" once again,

so a proper yaml may look like this:

# Let NetworkManager manage all devices on this system
network:
 renderer: NetworkManager
 ethernets:
  enp2s0:
   dhcp4: no
   dhcp6: no
   addresses: [x.x.x.x/24]
   gateway4: x.x.x.x
   nameservers:
    addresses: [x.x.x.x,8.8.4.4]
 version: 2

 

just remeber to indent and the levels of indentations.

latest update: a tui interface can solve this issue, by using "nmtui" package which is pre-installed inside system,

however, the debian ecosystem distro like ubuntu may not include this package...