Configure Static IP Addresses on Ubuntu 18.04 LTS Server

The way to configure a static IP in Ubuntu 18 is a bit different that the one in Ubuntu 16 and the previous versions. The file that needs to be modified is called 50-cloud-init.yaml and is located here: /etc/netplan. We will edit it.

sudo nano /etc/netplan/50-cloud-init.yaml

Originally, the file looks like this:

We need to add a couple of lines, but – very important – we should not change the indentation. I’ve struggled with some error messages when applying settings just because I’ve used TAB instead of SPACE, or because the indentation was off.

After modifications, the file should look like this:

We apply the new configuration using this command:

sudo netplan apply

NOTE: My netmask is 255.255.240.0, and that translates to 20 bits. If you have the more common netmask in your network, 255.255.255.0, then use 24 bits. Otherwise, use this table to find the number of bits required for you specific configuration:


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s