Home > IT Notes

What is the netmask

The netmask is used to identify which portion of the IP address represents the network address and which portion represents the machine address.

At Yarra Valley we have the address block 203.36.211.0 through to 203.36.211.127. In binary the addresses are: 11001011.00100100.11010011.00000000 through to 11001011.00100100.11010011.01111111. The netmask is generated by assigning a 1 for each bit in these addresses that does not change IE:

11001011.00100100.11010011.00000000
11001011.00100100.11010011.01111111
-----------------------------------
11111111.11111111.11111111.10000000

This converts to a decimal netmask of 255.255.255.128. In use, it tells the device applying the netmask that the first 25 bits of the IP address identify the network and the last 7 bits identify the machine.

Consider the class C network 192.168.100.0 through to 192.168.100.255. (This is the designated "private" class C block. IE packets destined for these addresses will not be routed by the Internet proper.) Here is the same netmask generation process:

11000000.10101000.01100100.00000000
11000000.10101000.01100100.11111111
-----------------------------------
11111111.11111111.11111111.00000000

Which converts to 255.255.255.0, the classic class C netmask.

To understand how the netmask is used, consider the diagram below. When a packet arrives at the router from the Internet addressed to 10.2.4.6, the router 'ands' this address with the netmask of 255.0.0.0 which gives 10.0.0.0, so the router routes the packet onto the 10.0.0.0 network. Similarly, when a packet arrives at the router addressed to 10.4.6.8, the router 'ands' this address with the netmask of 255.0.0.0 which again gives 10.0.0.0, so the router again routes the packet onto the 10.0.0.0 network.

However, in the configuration shown below, when a packet arrives at the router from the Internet addressed to 10.2.4.6, the router 'ands' this address with the netmask of 255.255.0.0 which gives 10.2.0.0, so the router routes the packet onto the 10.2.0.0 network. But when a packet arrives at the router addressed to 10.4.6.8, the router 'ands' this address with the netmask of 255.255.0.0 which gives 10.4.0.0, so the router again routes the packet onto the 10.4.0.0 network.

Home > IT Notes