How to Setup Static | Fixed IP on Ubuntu 20.04 | 18.04

This brief tutorial shows students and new users how to configure a static or fixed IP addresses on Ubuntu 20.04 | 18.04.

Generally, IP addresses are assigned dynamically and you probably would not need to assign fixed IP addresses.

However, in certain situations, you may need to setup static IP addresses on some machines that are not going to be receiving IP dynamically from DHCP servers.

Since the release of Ubuntu 17.10, NetPlan is now the default network configuration tool to manage network settings replacing the configuration file /etc/network/interfaces that was used in previous versions.

Netplan currently supports two renderers NetworkManager and Systemd-networkd.

NetworkManager is mostly used on Desktop machines while the Systemd-networkd is used on servers without a GUI.

The new interfaces configuration file now lives in the /etc/netplan directory. There are two renderers. NetworkManager and networkd.

When you use NetworkManager as the renderer, you will use the NetworkManager GUI to manage the interfaces.

Ubuntu uses a ‘Predictable Network Interface Names’ that, by default, start with en[letter][number].

Netplan configuration files are stored in the /etc/netplan directory and have the extension .yaml. You’ll probably find one or two YAML files in this directory.

The network configuration file will differ from setup to setup. Some may be named 01-netcfg.yaml, 50-cloud-init.yaml, etcs.

Below is a sample file for a network interface using networkd as renderer using DHCP. Networkd uses the command line to configure the network interfaces.

sudo nano /etc/netplan/*.yaml

You should see a similar DHCP server for servers like the one below:

      dhcp4: true
  renderer: networkd
  version: 2

On Desktops, you may see something like the one below:

  renderer: NetworkManager
  version: 2

Static IP Addresses with Networkd

To configure a static IP address using the new NetPlan tool on Ubuntu server, the file should look similar to the content below.

Run the commands below to open the network configuration file.

sudo nano /etc/netplan/*.yaml

Then change the dhcp4 value to no, then configure the static IP address details, including DNS and Gateway addresses.

      dhcp4: false
      gateway4: ""
          - ""
          - ""
  renderer: networkd
  version: 2

When you’re done editing the file, save it and exit.

You will want to make sure that the file meets YAML code indent standards. If not probably indented, you’ll get an error.

Run the commands below to apply your changes.

sudo netplan apply

To validate that your changes are apply, run the commands below to view the IP address configuration detals.

ip addr show dev enp0s3

It should display similar lines like the one below:

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:e0:e9:4d brd ff:ff:ff:ff:ff:ff
    inet brd scope global dynamic noprefixroute enp0s3
       valid_lft 976sec preferred_lft 976sec
    inet6 fe80::2aa0:522f:4f82:8d5b/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Step 2: Setup Static IPs on Desktop

To setup static IP addresses on Ubuntu desktops, click the network icon in the top menu, the select Wired Connected –> Wired Settings.

This will open the GNOME Network configuration settings. Click on the cog icon.

Then choose Manual for IPv4 Method, and setup the IP, Network, Gateway and/or DNS addresses. Click the Apply to save your changes.

This how how to configure static IP addresses on Ubuntu systems.

For more about Netplan, visit this site.

This brief tutorial showed students and new users how to configure your static or fixed IP address on Ubuntu systems.

If you find any error above, please use the comment form below to report.


You may also like the post below:

3 Replies to “How to Setup Static | Fixed IP on Ubuntu 20.04 | 18.04”

  1. My .yaml file has just two lines
    Let NetworkManager manage all devices on this system
    version: 2
    renderer: NetworkManager

    The system has set things up differently from the way described above.

  2. Hi,
    There is a syntax error here : addresses:
    It should be :


    or addresses: []

  3. Before applying these instructions to my (virtualbox) Ubuntu 20.04 desktop, its ip, from dhcp, was And, after installing and enablig ssh, I was able to connect via ssh from my Windows 10 host), using ssh inside Power Shell.

    After setting fixed ip to, ssh stopped working.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.