Netplan: Set static IP address

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

Feb 17, 2025 - 09:57
 0
Netplan: Set static IP address

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