Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I define a static route, why I have to define a subnet mask for the destination network? What would happen, when I have more than one gateway an the subnet masks of all destination networks are

share|improve this question

closed as off topic by pauska, Magellan, John Gardeniers, mulaz, MadHatter Oct 15 '12 at 14:09

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Very Easy Answer. Go study subnetting and routing. This is 101 stuff and homework is off-topic for ServerFault. – Magellan Oct 13 '12 at 15:32
Sometimes it helps to be pointed in the right direction, subnetting is a complex area to cover even for people who've 'done networking' for a long time. I still refer to cheatsheets... and occasionally have to go read serverfault. ;-) – Christopher Woods Nov 5 '13 at 17:56
up vote 5 down vote accepted

Because the destination network address by itself doesn't give a range of network addresses, however when coupled with a netmask, the full scope of the remote network is defined.

For example, say you were using a host on the network and had a route defined as follows

route add mask

The above rule, tells your computer that any host on the network ( - is accessible via the router

Specifying a destination without a subnet mask doesn't make sense, even in the event of a single host, which would be defined as

route add mask

If you have conflicting routes using a netmask of, then route with the lowest metric value would normally take precedence, for example

route add mask metric 10
route add mask metric 5 would be the preferred route, assuming no other matching routes exist with a lower metric

share|improve this answer

subnet mask serves to tell your router/OS what exactly is the network portion of your address.

Let's say you have if you would have no network mask (this is called classful routing) if it's pressumed that it is network because it belongs to Class A (some devices/OS give it the subnet defined on their interface). See here about classful and classless routing

These are the classes:

Class A
1.  0.  0.  1 = 00000000.00000000.00000000.00000000 = 01111111.11111111.11111111.11111111

Class B
128.  1.  0.  1= 10000000.00000000.00000000.00000000 = 10111111.11111111.11111111.11111111

Class C
192.  0.  1.  1 = 11000000.00000000.00000000.00000000 = 11011111.11111111.11111111.11111111

Class D
224.  0.  0.  0 = 11100000.00000000.00000000.00000000 = 11101111.11111111.11111111.11111111

Class E
240.  0.  0.  0 = 11110000.00000000.00000000.00000000 = 11111111.11111111.11111111.11111111

But if you put subnet mask then you can split that network into more networks like or

The subnet mask is required because when you define static address (let's say in windows, it doesn't use calssful routing but classless, which has to have the subnet mask to).

If you put subnet mask of that means that only the first part of the address is the network address so your network is x.0.0.0, if you would put then it takes the first two part of the address like x.x.0.0, and so on. So when you put subnet mask it means any address from to

If you have more than one route for same destination the route with lower metric will win.

About having subnet mask of your destinations set to in most devices/OS I don't think it is possible to put subnet mask if the address is not That is they don't allow to put 1 bit value in destination address of static route if the corresponding value in subnet mask is 0.

Windows for instance won't let you make this

route add mask

because you specified subnet mask of which is in binary form 11111111.00000000.00000000.00000000 and the destination address which is in binary form 00001010.00001010.00001010.00000000. It has 1 in the place where subnet mask has 0 (second and third portion of address)

share|improve this answer
I work with programmable control station. When I want to communicate with another station in another subnet, I can only define a destination network and a gateway but no subnet mask. So I think the subnet mask is always set to Commonly the destination network is set to and only the gateway is defined. What now can happen is, that there are two gateways but both of this static routes has for destination network This still works. But I can't exactly say why it works? – reneton Sep 29 '12 at 9:29
are you sure it defines the subnet mask, maybe if doesn't use subnet mask (classful routing) or it puts default subnet mask for that network class. Do you have some sort of routing table that you could paste in your question, something like the route print command on windows, if you have multiple routes for same destination then the one with lower metric or cost or hops (whatever your station has defined in routing table) would win – rAlen Sep 29 '12 at 9:37
I don't know if the subnet mask is defined by the network class, I assume not. I configure the station with a GUI, in this GUI I can only define destination and gateway. When I look at the routing table on the station, I can't see a subnet mask for the destination network. – reneton Sep 29 '12 at 10:00

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