Tech Support Forum banner
Status
Not open for further replies.

Adding route with variable subnet mask in windows xp

20K views 6 replies 3 participants last post by  TheOutcaste 
#1 ·
Hi,

In XP, I am trying to add a static route for a network with subnet mask. I tried issuing the command,

C:\>route add 172.16.10.0 MASK 255.255.252.0 172.16.20.1

I get the error:
-------------------
The route addition failed: The specified mask parameter is invalid. (Destination & Mask) != Destination.
-------------------

I found that, when I give varyable subnet mask, the error is thrown. Can someone tell me if there is any other way of giving the variable subnet mask.

Thanks in advance.
uv
 
#2 ·
I'm not sure what you mean by "variable subnet mask" in your subject line. Static routes are just that, static.

The command is failing because you’re using the wrong subnet ID. What you want is this:

route ADD 172.16.8.0 MASK 255.255.252.0 172.16.20.1

That will route addresses 172.16.8.1 - 172.16.11.254 to 172.16.20.1. Also, you will need to use the –p option to make the route persistent. Otherwise the route will only exist until you reboot the computer. That would be:

route –p ADD 172.16.8.0 MASK 255.255.252.0 172.16.20.1

I hope this helps,

Dave
 
#3 · (Edited)
That won't work either, the gateway has to be in the same subnet as the network you are trying to route.
EDIT: That should read, "That might not work, the gateway has to be on the same network as the Ethernet interface, so your Ethernet interface has to be part of the network that includes the 176.16.20.1 address for XP to accept the route addition"

Network starting addresses for various subnet masks 255.255.Y.0
The first address in the subnet will be 172.16.X.0 where X is:
Code:
Y=254 X is a multiple of   2: 0,   2,   4,   6,   8...
Y=252 X is a multiple of   4: 0,   4,   8,  12,  16...
Y=248 X is a multiple of   8: 0,   8,  16,  24,  32...
Y=240 X is a multiple of  16: 0,  16,  32,  48.  64...
Y=224 X is a multiple of  32: 0,  32,  64, 128, 160...
Y=192 X is a multiple of  64: 0,  64, 128, 192 
Y=128 X is a multiple of 128: 0, 128
 
#5 ·
You are right, it will work if you are part of that network. I should have said the Gateway must be on the same network as the interface, at least for XP.
If not, you get this error:
Code:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>route ADD 172.16.0.0 MASK 255.255.240.0 10.1.1.1
The route addition failed: Either the interface index is wrong or the gateway do
es not lie on the same network as the interface. Check the IP Address Table for
the machine.


C:\>
The key phrase here is:
the gateway does not lie on the same network as the interface.
On that system, the interface is 192.168.1.232, so it only allows gateways in the 192.168.1.x network.

On Win 7 it does work, as Win 7 is smart enough to route it out the interface with the 0.0.0.0 route, or the All Others route.

Thanks for the correction.
 
#6 ·
Thanks a lot for the replies:

I will try to give exact situation I am in.

Actually I have interface IP address as

172.16.20.120 mask 255.255.252.0

I am able to ping 172.16.20.1

I need route of 172.16.10.0 with mask 255.255.252.0 to be destined to 172.16.20.1.

I cannot add default gateway as 172.16.20.1, because I have one more interface connected to internet.

My OS is XP.

--uv
 
#7 ·
See the table in post #3. With a mask of 255.255.255.252, the network address has to be a multiple of 4, so 172.16.10.X would be part of the 172.16.8.0-172.16.11.255 network. You'd need to add this route with this command as dmdombroski stated:
route -P ADD 172.16.8.0 MASK 255.255.252.0 172.16.20.1
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top