1
24.7 Production Series / Port Forward to 127.0.0.1 works, but not to ::1 [+ workaround]
« on: August 24, 2024, 07:59:08 pm »
I wanted a PF rule so all DNS / NTP traffic on my network not going to my OPNsense would be redirected to localhost (the OPNsense box itself) in order to transparantly redirect this traffic. I have a dual stack (IPv4/IPv6) setup.
Easy enough for IPv4, for example DNS, but same for NTP (but different ports and only UDP).
I have allow rules for DNS / NTP under Firewall-Rules-WhateverInterface
NAT Port Forward:
Works perfectly for IPv4.
For IPv6 however, I would expect that the only things I have to change are:
The 2nd one: TCP/IP: IPv6
The 7th one: Redirect target IP: Single host or Network: ::1
I found out this is not working. Unbound and Chrony, which I use for DNS/NTP, apparently bind on 127.0.0.1, but not on the IPv6 counterpart ::1.
I already found a workaround after too many hours of research and trying:
To make things easier you could also make an alias under Firewall-Aliases to fd08::1/128 or whatever ULA you choose.
All set and done. Posted this for the benefit of the earth but also: I can't handle that I don't understand why it doesn't work with ::1? Or did I accidentally found a bug (probably not)? Maybe someone here could explain that, so I can sleep and give my brain some rest.
Thanks and cheers!
Easy enough for IPv4, for example DNS, but same for NTP (but different ports and only UDP).
I have allow rules for DNS / NTP under Firewall-Rules-WhateverInterface
NAT Port Forward:
- Interface: Interfaces I want
- TCP/IP: IPv4
- Protocol: TCP/UDP
- Destination / Invert: selected
- Destination: Alias of my OpnSense box
- Destination Port Range: DNS-DNS
- Redirect target IP: Single host or Network: 127.0.0.1
- Redirect target Port: DNS
Works perfectly for IPv4.
For IPv6 however, I would expect that the only things I have to change are:
The 2nd one: TCP/IP: IPv6
The 7th one: Redirect target IP: Single host or Network: ::1
I found out this is not working. Unbound and Chrony, which I use for DNS/NTP, apparently bind on 127.0.0.1, but not on the IPv6 counterpart ::1.
I already found a workaround after too many hours of research and trying:
- Under Interfaces-Virtual IP's make a virtual IPv6 ULA on the Loopback interface, for example fd08::1/128.
- Restart Unbound and Chrony (they now bind to fd08::1/128).
- Interface: Interfaces I want
- TCP/IP: IPv6
- Protocol: TCP/UDP
- Destination / Invert: selected
- Destination: Alias of my OpnSense box
- Destination Port Range: DNS-DNS
- Redirect target IP: Single host or Network: fd08::1/128
- Redirect target Port: DNS
To make things easier you could also make an alias under Firewall-Aliases to fd08::1/128 or whatever ULA you choose.
All set and done. Posted this for the benefit of the earth but also: I can't handle that I don't understand why it doesn't work with ::1? Or did I accidentally found a bug (probably not)? Maybe someone here could explain that, so I can sleep and give my brain some rest.
Thanks and cheers!

