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 using two network connections, and I tried using the "route" command so that when I access a specific internal IP on my LAN, it would use connection 1, anything else would go normally through connection 2 (which doesn't have access to my LAN).

The problem is I have a bunch of internal IP's that I need to access, and the "route" command doesn't seem to allow me to add an IP range instead of specific IP. And connection 1 doesn't have internet access, so I can't use it as my default connection.

Any idea how this can be solved?

Your help is appreciated

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

The route command is all about routing ranges of IP. The key to doing ranges is using the netmask portion of the route command.

Basic IP networking lesson

An IP address is a 32 bit number represent and address on the internet. Taken in binary the IP address 10.0.0.1 would look like this:

10      .0       .0      .1
00001010 00000000 0000000 00000001

The netmask specifies which portion of the address is the fixed part of the range by specifying a binary 1, and the variable portion of the range is a 0. So, a netmask of 255.255.255.255 represents all bits are fixed and therefore will only route the give IP. A netmask of 0.0.0.0 means all bits are variable, or in other words this matches every IP address. 0.0.0.0 is used for the default route. So, if you want to specify a range, you just need to specify the bits in the netmask you want to match.

If you wanted a route to apply to all the addresses from 10.0.0.0 to 10.0.0.255 your route command would look like

          Dest Ip       Netmask       Gateway
route ADD 10.0.0.0 MASK 255.255.255.0 10.0.0.1

If you wanted a route to apply to only 10.0.0.100 and 10.0.0.103 your command would look lik route ADD 10.0.0.100 MASK 255.255.255.252 10.0.0.1

And if you wanted a route to apply to all addresses 10.0.0.0 to 10.255.255.255 your route would look like

route ADD 10.0.0.0 MASK 255.0.0.0 10.0.0.1

You can also specify in the route command the interface it should use using the IF paramter:

route ADD 10.0.0.0 MASK 255.0.0.0 10.0.0.1 IF 2
share|improve this answer
    
Man this was EXTREMELY helpful. Thank you very very much! :D –  KeyStroke Mar 21 '10 at 11:01
add comment

As you are using Windows 7, execute cmd.exe as an administrator by going to the Start Menu, typing cmd.exe in the search box, right clicking on cmd.exe, and selecting Run as administrator (or pressing Ctrl+Shift+Enter).

You will see a difference from the normal Command Prompt. Within this elevated Command Prompt you can add your static route, i.e.

route add 10.0.0.0 mask 255.0.0.0 192.168.0.1 -p
share|improve this answer
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.