CCNA | P4: IPv4 Addressing | C4: Analyzing Existing Subnets
Subnetting is a process of dividing a larger network into smaller subnets. This is done by borrowing bits from the host ID portion of the address. Subnets are usually allocated by the network designer based on physical location, corporate department, device type, etc.
Subnetting provides better security and performance by dividing the network into smaller, contained layer 3 domains. A router or firewall can limit traffic allowed between subnets, and broadcast traffic is contained within the subnet.
An IPv4 address is a 32-bit address that is divided into four 8-bit octets.
When working in decimal format, reading from right to left, the columns of the number go up in powers of 10 because each has 10 possible values, 0 – 9.
For example, 192 is written as ‘192’ in decimal because it is one 100’s, nine 10’s and two 1’s (100 + 90 + 2).
When subnetting, it’s easier to work in binary format rather than decimal. With binary format, reading from right to left, the columns of the number go up in powers of 2 because each has 2 possible values, 0 or 1.
Each of the 8 bits in an IPv4 address’s octet therefore has this defined set of binary values: 128 64 32 16 8 4 2 1. When all eight binary bits in an octet are set to 1 (11111111)
, the decimal value is 255 because 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. 255 in decimal is 11111111
in binary, they’re just two different ways of writing the same value.
For example, the IPv4 address 192.168.0.10 is written like this in binary: 11000000 . 10101000 . 00000000 . 00001010
192 = 128 + 64 11000000
168 = 128 + 32 + 8 10101000
0 = 00000000
10 = 8 + 2 00001010
To subnet an existing subnet, you need to borrow bits from the host ID portion of the address.
The best way to find out the subnet mask of a subnet is to set the fixed bit of host-id to 1 and the rest to 0.
For example, if we consider a class C address, the first 3 octets are network bits so it remains as it is.
To divide a network into two parts, you need to choose one bit for each subnet from the host ID part.
After subnetting, we end up with NETWORK SUBNET HOST fields. We always reserve an IP address to identify the subnet and another one to identify the broadcast subnet address. Finally, after using the subnetting the total number of usable hosts is reduced from 256 to 254.
For example, let’s say we want to subnet the 172.16.0.0/16 network into smaller 172.16.0.0/19 subnets.
Subnet masks always consist of a solid contiguous block of 1s followed by a solid contiguous block of 0s.
The /19 indicates that the subnet mask has 19 “1’s” followed by all 0’s in binary: 11111111.11111111.11100000.00000000
. Because we might be asked to on the exam, let’s translate the subnet mask from binary to decimal before we get into the subnetting.
All eight bits are set to 1 in the first two octets. The decimal value for them is 255 because 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.
In the third octet, the first 3 bits are set to 1: 128 + 64 + 32 + 0 + 0 + 0+ 0+ 0 = 224. The subnet mask is therefore 255.255.224.0 in dotted decimal notation.
To subnet an existing subnet, you need to borrow bits from the host ID portion of the address.
The best way to find out the subnet mask of a subnet is to set the fixed bit of host-id to 1 and the rest to 0.
For example, if we want to subnet the 172.16.0.0/16 network into smaller 172.16.0.0/19 subnets, the subnet mask would have 19 “1’s” followed by all 0’s in binary: 11111111.11111111.11100000.00000000
.
In dotted decimal notation, the subnet mask is 255.255.224.012.
The third octet is the interesting octet for subnetting because the final “1” in the binary subnet mask is there: 11111111.11111111.11100000.00000000
. The number value in the third octet will change for each subnet.
We note the binary value of the final subnet bit by looking at the position of the final “1”.
In our example, the final “1” has a value of 32: 11100000
. This means that the block size is 32.
The subnets will go up in increments of 32 (starting from 0), on the ‘interesting’ third octet. Our subnets are:
• 172.16.0.0/19
• 172.16.32.0/19
• 172.16.64.0/19
• 172.16.96.0/19
• 172.16.128.0/19
• 172.16.160.0/19
• 172.16.192.0/19
• 172.16.224.0/19
When subnetting a larger network into smaller subnets, the number of usable available subnets is equal to 2N, where N is the number of ‘borrowed’ network bits.
In each of those subnets, the number of usable IP addresses which we can allocate to hosts is equal to 2H-2, where H is the number of remaining host bits.
We subtract 2 from 2H because the lowest IP address in a subnet is reserved for the Subnet ID, and the highest for the broadcast address.
In our example, we subnetted the 172.16.0.0/16 network into smaller 172.16.0.0/19 subnets.
172.16.0.0 is a Class B address with a default subnet mask size of /16.
We are using /19, so we are ‘borrowing’ 3 bits (19 minus 16) which would normally be used as host bits to use them as network bits instead. 2^3 = 8. We are subnetting the one 172.16.0.0/16 network into 8 smaller /19 subnets.
For the 1st subnet:
• 172.16.0.0/19 is the network address
• 172.16.0.1 to 172.16.31.254 are the usable IP addresses which can be allocated to hosts.
• 172.16.31.255 is the broadcast address.
For the 2nd subnet:
• 172.16.32.0/19 is the network address
• 172.16.32.1 to 172.16.63.254 are the usable IP addresses which can be allocated to hosts.
• 172.16.63.255 is the broadcast address.
For the 3rd subnet:
• 172.16.64.0/19 is the network address
• 172.16.64.1 to 172.16.95.254 are the usable IP addresses which can be allocated to hosts.
• 172.16.95.255 is the broadcast address.
Etc
Up to our final subnet:
• 172.16.224.0/19 is the network address
• 172.16.224.1 to 172.16.255.254 are the usable IP addresses which can be allocated to hosts.
• 172.16.255.255 is the broadcast address.
There are 13 host bits (32 bits in an IPv4 address minus the 19 network bits). 2^13-2 = 8190.
There are 8190 available host addresses in each subnet.
In conclusion, subnetting is a process of dividing a larger network into smaller subnets. Subnets are usually allocated by the network designer based on physical location, corporate department, device type, etc. Subnetting provides better security and performance by dividing the network into smaller, contained layer 3 domains. A router or firewall can limit traffic allowed between subnets, and broadcast traffic is contained within the subnet.
In the real world, you can use an online subnet calculator like my own. to perform subnetting.
However, it is important to learn how to do subnetting manually for the CCNA exam. Learning how to do it manually gives you a much deeper understanding of how IP networking works.
I hope this information was helpful. Let me know if you have any other questions!