Ruan Bekker's Blog

From a Curious mind to Posts on Github

How to Set a Static IP in Ubuntu 18

This is a short post on how to set a static ip address on ubuntu 18.04 using netplan

Netplan

At the moment my network interfaces uses dhcp, and we can see that below:

1
2
3
4
5
6
$ cat /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true

Changing the configuration to static:

1
2
3
4
5
6
7
8
9
10
$ cat /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    ethernets:
        eth0:
            dhcp4: false
            addresses: [10.37.117.37/24]
            gateway4: 10.37.117.1
            nameservers:
                addresses: [127.0.0.53,8.8.8.8]

After changing the configuration, you need to apply your changes:

1
$ netplan apply

Thank You

Thank you for reading my short post on how to change a static ip address on ubuntu 18.04 using netplan