8

I migrated from Ubuntu 16 to 18.04, and now my Internet connectivity is broken. Problem seems to be that 18.04 is using netplan and it wasn't properly configured.

The file /etc/network/interfaces only contains the loopback device:

auto lo
iface lo inet loopback

All the other entries are commented out (probably by an installer script).

The directory /etc/netplan/ was empty. I created a 01-netcfg.yaml with the following contents:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes
      dhcp6: no
      # addresses: []
      gateway4: xxx.xx.xx.xxx
      nameservers:
        addresses: [xxx.xx.xx.xx, xxx.xx.xx.xx]
        addresses: [8.8.8.8, 8.8.4.4]

The command sudo netplan --debug apply reveals the following interesting lines:

NetworkManager: definition eth0 is not for us (backend 1)
DEBUG: eth0 not found in {}

While looking for solutions, I found that most people don't use eth0 in their yaml definition, but something like enp2s0. Howerver, the command ifconfig shows only the two interfaces, eth0 and lo. Same with ip addr show.

Any ideas?

digory doo
  • 441
  • 1
  • 5
  • 13
  • 1
    Is this a server system or a desktop system? if the latter, your interface is likely being rendered by `NetworkManager` already (hence "not for us") – steeldriver Jul 09 '19 at 13:25
  • It's a desktop system. I tried using renderer: NetworkManager also, but it didn't help. – digory doo Jul 09 '19 at 13:26
  • For reference, what do you see if you run `dmesg|grep eth0` ? Are there any `renamed from eth0` lines ? Also, what's the output of `sudo journalctl -xeu networkd` and of `sudo journalctl -xeu NetworkManager` ? You may need to change the `resolveer` to `NetworkManager` as that's probably still be default since your upgrade from 16.04 – taifwa Jul 09 '19 at 13:27
  • Eth0 was not renamed. The output from journalctl is empty. How do I change the resolveer? – digory doo Jul 09 '19 at 13:29
  • Sorry - `renderer`. But I see you already tried that. No typos when you tried, I take it.... – taifwa Jul 09 '19 at 13:30
  • (edited my first comment since I mistyped second journalctl command - do you indeed get no output when running journalctl agains `NetworkManager`?) – taifwa Jul 09 '19 at 13:31
  • No, journalctl against NetworkManager shows quite a lot of entries. – digory doo Jul 09 '19 at 13:32
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/95913/discussion-between-taifwa-and-digory-doo). – taifwa Jul 09 '19 at 13:34

2 Answers2

3

Your /etc/network/interfaces looks fine.

Change your /etc/netplan/01-netcfg.yaml to the following code (and only this)... using sudo -H gedit /etc/netplan/01-netcfg.yaml...

network:
  version: 2
  renderer: NetworkManager

Then, in terminal...

sudo netplan generate # generate config files

sudo netplan apply # apply configuration

reboot # reboot the computer

Then use the standard Network Manager GUI to establish a wired/wireless connection.

heynnema
  • 68,647
  • 15
  • 124
  • 180
  • 1
    Unfortunately, I was impatient and uninstalled netplan. I'm now back to resolv.conf, which works fine. So, I don't know if your answer would have solved the problem... – digory doo Jul 11 '19 at 06:07
  • @digorydoo if you've resorted to manually editing /etc/resolv.conf then you're still doing it wrong. And by removing a portion of the OS, you've handicapped your system. Best to reinstall netplan and follow my answer. – heynnema Jul 11 '19 at 13:21
  • 4
    This answer states that it's best to go back to the standard Network Manager (GUI). Am I the only one who does not find that satisfying? – Joe Eifert Dec 02 '19 at 13:39
  • 1
    @JoeEifert Desktop installations should normally be using NetworkManager. Server installations should use netplan. This user has an 18.04 desktop upgrade installation where netplan isn't working. And the user uninstalled netplan, so why not go back to using the NM GUI? – heynnema Dec 02 '19 at 15:58
  • @heynnema Generally yes. But I supposed there was a reason for him to not go with the default. E.G. I want to teach my students how it's done with netplan and the network manager, but they are learning on ubuntu desktop. – Joe Eifert Dec 08 '19 at 11:02
  • 1
    @JoeEifert If you read closely, the OP upgraded from Ubuntu 16.xx to 18.04. Ubuntu 16 was a NetworkManager environment. Setting 18.04 back to NM makes it just like they're used to, and it's the way it got installed in a default 18.04 desktop environment. Satisfied yet? – heynnema Dec 08 '19 at 14:43
0

First, check the interface name

ls -l /sys/class/net (or) sudo lshw -class network

then if you have netplan files move it .bkp(format)

sudo netplan generate

It will automatically generate with the previous setting and interface name, make sure you have the same interface name. if not, change the interface name

sudo netplan try
sudo netplan apply

or

sudo reboot
Dinesh KS
  • 31
  • 4