need help using ng_patch to modify src/dst packets or alternative way

Eugene Grosbein eugen at grosbein.net
Sun Dec 17 18:42:49 UTC 2017


17.12.2017 17:59, Sami Halabi wrote:

> Hi Eugene,
> I'm looking for a solution for IP traffic. in linux iptables its possible but I couldn't find freebsd way yet.
> bkuncr soulution works for tcp only.

Then, you need to realize that for every packet, you need to change (translate)
both of source IP address from 10.1.1.2 to 1.1.1.1 and destination IP address
from 10.1.1.1 to X.X.X.X. This is called network address translation and,
in fact, you need NAT. But not ordinary "simple" NAT that translates
only source address in outgoing packets (and destination in incoming replies)
but double or "binat" to translate destination address in outgoing packets too
(and source address in corresponding replies).

This is possible to do with two instances of "ipfw nat" (or natd) for single external destination
but not for arbitrary number of external destinations.

They say, "pf(4)" packet filter can perform "binat" properly.
I have not tried that. You should start reading its documentation.


More information about the freebsd-current mailing list