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
route add my.external.ip.address mask 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 or 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.

  • 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

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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