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'm trying to use route add to redirect connection attempts for an external IP to an internal IP (the loopback IP, my network adapter's IP, either works). I've tried using the following commands to redirect my IP.

route add my.external.ip.address mask 255.255.255.255 0.0.0.0
route add my.external.ip.address mask 255.255.255.255 0.0.0.0 IF 1

IF 1 is my loopback interface, otherwise the command assumes to use my default network interface. (according to route print -4)

Now, both of these commands say "Ok!" and work just fine. My problem is that if I try to use a program that connects to my.external.ip.address, the destination host is unreachable.

tracert(or ping) my.external.ip.address returns "Destination host unreachable" (if I used IF 1 it returns "general failure"), but if I tracert or ping 127.0.0.1 or 192.168.1.106 both reply just fine.

Am I doing something wrong? Is route add not the right way to do this? Using the command at least redirects the IP to somewhere. It just fails to connect..

I have looked at the very least at 8 pages of super user questions, And loads more pages of google, and I'm still stumped. Any input is appreciated.

share|improve this question
    
Of course the destination host is unreachable -- you've added a route that points in the wrong direction. Your external IP address is on the router, not this machine. How are packets going to reach the router with a route pointing away from the router?! –  David Schwartz Aug 4 '12 at 0:06

1 Answer 1

up vote 2 down vote accepted

Even if you were doing those route add commands right, you'd just be asking your machine to act as the router that can forward stuff to that IP address; you wouldn't be asking it to act as the actual endpoint/owner of that IP address.

The easiest way to do what you want to do would probably just be to use the normal network setup GUI to add that IP address as an extra static IP address on one of your interfaces. Your IP stack will automatically create route table entries for its own addresses. When you set this up, don't add a default gateway/router for that IP address, because you don't want your machine to try to use that as a source IP address for sending traffic out to the Internet.

share|improve this answer
    
I can't upvote because I don't have 15 rep, but thank you! That was very helpful. –  cloud Aug 4 '12 at 1:23
    
@cloud Glad to help. If my suggestion worked, click the check mark next to this answer. It's called "accepting an answer" and it's worth 15 imaginary Internet points. –  Spiff Aug 4 '12 at 2:42
    
Sure thing, Done! :) –  cloud Aug 4 '12 at 16:50

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.