Technology / Networking

Networking Basics: What is IPv4 Subnetting?

Networking Basics: What is IPv4 Subnetting? picture: A
Follow us
Updated on May 13, 2024

Quick Definition: Subnetting is the process of taking a network and splitting it into smaller networks, known as subnets. It's used to free up more public IPv4 addresses and segment networks for security and easier management.

Subnetting is a fundamental aspect of IP network design and administration. This practice offers numerous benefits, including the more efficient use of IP addresses, reduced network traffic, improved security, and scalability

To understand subnetting, you first need to understand the decimal and binary structure of an IP address.

A Quick Rundown of IP Addresses and Binary

To understand subnetting, you should first understand an IP address's decimal and binary structure.

Let's start with the basics. Here's what an IP address looks like: 192.168.1.20

An IPv4 address is a 32-bit number. To simplify addresses, they are divided into four 8-bit numbers — or octets — separated by a decimal point. These octets range in number from zero to 255.

Why do octets only go up to 255? Because they're binary.

The biggest IP address possible is 255.255.255.255

In binary, this IP address looks like this: 11111111.11111111.11111111.11111111

Note that there are eight numbers between the decimal points. Each number represents a bit. Hence, the term octet or the 8-bit number grouping.

Binary corresponds to this table:

Network Mask Table
1286432168421

Let's use this binary number, for example: 10000001

Every 1 in a binary number "turns on" the number in its position. So, 1 in the first and last positions "turn on" 128 and 1.

Network Mask Table
1286432168421
10000001

Add up all the positions to get the decimal number: 128 + 1 = 129

When all the positions are "turned on," they add up to 255.

You can see how it works here. These are the most common octets you'll encounter in subnetting:

Network Mask Table
1286432168421
11111111
11111110
11111100
11111000
11110000
11100000
11000000

How to Define the Network Portion of a Subnet IP Address

During the early stages of the internet, organizations assigned IP addresses like crazy until we nearly ran out. Luckily, the designers of IP addressing came up with a way to end this wasteful practice: Dividing networks using subnetting.

The process of taking an extensive network and splitting it into smaller networks is known as subnetting — and it's freeing up more public IPv4 addresses.

There are two parts to an IP address: The network portion and the host portion.

It's like the address for a house. The network portion is like the city, state, and zip code. The host portion is like the house and street number.

A subnet defines the number of bits, out of 32, used for the "network portion" of the address. Subnet masks can also be defined in a more common 'slash' representation called CIDR notation.

In the following table, the red digits represent the bits used for the network. The black digits will be used for device IP addresses. Note that the 255.0.0.0 mask can also be represented as a '/8' because it reserves 8 bits of the overall 32 bits used to describe an IPv4 address as the network portion.

Bits used for maskDefault netmaskSubnet binary
/8255.0.0.011111111.00000000.00000000.00000000
/16255.255.0.011111111.11111111.00000000.00000000
/24255.255.255.011111111.11111111.11111111.00000000

For example, you might have a network with devices (known as hosts) with the following IP addresses:

  • Network: 172.16.56.0

  • Computer 1: 172.16.56.40

  • Computer 2: 172.16.56.55

  • Printer 1: 172.16.56.100

In this case, the network uses 24 bits (or three octets). Notice that every host device in the network has the same first three octets. That's the network portion of the IP address with a /24 mask.

  • IP address: 172.16.56.40

  • Mask: 255.255.255.0

  • Binary mask: 11111111.11111111.11111111.00000000

The last octet is the host portion of the IP address. That's where you'd assign your devices. In this case, you could assign up to 254 hosts. (More on that later.)

  • IP address: 172.16.56.40

  • Mask: 255.255.255.0

  • Binary mask: 11111111.11111111.11111111.00000000

Let's look at the table again. If it were /16, the first two octets would be the network portion, and the host portion would occupy the last two octets.

Bits used for maskDefault netmaskSubnet binary
/16255.255.0.011111111.11111111.00000000.00000000

If it were an /8 network, then only the first octet would be the network portion.

Bits used for maskDefault netmaskSubnet binary
/8255.0.0.011111111.00000000.00000000.00000000

These are the most common masks because they're the simplest, but you have to subnet when you need more than one network. Subnetting lets you choose the number of bits for the Network portion. You can even steal bits from the host portion of the network.

