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'm trying to do a simple redirect with IP tables. Basically what I want to do is make it so when I try to wget or curl something from the IP address of it will redirect me to

We recently switched around the IP address in our infrastructure so that they are all sequential but some of our server admins are having trouble remembering to type the new IP.

share|improve this question
DNS is the way forward. – Iain May 15 '11 at 23:07
up vote 0 down vote accepted

As Iain points out this looks like a job for DNS.

The iptables solution will probably be something like this, if you want to stick to it:

iptables -t nat -I PREROUTING -d -p tcp --dport 80 -j DNAT --to
iptables -t nat -I POSTROUTING -d -j SNAT --to

The first rule does the actual redirect, the second one masks the source IP address so returns the packets to and the connection thus actually works. Do note that all packets will go through at all times - it's a low level (TCP) redirect.

A nicer way to do this would be to set up a web server on to force an HTTP redirect to This is probably much better because it doesn't mask the redirect and the users may become (probably slowly) aware of it. Also, you only have to process the initial connection on - the rest goes directly to

About the IPs - you aren't using as a private network, right? It isn't private.

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.