Iptables – DNAT on the POSTROUTING chain

firewalliptables

What happens if I try to do a DNAT in the POSTROUTING chain of the NAT table in iptables?

Suppose I change the destination IP of the packet in the POSTROUTING chain to an address that should get routed via a different interface. What would happen to the packet?

  1. Would the host be able to route the packet to the correct interface even after all the routing decisions have been made.

  2. Or would the packet still be sent via the interface which was decided in the routing decisions before.

Best Answer

Both options are incorrect. The right answer is :

  1. An error will occur.

Because DNAT can only be used in PREROUTING or OUTPUT chains.

Related Topic