Netplan
Netplan is a network configuration util for linux.
Configuration
Section titled “Configuration”Configuration is stored in /etc/netplan/*.yaml. Multiple files may exist but alphabetically later ones will
override keys in previous files. Customise network configuration by creating the file /etc/netplan/99-custom.yaml
which will be loaded last.
Dynamic IP
Section titled “Dynamic IP”network: ethernets: enp0s8: dhcp4: true version: 2Static IP
Section titled “Static IP”# static IPnetwork: ethernets: enp0s3: addresses: - 192.168.120.62/24 enp0s8: addresses: - 192.168.140.62/24 gateway4: 192.168.140.1 nameservers: addresses: [192.168.100.66] version: 2The above
- assigns a single IP
192.168.120.62toenp0s3, with a netmask of255.255.255.0. - assigns a single IP
192.168.140.62toenp0s8, with a netmask of255.255.255.0.
It creates a route table
$ route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.140.1 0.0.0.0 UG 0 0 0 enp0s8192.168.120.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3192.168.140.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s8And updates DNS
$ resolvectl status
Link 3 (enp0s8) Current Scopes: DNSDefaultRoute setting: yes LLMNR setting: yesMulticastDNS setting: no DNSOverTLS setting: no DNSSEC setting: no DNSSEC supported: no Current DNS Server: 192.168.100.66 DNS Servers: 192.168.100.66Apply configuration
Section titled “Apply configuration”Run netplan try to immediately apply and confirm. It will rollback if you do not confirm the changes.
Do not reboot until configuration has been successfully applied and tested as it will attempt to apply the configuration at startup.
# netplan tryWarning: Stopping systemd-networkd.service, but it can still be activated by: systemd-networkd.socketDo you want to keep these settings?
Press ENTER before the timeout to accept the new configuration
Changes will revert in 119 secondsConfiguration accepted.