How to add IPv6 to Ubuntu 24.04 or later using netplan.
On Ubuntu 24.04, network configuration is managed by netplan. To enable IPv6 on your interface, you need to edit the YAML configuration file under /etc/netplan/.
Usually you will find a .yaml file inside /etc/netplan/. Open it with your editor, for example: 50-cloud-init.yaml
sudo nano /etc/netplan/50-cloud-init.yaml
You will find its content similar to this:
network:
version: 2
ethernets:
interface0:
match:
macaddress: "00:11:12:aa:bb:cc"
addresses:
- "192.168.1.10/24"
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
routes:
- to: "default"
via: "162.220.24.1"
on-link: true
Edit the file to add:
- an IPv6 address in the
addressessection, - an IPv6 gateway under the
routessection, - and an IPv6 nameserver under the
nameserverssection.
For example:
network:
version: 2
ethernets:
interface0:
match:
macaddress: "00:11:12:aa:bb:cc"
addresses:
- "192.168.1.10/24"
- "fd12:3456:789a::ac58/64"
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
- 2001:4860:4860::8888
routes:
- to: "default"
via: "162.220.24.1"
on-link: true
- to: "::/0"
via: "fd12:3456:789a::1"
on-link: true
Replace fd12:3456:789a::1 with your actual IPv6 gateway, and fd12:3456:789a::ac58/64 with your actual IPv6 address and prefix.
Then apply the changes with:
sudo netplan apply
Your system should now have both IPv4 and IPv6 connectivity.
