Question

eth0 not getting configured correctly after upgrade.

I recently upgraded an old droplet from 16.04 ->18.04 ->20.04. The first upgrade went fine but something broke networking after the second update. The droplet no-longer sets its IPV4 address/gateway correctly after a reboot. If I manually configured it using the recovery console everything works fine but it’s obviously broken again on next reboot.

In other words I need to run the following commands before I can use the droplet.

ifconfig eth0 <ipv4 address> netmask 255.255.240.0 up
ip route add default via <gateway>

I thought it might be an issue with cloud-init since I think that is meant to handle configuring the droplet and there was an exception logged in /var/log/cloud-init.log:

2023-09-15 23:16:30,093 - util.py[DEBUG]: Getting data from <class 'cloudinit.sources.DataSourceDigitalOcean.DataSourceDigitalOcean'> failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 1018, in find_source
    if s.update_metadata_if_supported(
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 904, in update_metadata_if_supported
    result = self.get_data()
  File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceDigitalOcean.py", line 48, in get_data
    (is_do, droplet_id) = self._get_sysinfo()
  File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceDigitalOcean.py", line 45, in _get_sysinfo
    return do_helper.read_sysinfo()
  File "/usr/lib/python3/dist-packages/cloudinit/sources/helpers/digitalocean.py", line 194, in read_sysinfo
    vendor_name = util.read_dmi_data("system-manufacturer")
AttributeError: module 'cloudinit.util' has no attribute 'read_dmi_data'
2023-09-15 23:16:30,096 - main.py[DEBUG]: No local datasource found

I tried upgrading cloud-init to the latest version but that didn’t seem to do anything. Didn’t even resolve the error message.

Any ideas? Should I just cut my loses and copy the data over to a new droplet?


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.

KFSys
Site Moderator
Site Moderator badge
September 16, 2023
Accepted Answer

Heya,

I think it’s possible it is related to cloud-init, yes.

First, try reconfiguring it:

sudo dpkg-reconfigure cloud-init

It’s possible that there’s stale data or configurations present from the older version of the OS. You can clean these up:

sudo cloud-init clean

Then reboot the droplet to see if it resolves the networking issue.

If that doesn’t worrk, we can try something else.

DigitalOcean uses a specific cloud-init configuration for its droplets. Check the /etc/netplan/ directory for any .yaml configuration files and make sure they are correct. It should look something like:

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true

If you make any changes, apply them using:

sudo netplan apply

Then, reboot to see if this resolves the issue.

If none of that work, I’ll recommend contacting DigitalOcean Support. They should be able to assist you with the network issue.

My update from 18 to 20 broke networking. I had to install a missing package before doing the upgrade then it worked ok.

sudo apt install landscape-common

Readers, beware: if your existing Ubuntu machine do not have /dev/vdb device (dmesg | grep -i vdb), do not use do-release-upgrade to Ubuntu 22.04.

I’ve got into similar problem after running do-release-upgrade on three-years-old droplet, the instance was not available by network because of this:

[root@machine ~]# cat /etc/netplan/50-cloud-init.yaml
network:
  version: 2
  ethernets:
    eth0:
      match:
        macaddress: "**:**:**:**:**:**"
      dhcp4: true
      dhcp6: true
      set-name: "eth0"

I’ve had to spin up another machine with Ubuntu 24.04 to copy the file from there as 10-local-override.yaml and adjusting the IP to match the old machine. To put it there, I had to reset the root password and connect via recovery console, after putting the override there netplan apply fixes at least non-reserved IP work and you can connect to the machine normally.

Proper file for reference:

[root@ksinia ~]# cat /etc/netplan/10-paskal.yaml
network:
    version: 2
    ethernets:
        eth0:
            addresses:
            - <external IP here>/20
            - 10.16.0.4/16
            match:
                macaddress: **:**:**:**:**:**
            mtu: 1500
            nameservers:
                addresses:
                - 67.207.67.2
                - 67.207.67.3
                search: []
            routes:
            -   to: 0.0.0.0/0
                via: <gateway IP here, same as external IP but with .1 in the last octet>
            set-name: eth0

I see that the problem is due to cloud-init missing some data:

[root@ksinia ~]# sudo cloud-init query v1 | grep availability
 "availability-zone": null,
 "availability_zone": null,

I think the problem is due to absence of /dev/vdb (config) device, which is present if you spin up a new machine with Ubuntu 22.04 in DigitalOcean.

I have no idea how to fix it and will copy the content manually to the new machine.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

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

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
Animation showing a Droplet being created in the DigitalOcean Cloud console