How to configure IP's on Ubuntu 18?

To configure a static IP address on your Ubuntu 18.04 server you need to modify a relevant Netplan network configuration file within /etc/netplan/ directory.  Ubuntu introduced Netplan utility to configure the network on Ubuntu 18.04 LTS. It uses YAML file format to read network configuration from /etc/netplan/ directory.

Following are the steps for configuring IPs on Ubuntu 18.04 

Step 1

You might find there a default Netplan configuration file called 01-netcfg.yaml or 50-cloud-init.yaml (may vary from version to version).

WARNING: You must adhere to a correct code indent for each line of the block. In other words, the prefix number of spaces for each line is essential.

# cat /etc/netplan/01-netcfg.yaml


# This the file describes the network interfaces available on your system
# For more information, see netplan(5).

      renderer: networkd
                         dhcp4: no
                         addresses: [192.168.XX.XXX/24]
                                     addresses: [,]
      version: 2


Here we have disabled dhcp4 with no option since we do not want dynamic allocation of IP addresses.

addresses: line should contain server IP address with subnet CIDR Prefix (More about CIDR)
gateway4: The line should contain the default gateway.
nameservers: contains IP addresses of primary and secondary DNS. In the above example, we have used Google's Public DNS servers IP addresses

Please make sure you have added those lines with the correct format.


Step 2

Once ready apply changes with:

# netplan apply

In case you run into some issues execute:

# netplan --debug apply

The above the command will help you to identify if there's an issue with the data you have inputted.

Example output

Invalid YAML at //etc/netplan/01-netcfg.yaml line 7 column 6: did not find expected key


Congratulations! You’ve successfully configured a network static IP addresses to your Ubuntu servers.


  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to add IP Address to servers

1.Login to the server via RDP. 2.In the Run window type NCPA.CPL. 3.In the network properties...

How to install Wordpress in webmin

  The following steps are followed for installing Wordpress in Webmin   Open File Manager in...

How to install Webmin in CentOs

  Installing webmin using YUM repository Create a .repo file using a command # nano...

How to install Virtualmin in webmin

  Steps for Installing Virtualmin on Webmin (Ubuntu):   Setting the hostname and FQDN For...

How to Install Duplicati Client in Centos

Duplicati Installation in Centos :   As Duplicati depends on other software, we need to install...