Taylor, Grant gtaylor at
Thu Apr 28 05:30:55 CEST 2005

> Hi,
> i have a special situation.
> (INTERNET) =====|firewall| =====|server|
> I want to DNAT a port of my firewall on a server inside:
> $IPTABLES -t nat -A PREROUTING -i eth0 -d -p tcp --dport 200 -j DNAT
> - --to-destination
> but the server inside only accept packets from the IP of the inside interface of the firewall :
> so i need that the source IP address of the packet sent by someone(x.x.x.x) on the internet
> change in
> I try the SNAT, the MASQUERADE:
> $IPTABLES -t nat -A POSTROUTING -o eth1 -s x.x.x.x -p tcp --dport 20000 -j SNAT --to
> or
> $IPTABLES -t nat -A POSTROUTING -o eth1 -s x.x.x.x -j MASQUERADE
> it don't work.

You are DNATing to the destination port of 200 where as you are later looking for traffic headed to 20000 and thus will never match the traffic that you DNATed.

Another point (IMHO) that you might want to consider is that if you have any client systems on the inside of the firewall that will be trying to connect to the x.x.x.x server they will never get return traffic as it will be SNATed to the firewalls internal IP.  I would recommend that you add an additional "-d" match to your rule to make sure that you don't erroneously SNAT traffic that should be going else where.

Grant. . . .

More information about the netfilter mailing list