Linux HOWTO: NetMasks Explained

Posted on April 12, 2007 in How-to

If youre not familiar with the /-notation used for network addresses, it works like this.

Every machine needs an individual address. To keep things simple, we assign them in clumps; each network of machines generally gets a range of addresses.

A single IP address is 32 bits long: printed in binary has 32 binary digits, each 1 or 0. Its standard to print them as 4 decimal numbers, each representing 8 bits, such as ` In binary, this would be `11000000101010000000000100000001.

To talk about a network of machines, we simply decide which bits of the address indicate the network: if two IP addresses have these bits the same, then they are on the same network.

The simplest way of representing this is the `/n notation, such as ` The `/24 means that the first 24 bits of this address are important: remembering that each number represents 8 bits, this means that any IP address starting with `192.168.1. is on this network. As another example, ` means that any IP address starting with `10. is on the network.

The second part usually called the netmask doesnt have to be a multiple of eight, but it often is, to make it easier to instantly recognise related IP addresses.

There is another way to write the netmask, and that is to spell it out in IP-address form, such as ` In binary, 255 is `11111111, so is `11111111111111111111111100000000. Each 1 in this netmask indicates that the corresponding part in the IP address is important: this means that the first 24 bits are important, so ` is equivalent to ``

Here is a table of common addresses you will see:

Decimal Range Use Common in masqueraded networks RFC 1918: private network addrs RFC 1918: private network addrs RFC 1918: private network addrs

This can be quite confusing, but youll see the same notation and the same numbers popping up over and over again, so I recommend you read the above paragraphs a couple of times.