Static IP address for Ubuntu Server 18.04 “netplan”

If you are using Ubuntu Server version 18.04 LTS and want to configure a static IP address, the procedure has changed for network interface configuration.

We used to configure /etc/network/interfaces but now the system uses something called netplan. If you try to configure the old “interfaces” file, it will point you to this new netplan network configuration.

Here’s how we change the network interface to use a static IP address. Edit “50-cloud-init.yaml“, replacing the text with the text below. Replace the IP address with your own (192.168.1.100 used as an example) and then save:

sudo nano /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp0s3:
            addresses: [192.168.1.100/24]
            gateway4: 192.168.1.1
            nameservers:
              addresses: [8.8.8.8,8.8.4.4]
            dhcp4: no
    version: 2

Apply the changes and then reboot.

sudo netplan apply
sudo reboot

Leave a comment

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