subnet mask (subnetting)
A subnet mask is a 32- or 128-bit number that segments an existing IP address in a TCP/IP network and divides that address into discrete network and host addresses. The process of subnetting can further divide the host portion of an IP address into additional subnets to route traffic within the larger subnet.
IP address binary bits that represent a network are represented by a 1 in the subnet mask, and bits that represent a host appear as 0s. In a binary mask, for example, a “1” over a number says “look at the number underneath;” a “0” says “don’t look.” Using a subnet mask saves the router from having to handle the entire 32-bit address; it can simply look at the bits selected by the mask.
IPv4 and IPv6 subnetting
Subnetting is essential when a single IP address block has to be allocated over numerous segments within the same local area network (LAN). Like IPv4 addresses, an IPv4 subnet mask contains four bytes (32 bits) and is written using the same dotted-decimal quadrant notation. In this method, the series of 8 binary 1s is translated to the decimal number 255. For example, a common IPv4 address is 192.168.1.1 with a subnet mask of 255.255.255.0. This example shows that the first three segments of the four segment address belong to the network portion of the address, while the last segment is designated for all hosts within that IPv4 subnet.
IPv6 addresses, on the other hand, use 128-bit binary addresses that often are viewed as eight-segment hexadecimal notations that are separated by a colon. Unlike IPv4 addresses that separate the IP address from subnet mask, IPv6 is a single address that is broken up into three portions that includes the subnet within the address. The first segment of the three-segment IPv6 address is the general routing prefix, which never changes on the LAN. This consumes the first 48 bits. The next 16 bits — 49 to 64 — designate the subnet the IP address belongs to. And finally, the last 64 bits are designated for the host portion of the address. An example IPv6 address looks like this:
In this case, the first three sections are the general prefix, the next section is the subnet and the final four segments indicate the node portion of the address. Once a packet has arrived at an organization’s gateway or connection point with its unique network number, it can be routed to its destination within the organization’s internal gateways using its subnet number.
Subnet masks allow organizations to subdivide public IP address blocks without acquiring new IP network numbers from an ISP. A subnet mask can increase the number IP addresses, and improve network security and performance. A subnet mask can be used to choose how many subnets to create or how many network nodes are needed on each subnet by setting all subsequent network bits to “1” and host bits to “0”. A subnet mask doesn’t represent a specific device or network on the internet; instead it indicates which portion of an IP address should be used to determine the network ID.
Subnet mask chart
Fixed- and Variable-Length IPv4 Subnetting
Fixed-Length Subnet Masking (FLSM) and Variable-Length Subnet Masking (VLSM) are methods to streamline how packets are routed within a subnet in a proprietary network. The original concept of IPv4 subnets was that they were broken into fixed-length sizes — known as classes. This is also referred to as classful subnetting. Class A networks had a first octet between 1 and 127. These effectively used a 255.0.0.0 subnet mask. The class B first octet ranged between 128 and 192, using a 255.255.0.0 mask. And C used the 192 to 223 space using the 255.255.255.0 mask. Class D and E networks are designated for multicast and experimental purposes, respectively. While FLSM simplifies subnetting by creating subnets of all the same length, this approach can yield subnets that are either too large or too small. VLSM was developed to further subdivide a large subnet into smaller subnets that have variable numbers of hosts, which can prevent wasting address space. VLSM is also referred to as Classless Inter-Domain Routing (CIDR).
How to calcualte subnet masks
A subnet calculator can be used to help divide an IP network into subnets by calculatingnetwork address, subnet mask, broadcast address and host IP address range. Subnets can be calculated by hand, but subnet calculators are also readily available online.