Linux VPS

Set up IPv6 on a Linux VPS and test it

Add the IPv6 address and gateway from your provider with Netplan or nmcli, open the firewall, publish AAAA records and confirm IPv6 works end to end.

IntermediateLinux VPS (Ubuntu · Debian · AlmaLinux · Rocky)2 min read

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

Check whether IPv6 already works

ip -6 addr show scope global
ip -6 route
ping -6 -c 3 2606:4700:4700::1111

If 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 try

Note: 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 eth0

Allow 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 -1

Troubleshooting

  • 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.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.