This content originally appeared on DEV Community and was authored by Sergio Peris
In order to set a static IP address to an interface using Netplan, we have to edit the desired Netplan yaml file.
Here is an example for configuring the interface eth0
with a static IP address.
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: false
dhcp6: false
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
Here we're setting the IP 192.168.1.100
as the static IP, 192.168.1.1
as the gateway, 1.1.1.1
and 8.8.8.8
as the DNS servers.
To apply the changes, we should run the command:
netplan apply
This content originally appeared on DEV Community and was authored by Sergio Peris

Sergio Peris | Sciencx (2025-02-17T08:04:26+00:00) Netplan: Set static IP address. Retrieved from https://www.scien.cx/2025/02/17/netplan-set-static-ip-address/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.