Here's what the full subnet mask table looks like. In this table, 1s represent the network portion, and 0s represent the host portion.

SlashNetmask1st Octet2nd Octet3rd Octet4th Octet
/30255.255.255.25211111111111111111111111111111100
/29255.255.255.24811111111111111111111111111111000
/28255.255.255.24011111111111111111111111111110000
/27255.255.255.22411111111111111111111111111100000
/26255.255.255.19211111111111111111111111111000000
/25255.255.255.12811111111111111111111111110000000
/24255.255.255.011111111111111111111111100000000
/23255.255.254.011111111111111111111111000000000
/22255.255.252.011111111111111111111110000000000
/21255.255.248.011111111111111111111100000000000
/20255.255.240.011111111111111111111000000000000
/19255.255.224.011111111111111111110000000000000
/18255.255.192.011111111111111111100000000000000
/17255.255.128.011111111111111111000000000000000
/16255.255.0.011111111111111110000000000000000
/15255.254.0.011111111111111100000000000000000
/14255.252.0.011111111111111000000000000000000
/13255.248.0.011111111111110000000000000000000
/12255.240.0.011111111111100000000000000000000
/11255.224.0.011111111111000000000000000000000
/10255.192.0.011111111110000000000000000000000
/9255.128.0.011111111100000000000000000000000
/8255.0.0.011111111000000000000000000000000
/7254.0.0.011111110000000000000000000000000
/6252.0.0.011111100000000000000000000000000
/5248.0.0.011111000000000000000000000000000
/4240.0.0.011110000000000000000000000000000
/3224.0.0.011100000000000000000000000000000
/2192.0.0.011000000000000000000000000000000
/1128.0.0.010000000000000000000000000000000

What are IP Address Classes?

To complicate things further, IP addresses have five classes, but only three are applicable to subnetting — A, B, C.

Here are the IP address ranges by class:

  • Class A = 1.0.0.0 to 127.0.0.0

  • Class B = 128.0.0.0 to 191.255.0.0

  • Class C = 192.0.0.0 to 223.255.255.0

Remember, these IP addresses are represented in binary.

Here are the largest subnet IP addresses in these ranges:

ClassNetmask1st Octet2nd Octet3rd Octet4th Octet
Class A127.0.0.001111110000000000000000000000000
Class B191.255.0.010111111111111110000000000000000
Class C223.255.255.011011111111111111111111100000000

This is important because it affects the number of hosts and subnets available in a network.

Notice that Class A addresses provide the most room for host addresses (the black digits). That's because the network portion only occupies the first octet. Most large enterprises use Class A IP addresses for this reason. You can connect more devices to a Class A network than a Class C.

ClassNetmask1st Octet2nd Octet3rd Octet4th Octet
Class A127.0.0.001111111000000000000000000000000

In every class, you can steal bits from the hosts to create more subnets but also reduce the number of hosts. Notice how stealing just one bit for the network significantly drops the number of hosts.

Class A Subnet Netmasks and Hosts

Network BitsSubnet MaskNumber of SubnetsNumber of Hosts
/8255.0.0.0016,777,214
/9255.128.0.008,388,606
/10255.192.0.024,194,302
/11255.224.0.062,097,150
/12255.240.0.0141,048,574
/13255.248.0.030524,286
/14255.252.0.062262,142
/15255.254.0.0126131,070
/16255.255.0.025465,534
/17255.255.128.051032,766
/18255.255.192.01,02216,382
/19255.255.224.02,0468,190
/20255.255.240.04,0944,094
/21255.255.248.08,1902,046
/22255.255.252.016,3821,022
/23255.255.254.032,766510
/24255.255.255.065,534254
/25255.255.255.128131,070126
/26255.255.255.192262,14262
/27255.255.255.224524,28630
/28255.255.255.2401,048,57414
/29255.255.255.2482,097,1506
/30255.255.255.2524,194,3022

Class B IP addresses offer fewer hosts than Class A because its network portion occupies the first two octets.

ClassNetmask1st Octet2nd Octet3rd Octet4th Octet
Class B191.255.0.010111111111111110000000000000000

Class B Subnet Netmasks and Hosts

