0

the question is simple when i set a static route for an ip address why does these commands work

route -p ADD 65.182.174.0 MASK 255.255.255.0 192.168.1.1

route -p ADD 65.182.174.11 MASK 255.255.255.255 192.168.1.1

and this command doesn't work

route -p ADD 65.182.174.11 MASK 255.255.255.0 192.168.1.1

i don't understand the subnet mask that much ... but what i understood was "A subnet mask is used to divide an IP address into two parts. One part identifies the host (computer), the other part identifies the network to which it belongs"

so what am i missing here ?

3
  • Your Router is for one IP address. 255.255.255.255.0 is for a whole subnet. 255.255.255.255.255 is for that one single IP address. – John Jan 15 '20 at 13:16
  • Got it Thanks for your answer – Julia Adams Jan 15 '20 at 14:24
  • You might want to also look up CIDR – Smock Jan 15 '20 at 14:32
0

When configuring routes, the mask is used to determine which address bits to compare when the system checks which routes match a given address. (Note that the route netmask isn't always the same as the destination's subnet mask – it's about which addresses you want to include in the route, so it could specify a single host, half a subnet, 16 subnets at once, etc.)

For example, when you use 65.182.174.0 mask 255.255.255.0, that actually means you want the route to match 65.182.174.<any> – because the netmask only has first 24 bits set to '1', it means only the first 24 address bits are compared and the rest is ignored.

So in theory, the system could accept 65.182.174.11 mask 255.255.255.0 and it would still mean exactly the same thing: the .11 would be ignored and only 65.182.174. would be used for route matching.

Rejecting such entries is usually deliberate, since it can catch certain mistakes – e.g. in this example, the operator could have mistyped the netmask (entering .0 when they meant .255) and accidentally routed a whole subnet when they just wanted to route a single host. So many systems insist that the network address must have all 'host' bits set to 0 because it more accurately specifies what you want to route.

1
  • Thanks! this helped alot :) – Julia Adams Jan 15 '20 at 14:23

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.