Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 1.1.1.1 but linux gateway change it to 2.2.2.2
So if I'm expecting the web page of 1.1.1.1, I'll get the changed one, the one of 2.2.2.2
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 stackoverflow.com 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 1.1.1.1 -j DNAT --to 2.2.2.2 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
add comment

1 Answer

Maybe you can use the etc/hosts (http://en.wikipedia.org/wiki/Hosts_%28file%29) in Win XP? You can add a line like this one : "www.google.com www.facebook.com" in your host file to redirect request to www.facebook.com to www.google.com (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
add comment

Your Answer

 
discard

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.