Network BitsSubnet MaskNumber of SubnetsNumber of Hosts
/16255.255.0.0065,534
/17255.255.128.0032,766
/18255.255.192.0216,382
/19255.255.224.068,190
/20255.255.240.0144,094
/21255.255.248.0302,046
/22255.255.252.0621,022
/23255.255.254.0126510
/24255.255.255.0254254
/25255.255.255.128510126
/26255.255.255.1921,02262
/27255.255.255.2242,04630
/28255.255.255.2404,09414
/29255.255.255.2488,1906
/30255.255.255.25216,3822

Class C IP addresses offer the fewest hosts because the network portion occupies three octets.

ClassNetmask1st Octet2nd Octet3rd Octet4th Octet
Class C223.255.255.011011111111111111111111100000000

You might notice that your home router's default IP address falls into the Class C category. This special subnet is reserved for private IP addresses; you can read why in the Network Address Translation article.

Class C Subnet Netmasks and Hosts

Network BitsSubnet MaskNumber of SubnetsNumber of Hosts
/24255.255.255.00254
/25255.255.255.1280126
/26255.255.255.192262
/27255.255.255.224630
/28255.255.255.2401414
/29255.255.255.248306
/30255.255.255.252622

These standards make subnetting a little easier. For example, if you choose a Class 'C' address, you know it uses at least 24 bits (/24) of the 32 available bits for the network portion of the address.

How to Subnet in IPv4

Now that we know about classes, binary, and subnets. Let's dive into a subnet.

Here's the IP address we'll use: 43.17.255.71/27

Here's what it looks like in binary:

00101011.000100011.111111.01000111

From the IP address, we already know two things:

  • It's a Class A IP Address

  • It must have at least eight network bits, but we're giving it 27 bits

In that case, we know the network portion of the subnet will occupy these bits:

Network BitsSubnet Mask1st Octet2nd Octet3rd Octet4th Octet
/27255.255.255.22411111111111111111111111111100000

Let's reverse engineer this last octet to determine the network portion of the address or what the subnet is for this address.

Here's what we want to do:

  1. Determine the number of allowed subnets using the /27 network mask

  2. Determine what subnet the address lies in

Here's an example:

1. Determine number of allowed subnets using /27 network mask.

Here's the binary representation of the possibilities for the last octet with a /27 mask:

000|0
0000
001|0
0000
010|0
0000
011|0
0000
100|0
0000
101|0
0000
110|0
0000
111|0
0000
0326496128160192224

This gives us eight possible subnets with the /27 mask.

2. How to determine what subnet your IP address lives

Now, let's find the subnet address where this IP address resides.

Remember that the IP address is 43.17.255.71

We are only looking at the last octet because the first three octets are the network portion.

43.17.255.71

We just have to take a look at our table again. 71 falls above the 43.17.255.64 subnet and below the 43.17.255.96 subnet. So it belongs in the 43.17.255.64 subnet.

SubnetLast OctetBlock sizeIP Address
10+3243.17.255.0
232+3243.17.255.32
364+3243.17.255.64
496+3243.17.255.96
5128+3243.17.255.128
6160+3243.17.255.160
7192+3243.17.255.192
8224+3243.17.255.224

We now have the subnet for 43.17.255.71: 43.17.255.64.

That seemed like a lot of work, right? If you are logged in to a Cisco router that's connected to the subnet, there's a more efficient and easier way to get the subnet. Using the command "show ip route" in the Cisco router command line, the output includes the subnet for the IP address.

Of course, you won't always have the command line at your fingertips. That's why it's important to understand how IPv4 addressing works and be able to calculate subnets. Using a chart like the one above and the method we covered makes that process easier. You can identify addresses from subnets in minutes, even seconds. Who knows, you'll want to tackle IPv6 subnetting at that point.

For now, Keith Barker explains how to reverse engineer an IPv4 address.


Download

By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.


Don't miss out!Get great content
delivered to your inbox.

By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.

Recommended Articles

Get CBT Nuggets IT training news and resources

I have read and understood the privacy policy and am able to consent to it.

© 2024 CBT Nuggets. All rights reserved.Terms | Privacy Policy | Accessibility | Sitemap | 2850 Crescent Avenue, Eugene, OR 97408 | 541-284-5522