Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 linux machine used as gateway for a Win XP machine. Both are in Virtual machine for testing purpose. Now I want to trick the Win XP user (me) with the forwarding of an IP address: I want to change the destination IP address.

For example I want to go to but linux gateway change it to
So if I'm expecting the web page of, I'll get the changed one, the one of
For example I want to go to Facebook and I'm forced to Google home page.

How can I do it? With prerouting?
Because I've done lot of tries, but no one working :(

share|improve this question

migrated from Apr 28 '11 at 11:00

This question came from our site for professional and enthusiast programmers.

Obviously this is not a programming question, so voting to close. – unwind Apr 28 '11 at 10:15
Maybe don't close it but transfer it to serverfault – Dynamicbyte Apr 28 '11 at 10:19
Should be on superuser/serverfault. Either way, -t nat -A PREROUTING -d -j DNAT --to should do it. You'll need a POSTROUTING SNAT as well so the response returns through the gateway - if it's a NAT'ing gateway I presume you already have that – Erik Apr 28 '11 at 10:24
Thanks Erik, I did that way, with that rule of PREROUTING and as POSTROUTING I have: -t nat -A POSTROUTING -o eth0 -j MASQUERADE, and tried lot of other configuration. Still not working. Any ideas? – Possa Apr 28 '11 at 12:16

Maybe you can use the etc/hosts ( in Win XP? You can add a line like this one : "" in your host file to redirect request to to (you should also add a line without the www). You can try the same thing on the linux (I don't think it'll work).

The best would be that your linux serves DNS for you, so you can configure your DNS software for that purpose.

share|improve this answer
/etc/hosts only maps names to IP addresses. You cannot map a name to another name this way. – grawity Apr 28 '11 at 13:08

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.