Bug #4639


NAT fails to correctly translate udp port numbers embedded in certain ICMP error packets

Added by Daniel Haid about 9 years ago. Updated almost 8 years ago.

Operating System
Target version:
Start date:
Due date:
% Done:


Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
Affected Architecture:


I think I found a bug in the NAT of the packet filter, but I am not sure. My
setup is as follows.

client (linux) | | bridge0, mtu=1500 |
pfsense 2.2.2 (FreeBSD 10.1-RELEASE-p9) | | pppoe0, mtu=1492 |

On the client, I run the following command:

  1. nping --udp -g 10000 -p 20000 --data-length 1472 --df

This generates five UDP packets of IP length 1500, set the do not fragment
option, and send them from source port 10000 to destination port 20000. I have
verified by packet capture that this really happens.

As the mtu of the pppoe link is 1492, the packets cannot reach their
destination, so pfsense generates "ICMP fragmentation needed" error packets. I
expect five such packets, and I indeed receive five, but the first one (!)
seems to be corrupted, as I will now explain.

I run the following command (with following output) on pfsense:

  1. pfctl s state | grep 10000
    bridge0 udp < NO_TRAFFIC:SINGLE
    pppoe0 udp ( -> SINGLE:NO_TRAFFIC

Each of the five ICMP packets should have embedded the header of the respective
offending 1500-byte packet. The NAT should appropriately map the port numbers.
However, the first packet receieved from the client has source port 59518
(the untranslated one) in the UDP header embedded in the ICMP packet.
The other four ICMP packets are fine (source port 10000, which is the correct,
translated, value).

Note that this only happens for ICMP error packets originating at the pfsense
router itself. ICMP error packets of the same type but from a router in the
public internet are always translated correctly (all five!) before being
forwarded to the client.


Also available in: Atom PDF