More and more visitors, especially on mobile networks, reach the internet over IPv6. Giving your VPS an IPv6 address lets them connect natively, and some mail and API providers prefer it. This guide configures it, secures it and tests it. For background see IPv4 vs IPv6 explained.
Before you start
- The IPv6 address (or subnet such as a
/64) and gateway assigned to your VPS, from the panel or support (IPs in Virtualizor). - VNC console access in case of mistakes.
- Basic static IP knowledge from configure a static IP with Netplan and nmcli.
Check whether IPv6 already works
ip -6 addr show scope global
ip -6 route
ping -6 -c 3 2606:4700:4700::1111If you see a global address and the ping works, skip to the firewall step.
Ubuntu: add IPv6 with Netplan
Add the IPv6 address and route next to your IPv4 settings:
network:
version: 2
ethernets:
eth0:
addresses:
- 203.0.113.25/24
- 2001:db8:1234::10/64
routes:
- to: default
via: 203.0.113.1
- to: default
via: 2001:db8:1234::1
nameservers:
addresses: [1.1.1.1, 2606:4700:4700::1111]sudo netplan tryNote: Some providers use the link-local gateway fe80::1. Use whatever gateway your provider lists, and add on-link: true if it is outside your prefix.
AlmaLinux and Rocky: add IPv6 with nmcli
sudo nmcli con mod eth0 ipv6.method manual ipv6.addresses 2001:db8:1234::10/64 ipv6.gateway 2001:db8:1234::1 ipv6.dns "2606:4700:4700::1111"
sudo nmcli con down eth0 && sudo nmcli con up eth0Allow IPv6 in the firewall
Firewalls keep separate IPv6 rules. With UFW, check IPV6=yes in /etc/default/ufw, then reload; the same ufw allow rules then cover both. Details in UFW IPv6 rules. Make sure your services listen on IPv6 too (ss -tlpn should show [::]:443).
Publish AAAA records
Add an AAAA record for the hostname, for example example.com → 2001:db8:1234::10, in your DNS zone. Add a PTR for the IPv6 address too if the server sends email (reverse DNS for email).
Warning: Only add an AAAA record once IPv6 really works. A broken AAAA record makes the site slow or unreachable for IPv6 visitors while it still looks fine for you over IPv4.
Test from outside
dig +short AAAA example.com
curl -6 -sI https://example.com | head -1Troubleshooting
- Address set but no ping: wrong gateway or prefix; check
ip -6 route. - Address disappears after reboot: cloud-init overwrote the config; disable its network config.
- Mail bounces over IPv6: add the IPv6 PTR or make the MTA prefer IPv4.
