Static IP using Netplan
How to setup static IP using netplan on ubuntu 22.04 and above
Setting a static IP address on Ubuntu 22.04 and higher using netplan
netplan
Netplan basically acts as a translation layer, it takes configuration files, and creates the right systemd-networkd or Networkmanager configuration.
First disable the cloud-init networking.
Create a file, sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
with the following contents:
Then, edit the existing netplan configuration file, for me this was sudo nano /etc/netplan/50-cloud-init.yaml
, which originally looked like this:
What it’s basically doing is setting the network interface enp1s0
to use DHCP (and is not static).
Change it to make it look like this:
dhcp4: false
anddhcp6: false
are disabling DHCP for both IPv4 and IPv6.addresses
is setting the static IP address.routes
is setting the default gateway and pointing at my router, 192.168.50.1nameservers
is setting the DNS servers to use, I’ve chosen one Cloudflare and one Google DNS.
Apply changes using:
Check status using:
Last updated