Solved Update IPv6 routes on a gateway from upstream router advertisements?

I'm running an AP that bridges traffic to my ISP. For various reasons, I'm running both IPv4 and IPv6 and I need to NAT traffic from the LAN to the ISP. For this reason, net.inet6.ip6.forwarding needs to be enabled.

The usual solution for periodically updating the IPv6 gateway address seems to be rtsold(8), but it also seems to be common knowledge that it does nothing when net.inet6.ip6.forwarding is enabled. I can confirm this by just toggling net.inet6.ip6.forwarding: With it enabled I get NAT, with it disabled my default route gets a gateway address.

After looking at the source for rtsold(8), I don't see any logic that actually changes routes. Instead, it seems like it just solicits an advertisement, and the kernel (or something else) updates the routes. (I had hoped that I could just hack rtsold(8) to make it ignore net.inet6.ip6.forwarding.)

In any case, it's been quite problematic to dynamically update the IPv6 gateway for my ISP. I ended up modifying rtsol.c so that it passes the sender's address to the -M script as an extra argument, and then I have a script that calls route -6 change default $addr to set the gateway. I also tried route6d(8), but it was hard to tell if my config was bad or if it's also the wrong tool.

The hacked rtsold(8) is fine for now, but I really don't like running hacked base binaries. Is there a better way to go about this?
 
You probably need to set ipv6_cpe_wanif to the interface connected to your ISP in your rc.conf(5) file.

Code:
     ipv6_cpe_wanif
                 (str) If the variable is set to an interface name, the
                 ifconfig(8) options “inet6 -no_radr accept_rtadv” will be
                 added to the specified interface automatically before
                 evaluating ifconfig_⟨interface⟩_ipv6, and two sysctl(8)
                 variables net.inet6.ip6.rfc6204w3 and net.inet6.ip6.no_radr
                 will be set to 1.

                 This means the specified interface will accept ICMPv6 Router
                 Advertisement messages on that link and add the discovered
                 routers into the Default Router List.  While the other
                 interfaces can still accept RA messages if the “inet6
                 accept_rtadv” option is specified, adding routes into the
                 Default Router List will be disabled by “inet6 no_radr”
                 option by default.  See ifconfig(8) for more details.

                 Note that ICMPv6 Router Advertisement messages will be
                 accepted even when net.inet6.ip6.forwarding is 1 (packet
                 forwarding is enabled) when net.inet6.ip6.rfc6204w3 is set to
                 1.

                 Default is “NO”.
 
Thanks! That works perfectly.

I don't know how I missed net.inet6.ip6.rfc6204w3. I guess it just looked obscure when I was skimming through net.inet6.
 
Back
Top