Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How to change destination IP address after routing decision was made, i.e. in POSTROUTING chain of iptables?

share|improve this question
    
Can you tell us why you would even want to? –  Zoredache Mar 24 '10 at 17:38
    
Are you trying to do NAT? en.wikipedia.org/wiki/Network_address_translation –  einstiien Mar 24 '10 at 17:42

2 Answers 2

e... as the name suggests - it is a bit too late to do it in the POSTROUTING table.

this and this are quite helpful to see what/when happens. if you really have to dst address rewrite - maybe put another machine in the line [ virtual ? ] or even better - rethink why would you want to do that.

share|improve this answer

If you really want to change the destination in POSTROUTING, perhaps you can try abusing the NETMAP target? I'm not sure if it works, but try something like:

iptables -t nat -A POSTROUTING -d 1.2.2.2/32 -j NETMAP --to=1.3.3.3/32
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.