Set network settings with netplan

If your system is using netplan for network configuration, change settings in “/etc/netplan/50-cloud-init.yaml”:

DHCP:

jonas@kube-c1-n3:~$ cat /etc/netplan/50-cloud-init.yaml
network:
    ethernets:
        enp0s3:
            addresses: []
            dhcp4: true
    version: 2
jonas@kube-c1-n3:~$ sudo netplan apply

Static IP:
jonas@kube-c1-n3:~$ cat /etc/netplan/50-cloud-init.yaml
network:
    ethernets:
        enp0s3:
            addresses: [192.168.10.103/24]
            gateway4: 192.168.10.1
            dhcp4: no
    version: 2
jonas@kube-c1-n3:~$ sudo netplan apply

Note that “gateway4” should only be set for the default route interface.

Leave a Reply