Question

Upgrading Ubuntu 20.x -> 22.x killed my network

I’ve spent the last several hours trying to figure out what’s going on, but I’m totally stuck.

I was trying to upgrade my droplet from Ubuntu 20.x to Ubuntu 22.x using this guide. Now my networking doesn’t work.

  • I can only access the droplet through the recovery terminal, so copy-pasting details is not possible.
  • When using the terminal, I can ping localhost, but I can’t ping the gateway.
  • DNS doesn’t work because the network is totally unreachable.
  • ufw status shows ssh port is LIMIT IN from Anywhere and: deny (incoming), allow (outgoing), disabled (routed).
  • /etc/netplan/50-cloud-init.yaml file shows one entry for “ens3”.
  • “ip a” shows two interfaces: “lo” (state UNKNOWN) and “ens3” (state UP).
  • “ip route” does not return anything.

How do I troubleshoot this?

Thanks for any help!

  • Andy

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

To answer my own question via DO support (thanks Mubashir!)…

The issue was with “systemd’s predictable network interface naming”.

The solution was to turn it off via GRUB.

  • edit /etc/default/grub.d/50-cloudimg-settings.cfg and add net.ifnames=0 at the end of GRUB_CMDLINE_LINUX_DEFAULT:

GRUB_CMDLINE_LINUX_DEFAULT=“console=tty1 console=ttyS0 net.ifnames=0”

  • then:

update-grub

reboot

So the answer above didn’t work for me. What I ended up doing was creating a new YAML file at /etc/netplan/config.yaml with the following content:

network:
  version: 2
  renderer: networkd
  ethernets:
      eth0:
          addresses: [ "<droplet IP address>/24" ]
          routes:
            - to: default
              via: <droplet gateway IP address>
              on-link: true #only needed if the droplet is on a different subnet

If your droplet gateway is on a different subnet (i.e. more than just the last set of numbers in the IP address and gateway IP address are different), you need to include the “on-link” line.

Save the file and then run this command:

netplan generate

followed by

netplan apply

That will set the static IP and gateway address and make it persist past reboots.

If you need to temporarily add the static IP address and gateway, use these commands:

ip addr add <droplet IP address> dev eth0
ip link set dev eth0 up
ip route add default via <gateway IP address> onlink dev eth0

This will give you connectivity in order to run updates and install additional packages, but that connectivity will not persist on reboot.

I hope this helps someone.

In my case the issue was caused by the fact that eth0 was replaced by ens0. In order to check what your card name is :

ll /sys/class/net/
total 0
drwxr-xr-x  2 root root 0 set 26 08:46 ./
drwxr-xr-x 70 root root 0 set 26 08:46 ../
lrwxrwxrwx  1 root root 0 set 26 08:49 docker0 -> ../../devices/virtual/net/docker0/
lrwxrwxrwx  1 root root 0 set 26 08:46 ens3 -> ../../devices/pci0000:00/0000:00:03.0/virtio1/net/ens3/
lrwxrwxrwx  1 root root 0 set 26 08:46 lo -> ../../devices/virtual/net/lo/
lrwxrwxrwx  1 root root 0 set 26 08:49 veth0210b8e -> ../../devices/virtual/net/veth0210b8e/

as you can see I have no eth0 but I have a “suspicious” ens3.

Cross reference the findings with what’s inside /etc/network/interfaces.d/50-cloud-init.cfg


auto eth0
iface eth0 inet static
    address <your ip>
    dns-nameservers 8.8.8.8 8.8.4.4
    gateway <your gateway>
    netmask 255.255.192.0
    post-up ifup eth0:1


auto eth0:1
iface eth0:1 inet static
    address <your ip>
    netmask 255.255.0.0

At that point I changed the occurrences of eth0 with ens3 in cloud-init.cfg and tried to manually up/down my network :

ifdown eth0
ip addr flush dev eth0
ip addr flush dev ens3
ifup ens3

ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=2.96 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=0.853 ms

nslookup google.com
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	google.com
Address: 142.250.179.174
Name:	google.com
Address: 2a00:1450:400e:811::200e

all up and running.

Reboot

njoy :)

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.