Configure Static IP Address on Ubuntu 18

Recently I have been working with Ubuntu 18, there has been a lot of changes but one of the biggest change is how networking is managed and configured.

When you cat /etc/network/interfaces file it tells us to use Netplan.

Netplan is the new network configuration management tool that was introduced in Ubuntu 17.10.
With Netplan you can  simply create a YAML description of the required network interfaces and what each should be configured to do. From this description Netplan will generate all the necessary configuration for your chosen renderer tool.

Netplan replaces the existing static network configuration file /etc/network/interfaces now you need to use /etc/netplan/*.yaml files to configure the network interfaces on Ubuntu.

There are two types of renderer tool NetworkManager and networkd
NetowkrManager with GUI is mostly used on the Ubuntu desktop environments where as networkd is used on the Ubuntu servers.

Below is an example of how to use Netplan with networkd on a Ubuntu server.

By default when Ubuntu is installed it will be configured with DHCP and and file will look something like this. Here I have two interfaces enp0s3 and enp0s8 you may have only one and names cloud be different.

# vim /etc/netplan/50-cloud-init.yaml


Edit the file and add the following configuration.

                               addresses: []
                                         addresses: []
                               dhcp4: no
           version: 2


I have configured one of the network interface enp0s3 as static  and second one enp0s8 left as dhcp.

After the changes are done save the file and apply the changes with netplan as follows.

# netpaln  apply


# netplan –debug apply

This will activate the configuration and if there are any errors in the file it will show that on screen.
Thats it one it is done your Ubuntu will be configured with staic IP.

Did it work for you or you faced any errors let me know in comment section. Happy Networking.

3,547 Replies to “Configure Static IP Address on Ubuntu 18”