What Is A Subnet Mask: Splitting Up IP Addresses With Subnetting

What Is A Subnet Mask?

0 Comment

7 mins Read

What Is A Subnet Mask?

Each and every device connected to the Internet communicates, locates, and interacts with other devices connected to the Internet through an IP address. This address is a unique set of numbers assigned to each device on a network, much like a home address that locates and differentiates the location of a certain house from other houses in the street.

While there aren’t that many IP addresses on a typical IPv4 home network (e.g., 192.168.0.0/24 gives 256 addresses), on IPv6 networks, there could be as many as 18 quintillion addresses available.

That said, not all of them are used by your household’s devices, thanks to subnetting and subnet masks. So the questions that remain are: What is a subnet? What is a subnet mask? How does IPv4 and IPv6 subnetting work? And how can you use a subnet cheat sheet to configure your network? All will be answered in this article by yours truly.

I’ve created a cheat sheet that covers subnet masks, the IPv6 CIDR prefix length, and how to set up your IPv4 or IPv6 networks. Be sure to check it out at the end of this article! It also has helpful info on IP addresses and networking.

What Is a Subnet Mask?

An IPv4 address is made up of 32 bits, which are then divided into 8-bit segments, which are commonly referred to as “octets.” These octets are typically allocated to either the network ID or host ID. If you need more information about IPv4 and IPv6, read our blog post titled “IPv4 vs. IPv6: How IPv6 Is Set to Replace IPv4.”

The Network ID and Host ID

The network ID or network address defines which network an IP address belongs to. So, When a packet of data is sent across the internet or a local network, the routers use the network ID to decide whether the packet’s destination is in the same network or if it needs to be forwarded to a different network. The network ID tells routers which network the packet should be routed to.

Additionally, the network ID also helps differentiate different subnets in a larger organization or environment. With a distinct network ID for each subnet, devices can communicate within their local subnet or reach other subnets through routers. Naturally, all devices in the same network share the same network ID.

Then, we have the host ID portion of an IP address. This portion is essentially what defines the unique device (host) within that network. The host ID distinguishes devices in a network so that the network can properly route traffic to and from the correct devices.

The Subnet Mask

Now, we can finally discuss the subnet mask. The subnet mask is a 32-bit number (similar to an IP address) that defines which of those octets that I mentioned above are assigned to the network ID and which are assigned to the host ID.

IPv4 Subnet Mask

Let’s say you have an IPv4 address that looks like 192.168.1.10 and a subnet mask that looks like 255.255.255.0. The recurring numbers in the subnet mask show us that the first three octets, or 24 bits, of the IP address, which is 192.168.1.0, represent the network portion (network ID). 

This is because, as I said earlier, the network portion of all devices in the same network share the same network ID, so that number is constant among all the devices in the network. As for the host ID portion, the last octet is the number of available IP addresses that can be assigned to a device.

So, you may ask, how do I know how many IP addresses are available for devices? Well, when a subnet mask shows us that an IP address has eight bits reserved for host IDs, it means that there are eight variables where a 0 or 1 can be placed. 

This translates into 2^8 or 256 IP addresses that can be assigned to a device in this IPv4 address. However, note that two of these addresses are always reserved for the network address (192.168.1.0) and broadcast address (192.168.1.255).

IPv6 Subnet Mask

Subnet masks in IPv4 aside, let’s talk about subnet masks in IPv6. Rather than showing which portion of the IPv6 address is assigned to the network ID and which is assigned to the host ID through a dotted decimal notation like in IPv4 (255.255.255.0), IPv6 uses a prefix length, which is part of a newer system of IP allocation and notation altogether.

This system is called Classless Inter-Domain Routing. Instead of the previous class-based IP allocation system, it uses Variable-Length Subnet Masking (VLSM). You can learn more about CIDR, how it works, and how it differs from previous systems here.

As for how a CIDR notation shows which portions are for network and host ID, typically, a / is added to the end of an IPv6 address followed by a number, which indicates how many bits are allocated to the network portion. This CIDR notation is called a prefix length.

Note that while each number in an IPv4 address represents 8 bits or an octet, in IPv6, each number and letter combination between two decimals represents 16 bits. For example:

2001 (hex) → 0010000000000001 (binary)

The complete binary version of the IPv6 address 2001:0db8:85a3:0000:0000:8a2e:0370:7334 is:

0010000000000001 0000110110111000 1000010110100011 0000000000000000
0000000000000000 1000101000101110 0000001101110000 0111001100110100

Additionally, to shorten an IPv6 address, instead of including all the zero blocks (16-bit blocks of zeros in an IPv6 address), they are replaced with a double colon (“::”). The number of 16-bit zero blocks can be calculated by subtracting the number of non-zero blocks that are shown full from the total number of blocks in an IPv6 address, which is eight. For instance:

2001:db8:1234::/64  → 2001:db8:1234 → 8 total blocks – 3 non-zero blocks= 5 zero blocks

So, the full address is 2001:0db8:1234:0000:0000:0000:0000:0000/64.

With those basics covered, let’s look at an example of IPv6 subnet masks:

If an IPv6 address is as follows: 2001:db8:1234::/64 

The first 64 bits are for the network portion: 2001:db8:1234

The remaining 64 bits (128-64=64) are for the host portion: 0000.0000.0000.0000.

Subnet Cheat Sheet for IPv4 and IPv6

While subnet masks and subnetting seem like the same terms, they do completely different things. Subnetting essentially breaks down massive numbers of IPv4 or IPv6 addresses that come with a network to better manage different departments or devices and improve security.

