Ubuntu Server 20.04 set static IP with netplan

First check if you have file

/etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg

If the file exists, make sure, you have the following content in it.

root@ubuntu:~# cat /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
network: {config: disabled}
root@ubuntu:~# 

Edit

vi /etc/netplan/00-installer-config.yaml

Replace all content with

network:
    version: 2
    ethernets:
        eth0:
            addresses: [192.168.1.100/24]
            routes:
                - to: default
                  via: 192.168.1.1
            nameservers:
                addresses: [1.1.1.1, 8.8.8.8]

In the above cause 192.168.1.100 is your static IP address. 192.168.1.1 is the gateway. eth0 is the network interface name.

Older versions of netpan used gateway4 instead of routes.

            gateway4: 192.168.1.1

Now try the changes with

netplan try

If all is good, you can make changes permanent with

netplan apply

See IP

Need help with Linux Server or WordPress? We can help!

Leave a Reply

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