GuidesNetwork and VPNIPv6 on your VPS

Set up and use IPv6 on your VPS (Debian 13)

Check the IPv6 /64 your server comes with, add a second address that survives reboots, lock IPv6 down with nftables and test it, with the pitfalls we hit on a real Debian 13 server.

Tested on Debian 13 (trixie) with ifupdown 0.8.44, cloud-init 25.1.4, nftables 1.1.3 and curl 8.14.1, on a Melonslab server Updated November 27, 2026

Recommended server for this guide

SSD RAID 1 · ECC DDR4 · 10 Gbit

VC-P Alloy · 2 vCPU · 8 GB Memory · 60 GB Storage

Month to month, no lock-in 7-day money-back guarantee

€8.99/mo

Deploy now

Run this guide on Melonslab

We ran every step below on our own server. For this workload we recommend VC-P Alloy at €8.99/mo. Order it, pick Debian 13, and follow the guide.

  1. 1. Order the server. Use the button below to order the recommended plan. Choose Debian 13 when the installer asks for an operating system.
  2. 2. Add IPv4 if needed. Add it on the order form when the guide publishes a service on the internet. It is a paid add-on, not included in the plan.
  3. 3. Connect over SSH. Log in as root with the address and credentials from your order, then run the commands below.
  4. 4. Follow the verified steps. Every command in this guide was run on a Melonslab server before it was published.
Deploy now
On this page

What you will set up

A Melonslab server comes with IPv6 already working. This guide shows you how to read what you were given, add a second address, firewall IPv6 properly and test it. We tested on a fresh Debian 13 server, and this is what it looked like as delivered:

  • Address: one static address, 2a14:1ec7:fa00:37::a/64, on eth0. The server owns the whole /64, 2a14:1ec7:fa00:37::/64.
  • Default route: default via 2a14:1ec7:fa00::1 dev eth0 metric 1024 onlink. The gateway is outside your /64 (it is in 2a14:1ec7:fa00::/64), so the route is marked onlink.
  • Network manager: plain ifupdown, with the config written by cloud-init into /etc/network/interfaces.d/50-cloud-init. There is no netplan, no NetworkManager and no systemd-networkd.
  • No router advertisements: accept_ra and autoconf are 0. The address and gateway come only from the static config, so SLAAC is not used.
  • DNS: the resolver list already includes two IPv6 resolvers.
  • Firewall: none. Debian ships an empty nftables ruleset and the service is disabled.

The examples below use the documentation range 2001:db8:1234:5::/64 with the gateway 2001:db8:1234::1. Replace them with your own values from step 1.

By the end you will have:

  • a second address, ::b, that is still there after a reboot,
  • an nftables firewall with a default-drop policy for IPv4 and IPv6, with SSH and ICMPv6 allowed,
  • tests that show a port is blocked, then open.

Before you start

  • A Melonslab server with Debian 13 and root access.
  • A console or a second way in if you are nervous. All the steps here are done over IPv4 SSH, so a mistake in IPv6 does not lock you out, but a mistake in the firewall can.
  • A device with IPv6 for the outside test. Many home connections and mobile networks have it. ping -6 example.com on the device tells you.

1. Check what you were given

ip -6 addr show dev eth0
ip -6 route
sysctl net.ipv6.conf.eth0.accept_ra
cat /etc/network/interfaces.d/50-cloud-init

The address should have scope global with valid_lft forever. The route table should show your /64 as proto kernel, the link-local fe80::/64, and the default via ... onlink route. In the config file, the IPv6 part looks like this:

iface eth0 inet6 static
    address 2001:db8:1234:5::a/64
    gateway 2001:db8:1234::1

Make sure outbound IPv6 works before you change anything:

ping -6 -c3 2606:4700:4700::1111
ip -6 route get 2606:4700:4700::1111

2. Add a second address that survives reboots

A second address is useful when you want one address per service, or a stable address for a reverse DNS name. Any address inside your /64 is yours to use.

First stop cloud-init from rewriting the network config. The header of the file tells you how:

echo 'network: {config: disabled}' > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
cp /etc/network/interfaces.d/50-cloud-init /root/50-cloud-init.orig

Then add two lines at the end of the iface eth0 inet6 static block, which is the last block in the file:

cat >> /etc/network/interfaces.d/50-cloud-init <<'EOF'
    post-up ip -6 addr add 2001:db8:1234:5::b/64 dev eth0 || true
    pre-down ip -6 addr del 2001:db8:1234:5::b/64 dev eth0 || true
EOF

The || true stops a failed address add from marking the whole interface as failed.

Add the address to the running system now, so you do not have to bring the interface down and up:

ip -6 addr add 2001:db8:1234:5::b/64 dev eth0

Do not run ifdown on eth0 or an alias over SSH. In our test, taking down an interface alias with ifdown cut the server off the network and we had to redeploy it. Use ip addr add for the live change and a reboot to prove the file works.

Reboot and check:

reboot

After you log in again:

ip -6 addr show dev eth0
ping -6 -c2 -I 2001:db8:1234:5::b 2606:4700:4700::1111

