I’ve only just begun using Ubuntu 18.04 server and one of the very first things I noticed was that network configuration is now done using netplan. I’m so used to doing the following:
To my surprise a message in /etc/network/interfaces says that ifupdown has been replaced by netplan. It turns out that although it’s a new way of configuring network settings, it isn’t all that hard.
First, issue these commands:
All the above commands do are disable cloud-init’s network configuration capabilities. If you reboot with the above configuration, you will have no network. To set a static IP address, create a new YAML file with the following:
Now check the settings are ok in this file:
If everything is ok you have the option to immediately apply the settings by pressing Enter.
If you want to use a dynamic IP address instead, all you need to change in the above configuration is dhcp4: yes, then remove everything below it:
Again, check the settings are ok, then press Enter.