Why does this ROUTE ADD command fail?

I am trying to block access to a single IP address by adding a specific route that leads "nowhere" (instead of the default gateway):

route ADD 199.239.136.200 MASK 255.255.255.255 127.0.0.1 METRIC 10

The problem is that this command fails with the following error:

The route addition failed: The parameter is incorrect.

It doesn't say which parameter is incorrect. I probably violated an implied rule of networking basics but I don't know what it is. Any idea which parameter is incorrect and, more importantly, why?

Thanks.

3 Answers

You cannot have the loopback device (127.0.0.1) be the gateway. It doesn't make sense.

What you are saying with this command is "route all traffic that goes to this address(es) through this gateway". Because loopback does not route to any network, it does not work.

Find out which gateway you want this traffic to go through and use that instead. In a comment you mentioned using your own IP address. That might work because your IP would just fail routing the traffic. I have not tested this so ymmv:

route ADD 199.239.136.200 MASK 255.255.255.255 <OWN_IP> METRIC 10

Might be worth for you to check out Wikipedia's article on loopback for more information. Also, check out this superuser question for information on the gateway's role in routing.

3

You're trying to add your own device as the gateway, for every port on your computer I can come up with a reason to do this. The issues, is that windows will not let you set 127.0.0.1 as the gateway. This might be due to the fact that it is not defined by windows ipconfig. So, instead of using 127.0.0.1 as the gateway, Windows has re-defined it as "On-Link" :

Destination Netmask Gateway Interface Metric
127.0.0.0 255.0.0.0 On-link 10.10.2.210 11

To set an On-Link gateway you have to specify it as 0.0.0.0 . My guess is that Microsoft knew that this gateway is impossible, so they internally defined it as the local address gateway.

To set this simply use:

C:\Windows\system32>route add 127.0.0.0 mask 255.0.0.0 0.0.0.0 OK!
C:\Windows\system32>route add 127.0.0.1 mask 255.255.255.255 0.0.0.0 OK!

Make sure you specify your own metric and interface as Windows might not pick the one you intended on using.

With the subnet mask set to 255.255.255.255 you are masking every single bit of the address, that sounds like an issue to me

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like