For instance, in a corporate environment, the finance department may have its own subnet, preventing unauthorized access from other departments. In a home environment, dividing the network into two subnets, one for personal devices and one for IoTs (Internet of Things) like smart home assistants or Roombas, can improve security and traffic, as IoTs constantly communicate with cloud services and are typically more vulnerable to security breaches.

Before 1993, subnetting was done through classes where a network either had 254, 65,534, or over 16 million IPs for (devices), and you couldn’t divide them into smaller networks like you can today.

However, thanks to the development of CIDR, you can now split any network of any size into however many smaller networks as you like. So, let’s get into how subnetting in IPv4 and IPv6 is done and how you can use our handy subnet cheat sheet to configure your network.

IPv4 Subnet Cheat Sheet 

Let’s say you have a network, such as 192.168.1.0/24, with 256 IP addresses for the host portion. While you can figure out how many IPs are dedicated to the network and host portion through the subnet mask (255.255.255.0), through the /24 at the end of the IP, you can deduct that since 24 bits are dedicated to the network portion 8 bits or 256 (2^8=256) addresses are used for the host portion.

If we want to divide this network and have two subnets of 128 addresses, we borrow one bit from the network portion, which leads to the following setup and changes:

  • New subnet mask: /25 or 255.255.255.128
  • Hosts per subnet: 128
  • Subnet 1: 192.168.1.0/25  (126 usable addresses from 192.168.1.1 to 192.168.1.126)
  • Subnet 2: 192.168.1.128/25 (126 usable addresses from 192.168.1.129 to 192.168.1.254)

Through this CIDR process, you can divide any network as much as you like, as long as you have two usable IP addresses ( excluding the two IPs necessary for broadcast and network address). So, for a /24 network with 254 usable IPs, you can create 64 subnets, each containing two usable IP addresses; however, such a low number of hosts is typically used for point-to-point connections.

IPv6 Subnet Cheat Sheet

IPv6 subnetting is especially important as the IPv6 address space offers 2^128 or 340 undecillion (34 with 37 zeros behind it) unique IP addresses. An average IPv6 network is typically set up with a /64 CIDR that allocates 64 bits to the network portion and the other 64 bits to the host portion, giving you 2^64 or 18 quintillion (18 with 18 zeros behind it) unique addresses.

Considering the sheer number of available IPv6 addresses, even with a typical /64 CIDR, subnetting an IPv6 network is hugely beneficial as network admins can manage devices by grouping them based on location, department, or function, monitor their traffic, apply security policies, and configure routers much easier.

While /64 subnets are the most commonly used form of subnetting IPv6 IPs as features like SLAAC or Stateless Address Autoconfiguration ( allows devices to automatically generate their IP addresses based on the network they connect to without needing a DHCP server), you can easily divide an IPv6 network into whatever number of subnets you like.

Let’s say you have a typical /64 IPv6 network such as 2001:db8:abcd:1000::/64; if we borrow, for instance, 4 bits from the network portion, we can divide our network into 16 subnets, which leads to the following changes:

  • Original subnet: 2001:db8:abcd:1000::/64
  • New subnet: /68
  • Number of subnets: 2^(bits borrowed from network)= 2^4=16 subnets
  • First subnet: 2001:db8:abcd:1000:0000::/68
  • Second subnet: 2001:db8:abcd:1000:1000::/68
  • Third subnet: 2001:db8:abcd:1000:2000::/68
  • … up to 2001:db8:abcd:1000:f000::/68
  • 2001:db8:abcd:1000: The first 64 bits define the global routing prefix.
  • 0000 – f000: The next 4 bits are used for subnetting.
  • Host Portion: The remaining 60 bits are used for host addresses. (The remaining “::” which shows three 16-bit blocks)
  • Each /68 subnet has 2^60 = 1.15 quintillion possible host addresses. 

Final Thoughts

Subnetting is a crucial part of every network, whether that’s IPv4 subnetting or IPv6 subnetting. Hopefully, this post and the subnetting cheat sheet I’ve provided can help you set up and subnet your network much easier. 

FAQs

What is a subnet mask?

In IPv4, the subnet mask is a 32-bit number (similar to an IP address) that defines which octets are assigned to the network ID and the host ID. In IPv6, Instead of using subnet masks like in IPv4 (e.g., 255.255.255.0), IPv6 uses prefix length notation to indicate how many bits of the address are used for the network portion.

How are IPv4 and IPv6 subnetting done?

Through CIDR or Classless Inter-Domain Routing, we can divide an IPv4 or IPv6 network into however many subnets we like by borrowing bits from the network portion; however, for IPv4, you must have at least two usable IP addresses ( excluding the two IPs necessary for broadcast and network address). For example, if you have a network with 256 IP addresses (192.168.1.0/24) and want to split it into two subnets with 128 IPs, you borrow one bit from the network portions, producing these two subnets: 192.168.1.0/25 & 192.168.1.128/25

Is there a subnetting cheat sheet for IPv4 and IPv6?

Yes! Calculating how many IP addresses you get when subnetting your network can be quite tricky, especially with IPv6. That’s why I’ve compiled a comprehensive subnet cheat sheet to make your subnetting easier. It’s also an IPv6 cheatsheet and a network cheatsheet, so it’s pretty comprehensive!

Your friendly neighborhood writer guiding you through the sea of tech and cloud.

Comments

Leave a Comment

Your email address will not be published. Required fields are marked *


Latest Posts