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?
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!
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.
Heya,
I think it’s possible it is related to cloud-init, yes.
First, try reconfiguring it:
It’s possible that there’s stale data or configurations present from the older version of the OS. You can clean these up:
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:If you make any changes, apply them using:
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.
I am piping in here to say I experienced this network failure when updating a droplet from 22.04.x to 24.04. The droplet was originally an Ubuntu 20.04 droplet and the 22.04 upgrade went off without a hitch, but this time around, my external networking completely broke. I ended up adapting what Dmitry recommended (his syntax did not quite work for me) and my network again works, including across reboots. The following will have to be entered on the recovery console by hand.
I created a custom /etc/netplan/10-local-override.yaml with the following:
Note that netplan parsing is exact. Use spaces, not tabs, and the number of spaces on every line must be EXACTLY what it expects or it will fail. You can find the correct mac address from the 50-cloud-init.yaml file in /etc/netplan. The IP addresses are from your droplet configuration. Use a subnet mask cheat sheet to figure out what the correct block sizes are.
You can then apply the configuration with sudo netplan apply. This has fixed things for me and the fix has survived reboots. It appears to be some cloud-init related data missing, a specific system device was not created or is not present, and/or some sort of problem with the cloud-init package that I can’t figure out (dpkg reconfigure did nothing for me) . I suspect the only long term solution is to spin up a new 24.04 droplet and import all my data, but who’s got time for that? I wanted to upgrade in place for a reason.
My update from 18 to 20 broke networking. I had to install a missing package before doing the upgrade then it worked ok.