Both addresses should be there with preferred_lft forever, and the ping from ::b should work.

3. Add an IPv6 firewall

A fresh Debian has no firewall, so every port an app opens is open to the whole IPv6 internet too. Do not count on nobody finding your address.

The inet table in nftables covers IPv4 and IPv6 with the same rules. Write /etc/nftables.conf:

cat > /etc/nftables.conf <<'EOF'
#!/usr/sbin/nft -f
flush ruleset

table inet filter {
    chain input {
        type filter hook input priority filter; policy drop;
        ct state established,related accept
        ct state invalid drop
        iif lo accept
        meta l4proto icmp accept
        meta l4proto ipv6-icmp accept
        tcp dport 22 accept
    }
    chain forward {
        type filter hook forward priority filter; policy drop;
    }
    chain output {
        type filter hook output priority filter;
    }
}
EOF
nft -c -f /etc/nftables.conf && echo syntax-ok

ipv6-icmp must stay allowed. IPv6 uses ICMPv6 to find the gateway's hardware address (neighbour discovery). In our test, removing that one rule left the gateway entry INCOMPLETE and stopped all outbound IPv6 until we put the rule back.

To avoid locking yourself out, schedule a flush of the ruleset a few minutes ahead, load the rules, check that SSH still works from a second terminal, then cancel the timer:

systemd-run --quiet --unit=fw-failsafe --on-active=180 nft flush ruleset
nft -f /etc/nftables.conf
# open a second SSH session now and check it works, then:
systemctl stop fw-failsafe.timer
systemctl enable --now nftables

To open a port permanently, add a line to the input chain in /etc/nftables.conf, for example tcp dport 443 accept, and run systemctl restart nftables. A rule added only with nft add rule is lost on restart, which is handy for tests.

4. Test it

From the server

ping -6 -c2 2606:4700:4700::1111
curl -6 -s https://ifconfig.co
dig +short AAAA example.com @2606:4700:4700::1111
ip -6 route get 2606:4700:4700::1111

curl -6 prints the address the server used. These tools are not in a fresh Debian: apt install curl netcat-openbsd bind9-dnsutils gives you curl, nc and dig.

From a client

Replace 2001:db8:1234:5::a with your server's address. On the server, start a listener on port 8080, which the firewall does not allow yet:

nc -6 -l 8080

From a device with IPv6, the connection should time out:

nc -6 -zv -w3 2001:db8:1234:5::a 8080

Open the port on the server and try again. This time it should say succeeded:

nft add rule inet filter input tcp dport 8080 accept

Also check that ping and SSH still work from the client:

ping -6 -c2 2001:db8:1234:5::a
nc -6 -zv -w3 2001:db8:1234:5::a 22

Verify

ip -6 addr show dev eth0 | grep 'inet6 2'
ip -6 route show default
systemctl is-active nftables
nft list chain inet filter input

You should see both addresses, the default route via your gateway, active, and a chain with policy drop. After a reboot all four should look the same.

Pitfalls we ran into

  • The new address is deprecated. If you add it with an ifupdown alias (iface eth0:1 inet6 static), ifupdown adds it with preferred_lft 0. The address works for incoming traffic, but is not used for outgoing connections, and setting preferred-lifetime did not change it for us. Use the post-up line from step 2 instead.
  • Outbound traffic leaves from the newest address. With ::a and ::b on the same /64, curl -6 https://ifconfig.co returned ::b, and ip -6 route get showed src ...::b. If the first address has reverse DNS or is allowlisted elsewhere, pick the source on purpose: curl -6 --interface 2001:db8:1234:5::a https://ifconfig.co.
  • The first ping packet is lost. A new neighbour needs a moment for neighbour discovery. One lost packet at the start is normal.
  • Router advertisements are off. accept_ra = 0 is how these servers are delivered. Do not turn on SLAAC on eth0, because it can add extra addresses and a second default route.
  • The gateway is not in your /64. If you write your own route, use onlink, as in the delivered default via ... dev eth0 onlink.
  • Forwarding is off (net.ipv6.conf.all.forwarding = 0). Turn it on only if the server routes traffic for others, for example a VPN.

What we could not check

We ran the client tests from a network namespace on the server, not from a device on another network, so we have not shown routing from the public internet to the new address. Test from your own IPv6 device as in step 4.

Cleanup

To go back to the delivered state:

systemctl disable --now nftables
nft flush ruleset
rm /etc/nftables.conf
cp /root/50-cloud-init.orig /etc/network/interfaces.d/50-cloud-init
rm /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
ip -6 addr del 2001:db8:1234:5::b/64 dev eth0

Run it on your own server

SSD RAID 1 · ECC DDR4 · 10 Gbit

VC-P Alloy

€8.99/mo

vCPU
2
Memory
8 GB
Storage
60 GB
Transfer
10 TB
Performance
SSD · RAID 1
  • Full root access
  • Native /64 IPv6
  • RAID-protected storage
  • Malmö, Sweden
  • Month to month, no lock-in
  • 7-day money-back guarantee
All guides