Today I discovered a strange issue with NAT on my router running FreeBSD 10.3-RELEASE-p7, and after hours of fiddling, I'm still not sure what to make of it...
The machine connects my internal LAN and wireless LAN to the internet by means of user-ppp over an ADSL line, so my etxernal interface for all intents and purposes is tun0. IP address assignment is done dynamically through PPP, so the external address changes every once in a while. I have confirmed that the
In my /etc/pf.conf is a NAT rule quite similar to many examples:
Which appears as follows after loading the ruleset (notice the 'round-robin' automatically added):
Now what seems to be happening is that some packets (mostly UDP from what I can tell) have their source address translated to an IP address I had almost 20hrs ago. And I really have no idea where this old expired address is coming from.
If I remove the braces around the interface name in the NAT rule like so:
then the problem seems to be gone (as is the implicit 'round-robin'). This would of course cease to work when the IP address on the interface changes the next time. A better solution seems to be this:
But that still does not explain where this expired IP address is still coming from and why it is not displayed in the output of
The machine connects my internal LAN and wireless LAN to the internet by means of user-ppp over an ADSL line, so my etxernal interface for all intents and purposes is tun0. IP address assignment is done dynamically through PPP, so the external address changes every once in a while. I have confirmed that the
iface-alias
option in PPP is disabled and also ifconfig -v tun0
does not show any alias addresses on the interface:
Code:
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1492
options=80000<LINKSTATE>
inet 77.180.129.49 --> 62.52.201.187 netmask 0xffffffff
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
groups: tun
Opened by PID 575
Code:
ExtIF = "tun0"
[...]
nat on $ExtIF inet from 10.6.0.0/16 -> ($ExtIF)
Code:
nat on tun0 inet from 10.6.0.0/16 to any -> (tun0) round-robin
If I remove the braces around the interface name in the NAT rule like so:
Code:
nat on $ExtIF inet from 10.6.0.0/16 -> $ExtIF
Code:
nat on $ExtIF inet from 10.6.0.0/16 -> ($ExtIF:0)
ifconfig -v tun0
. This old address just shouln't be around anymore anywhere.