Need help setting up IPv6 SNAT rule with nftables

I’m stuck trying to configure an SNAT rule for IPv6 on my router using nftables. I want all outgoing traffic through the enp1s0 interface to be SNATted with a specific IPv6 address. Here’s what I’ve tried:

nft add rule inet nat postrouting oifname "enp1s0" snat ip6 to 2a01:4f8:c17:b8f::1/64

But I get an error saying “No such file or directory”. I also tried:

nft add rule nat postrouting oifname "enp1s0" snat to 2a01:4f8:c17:b8f::1

This time, the error was “Address family for hostname not supported”. Lastly, I attempted:

nft add rule nat postrouting ip6 oifname enp1s0 snat to 2a01:4f8:c17:b8f::1

But got a syntax error. I’m not sure what I’m doing wrong. Can someone please help me figure out the correct syntax for this IPv6 SNAT rule? Thanks!

hmm interesting problem! :thinking: i’ve been playing around with nftables recently too and ipv6 can be tricky. have you considered using masquerade instead of snat? it might be easier to set up. something like:

nft add rule ip6 nat postrouting oifname “enp1s0” masquerade

this would dynamically use the ipv6 address of your enp1s0 interface. if you really need that specific ipv6 address tho, maybe try breaking it down into smaller steps? like first add the table, then the chain, then the rule. curious to hear if any of this helps or if you’ve found another solution!

hey there! have u tried using the ip6 family explicitly? maybe somethin like this:

nft add rule ip6 nat postrouting oifname “enp1s0” snat to 2a01:4f8:c17:b8f::1

make sure u have the ip6 nat table set up first tho. hope this helps!