Phoenix Ignited is a proud tech solutions partner of Luxauro.com. View their news and media page here: Luxauro.com

Intro to Net Masks

Intro to Net Masks

Basic to understanding networking and basic to how networking works is network addressing and sub-networking. Think of it this way the internet is an interstate and off of that interstate branch state highways, and off of those highways branch streets, roads etc. Now host machines on the internet are determined by an IP address, and that IP address lies in a range of IP addresses. Those ranges are “sub-nets” or sub networks. If an ISP is responsible for an IP range of 123.12.12.0/24 it means that the ISP is responsible for all IP’s that belong to that range such as 123.12.12.12 or 123.12.12.10. Meanwhile that ISP would be part of a larger sub-net such as 123.12.0.0/16 which includes all addresses from 123.12.1.123 to 123.12.255.232. A netmask declares the size of a sub-net or sub network.  This article goes through what netmasks are, how they work, and how to convert an IP address and a netmask to CIDR notation and vice versa. 

What is a netmask?

A netmask is a 32-bit binary number that divides an IP into a network portion and a host portion. In decimal a netmask often looks something similar to 255.255.0.0 or 255.0.0.0 or 0.0.0.0 etc. in binary a netmask appears in the form of 11111111.11111111.00000000.00000 (in decimal corresponding to 255.255.0.0). or 11111111.00000000.00000000.00000 (in decimal corresponding to 255.0.0.0). The binary makeup of a netmask is divided between 1’s and 0’s. The 0’s determine the host portion of the IP while the 1’s determine the network portion of the IP. The 1’s must be contiguous and the 0’s must be contiguous for a router to understand which portion of the IP address denotes the network and which portion denotes the host. 

Consider a city, each city has multiple roads, and each road multiple addresses. In this case the 1’s denote which part of the address belongs to the “street” or network and the 0’s denote which portion of the IP address belong to the “house” or host machine. The address 32223 Apple Lane denotes a building, however the Apple Lane portion of the address denotes the street, and the 32223 denotes the physical building on the street. 

NOTE: There is no “technical” difference between a netmask and a subnetmask, they perform the exact same functions.

How Does a Netmask Work?

A netmask is a 32-bit binary string of digits, just as an IP is a 32-bit binary string of digits. When a router receives an address such as 123.12.12.112 (in binary it would look like: 01111011.001100.001100.01110000) and a netmask of 255.255.0.0 (in binary it would be: 11111111.11111111.00000000.00000000) it performs a binary AND operation. The result is the network address. The router can then determine which part of the IP is the network address and which part the host address and send the data packets, requests, etc. to the correct machine.

Netmasks, IP's, and CIDR

CIDR (or Classless Inter-Domain Routing) notation takes an IP address (or network) and appends a /# to the end which determines the number of 1’s in the netmask, for instance 123.12.12.0/24 translates to the network 123.12.12.0 with a netmask of 255.255.255.0. or for a host IP it might be 123.12.12.12/24 this translates to a host IP of 123.12.12.12 which has a netmask of 255.255.255.0 and resides in the 123.12.12.0 network. Again the /# determines the number of 1’s in the netmask. A network of 123.12.12.0/24 has a netmask of 255.255.255.0 which in binary is 11111111.11111111.11111111.00000000 (did you count all 24 1’s?).

That’s it for our exploration of netmasks! Hope you enjoyed it!

Walter Miely is a tech entrepreneur and CEO of Phoenix Ignited Tech You can find him on Linkedin. This material is licensed under the CC BY 4.0 License LEGAL DISCLAIMER: The content provided here is provided AS IS, and part of, or the entirety of this content may be incorrect. Please read the entireLegal Disclaimer here.