How-Tos

How-To: Make Sure Your nftables Firewall Actually Covers IPv6

Leave a comment

After this week’s Netfilter IPv6 flaw, I went back and double-checked something simple on my own Linux servers: does my firewall even apply to IPv6? It’s easy to write a tidy IPv4 ruleset and leave IPv6 wide open. Here’s the quick check.

1. Does the box have IPv6 at all?

ip -6 addr show scope global

If you see a global address, IPv6 traffic can reach this machine, and your firewall needs to cover it.

2. Which table families are you using?

sudo nft list tables

A table ip only filters IPv4. A table ip6 only filters IPv6. A table inet covers both, which is what I use. If you only see ip tables, your IPv6 traffic isn’t being filtered by them.

3. What’s actually listening on IPv6?

sudo ss -tulpn | grep -E '\[::\]|\[[0-9a-f:]+\]'

Anything bound to [::] is reachable over IPv6 if the firewall allows it.

4. A minimal inet ruleset

table inet filter {
  chain input {
    type filter hook input priority 0; policy drop;
    ct state established,related accept
    iif lo accept
    meta l4proto ipv6-icmp accept
    meta l4proto icmp accept
    tcp dport 22 accept
  }
}

Don’t drop all ICMPv6. IPv6 needs it for neighbor discovery and path MTU, so blocking it breaks things in confusing ways. Add your own service ports, then check the syntax before loading with sudo nft -c -f /etc/nftables.conf.

5. Test from outside

From another machine with IPv6, try a port that should be closed: nc -6 -zv -w 3 your-server 8080. It should time out.

Safety notes

Keep a second session or console open when you change firewall rules, so a typo doesn’t lock you out. If a box doesn’t need IPv6, turning it off is fine too, but make that a deliberate choice. Pair this with my nftables SSH rate-limit how-to.

God Bless, and Use the Source!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.