Ubuntu Server 20.04 set static IP with netplan
First check if you have file
1 |
/etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg |
If the file exists, make sure, you have the following content in it.
1 2 3 |
root@ubuntu:~# cat /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg network: {config: disabled} root@ubuntu:~# |
Edit
1 |
vi /etc/netplan/00-installer-config.yaml |
Replace all content with
1 2 3 4 5 6 7 8 9 10 |
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.
1 |
gateway4: 192.168.1.1 |
Now try the changes with
1 |
netplan try |
If all is good, you can make changes permanent with
1 |
netplan apply |
See IP