Ubuntu Static IP

Ubuntu uses Netplan (after Ubuntu 17.10).

Netplan configuration is written in yaml, with the

First, find the device name with ifconfig or ip link.

For me, thats enp0s3.

Change directory to etc/netplan.

In my VM of Ubuntu 20.04, there is one file in that director: 00-installer-config.yaml, so I’ll just go ahead and work with that one.

I’ll make a copy first just in case: sudo cp 00-installer-config.yaml 00-installer-config.yaml.bak This is what it looks like:

network:
  ethernets:
    enp0s3:
      dhcp4: true
  version: 2

I am going to change the new server to look like this:

 network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      addresses:
        - 192.168.1.10/24
      gateway4: 192.168.1.1
      nameservers:
          addresses: [8.8.8.8, 1.1.1.1]

After saving the file, run sudo netplan apply.

And hopefully we’ll see an updated IP