Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a ubuntu box behind NAT, with a static ip, and I want to redirect any connections coming from my machine to my public ip to redirect back to localhost (my machine).

How can I set up packet routing, so that all traffic from localhost to my external ip is routed back to localhost? (transparent for any application)

share|improve this question
up vote 0 down vote accepted

My iptables is a little rusty, so I'm not 100% sure this will work. You could try this:

iptables -t nat -A PREROUTING  -p tcp -d <public ip> -j DNAT --to
share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.