- Create a copy of existing Netplan config
cd /etc/netplan/
sudo cp 50-cloud-init.yaml 90-custom.yaml
- Update 90-custom.yaml
network:
version: 2
ethernets:
ens5:
dhcp4: true #enable or disable dhcp for IPv4
dhcp6: false #enable or disable dhcp for IPv6
accept-ra: false #set to true to allow IPv6 to be configured automatically. Distinct setting from dhcp6.
#Both DHCP and Static IPs can be enabled at the same time!
addresses: [<IPv4 Address>/20, '<IPv6 Address>/128']
gateway4: <IPv4 Gateway>
#IPv6 route might differ depending on cloud vendor. Check ip -6 route to get the actual route used via DHCP6/RA first
gateway6: 'fe80::1'
nameservers:
addresses: [<DNS1>, <DNS2>]
- Apply changes
- Confirm changes
ip -4 addr show
ip -6 addr show