You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

In today’s guide, we are going to see how to configure a static IP address on Ubuntu server 18.04/19.04. After installing Ubuntu 18.04/19.04 Server or Desktop, the default setting it to obtain an IP address automatically via DHCP server. This means that you will have to configure a Static IP address Manually.

If you are new to Linux you may consider reading Top 20 Basic Linux Most Used Commands for Newbies with Examples.

Method 1: Manually edit Network Configuration files

To get a Static Ip Address on Ubuntu server 18.04/19.04, you’ll edit interfaces configuration file located at /etc/network/interfaces. You can use vi/vim editor or nano editor for this purpose.

In this example, we’ll use vim editor and configure our server to use the IP address of, netmask, dns server and default gateway being

Open /etc/network/interfaces

sudo vim /etc/network/interfaces

If you prefer nano editor, use:

sudo nano /etc/netwok/interfaces

Then add the following lines replacing with your IP information.

auto eth0
iface eth0 inet static

Save the configuration changes and quit. You can also update DNS server settings at runtime by adding the lines inside /etc/resolv.conf file.

sudo tee /etc/resolv.conf <<EOF

For the changes to take effect, restart your network daemon by

sudo ifdown eth0 && sudo ifup eth0

Don’t forget to replace eth0 with your network card name.

Check that you have an ip address on eth0 interface by typing

$ ifconfig -a


$ ip addr

If you cannot see ip address, gateway, and netmask info, restart your computer. Just type the command reboot on the terminal

sudo reboot

Method 2: Use Netplan YAML network configuration

On Ubuntu 18.04/19.04, you can use Netplan which is a YAML network configuration tool to set static IP address.

This configuration assumes your network interface is called eth0. This may vary depending on your working environment.

Create a network configuration file.

 sudo nano /etc/netplan/01-netcfg.yaml

Then configure like below.

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
  version: 2
  renderer: networkd
      dhcp4: no
      # Ser IP address & subnet mask
      addresses: []
      # Set default gateway
        # Set DNS name servers
        addresses: [,]
      dhcp6: no

When done making the changes, save the configuration file and apply your network settings.

sudo netplan apply

To confirm your network settings, use the command:

$ ip addr 

If you don’t need IPv6, it’s possible to disable it like follows.

echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p 

Other Tutorials that you may Like

How To Customize Bash on Linux with Bash-it

Best Linux Books for Beginners & Experts 2019

Top Best Android Programming Books 2019

Best Arduino and Raspberry Pi Books For Beginners 2019

Best CCNA R&S (200-125) Certification Preparation Books 2019

Best CCNA Security (210-260) Certification Study Books

Best LPIC-1 and LPIC-2 certification study books 2019

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF