Note: This may not be a recommended approach to configuring Ubuntu, but I found it easier to roll back to how things worked in older versions.
Ubuntu 18.04 and newer use something called NetPlan and CloudInit to manage networking. It is supposed to be more flexible and more powerful than traditional networking. Myself (and many others) have instead found it to be an inconsistent, overly complicated pain. In fact, I still haven't found adequate information on where CloudInit stores its initial settings after install.
Let's assume you just completed an Ubuntu 18.04, 20.04, or 22.04 install, and want to quickly get your network up and running similar to how you had it in Ubuntu 16.04 or 14.04...
Update APT database:
sudo apt update
Install the old networking:
sudo apt install ifupdown net-tools
Disable the new DNS:
sudo systemctl disable systemd-resolved.service
To change your interface name back to the old "eth0" that you're familiar with, edit the /etc/default/grub file and change the line with GRUB_CMDLINE_LINUX to look like this:
Now load the new Grub configuration:
And reboot to apply your changes:
Edit/Re-create your /etc/network/interfaces file. It may look something like this:
# # /etc/network/interfaces # # loopback auto lo iface lo inet loopback # IPv4 auto eth0 iface eth0 inet static address 192.168.1.99 netmask 255.255.255.0 gateway 192.168.1.1 # IPv6 # iface eth0 inet6 auto # EoF
Remove your old NetPlan config:
sudo rm /etc/netplan/00-installer-config.yaml
Restart the network:
sudo /etc/init.d/networking restart
Remove and re-create your /etc/resolv.conf file.
sudo unlink /etc/resolv.conf
It may look something like this:
# # /etc/resolv.conf # nameserver 188.8.131.52 nameserver 184.108.40.206 search localhost localhost.example.com domain example.com # EoF
sudo apt purge cloud-init
Optional, you can remove the old CloudInit configuration files:
sudo rm -fr /etc/cloud/ sudo rm -fr /var/lib/cloud/
Now you're free to change your hostname to anything you want, without CloudInit permanently keeping the old hostname in its configuration.
sudo hostname MyHostName