TCP/IP and Subnets
Calculating the Subnet Mask Example: We require 8 subnets and we have decided to use a Class B network address of 175.10.0.0. Using a standard Class B subnet, this would give us 1 subnet and 65,000 hosts addresses. Increasing the subnet to 255.255.192.0 will give 4 subnet and 16,000 hosts. If we want to use 8 subnets, a mask of 255.255.224.0 would be sufficient. This would give us 8,000 hosts on each subnet. Determining the valid Network Address
Subnet Calculator
My experience with subnet masks is that they can be quite difficult to understand unless you're quite adept at maths. True networking professionals would disagree. However, thanks to the growth of the Internet and the business-spotting potential of some software companies, there are ways round the hard work, and software versions of a Subnet Calculator are available on the internet such as this one.
What is a Subnet Mask?
This is a number that contains four sets of octets, usually containing at least one set of the number 255. However, its real purpose is to act as a mask to TCP/IP and show it which portion of the address is the network address and which portion is the host address. Note: Every TCP/IP address must have a Subnet mask.
Thus a subnet of 255.0.0.0 can represent the network as:
nnnn.nnnn.hhhh.hhhh.hhhh.hhhh.hhhh.hhhh
So to look for the hosts on a network, it knows to ignore the left hand or first eight bits in the address. Equally, a host address of 255.255.0.0 could be represented as:
nnnn.nnnn.nnnn.nnnn.hhhh.hhhh.hhhh.hhhh
After IP has worked out the network portion of the address, it can then determine if the address is local or remote, and route the traffic accordingly. This is important as IP tests the address in binary, thus:
Mask 255.0.0.0 1111.1111.0000.0000.0000.0000.0000.0000
Source Address 10.1.2.3 0000.1010.0000.0001.0000.0010.0000.0011
Destination Address 12.1.2.4 0000.1100.0000.0001.0000.0010.0000.0100
Equals remote.
Standard Subnets
| Class | Decimal | Binary |
|---|---|---|
| A | 255.0.0.0 | 1111.1111.0000.0000.0000.0000.0000.0000 |
| B | 255.255.0.0 | 1111.1111.1111.1111.0000.0000.0000.0000 |
| C | 255.255.255.0 | 1111.1111.1111.1111.1111.1111.0000.0000 |
Custom Subnet Masks
By using a custom subnet mask applied to an address, the IP address can be used to create a more flexible division between hosts and networks. For example, a Class A network can have 17 million hosts, but it's unlikely that an organisation will have one network with 17 million PCs, servers, etc. Organisationally, you are likely to want to split these up on different logical networks, as well as physical ones. This is where routers come in. By a combination of IP addresses and subnet masks, you can break a Class A range down into more networks. For example, if you wanted to use a Class A network with a subnet of 255.255.0.0, this would mask off the first 24 bits for the network portion of the address, thereby creating 254 networks and 65,534 hosts.
Sub-netting Rules:
*
The subnet bits in the IP address cannot be all 1s
*
The subnet bits in the IP address cannot be all 0s
*
The Host bits in the IP address cannot be all 1s
*
The Host bits in the IP address cannot be all 0s
When all the host bits are set to 1, this becomes a broadcast address, which means every host on the network will accept it for further processing. When the host bits are set to 0, the IP address refers to the network and not to the hosts, as no host can use it.
Six Steps to Custom Subnet Mask Creation
*
Determine how many subnets are required
*
Calculate how many hosts are to be used on each subnet
*
Calculate Subnet mask
*
Determine the valid IP addresses
*
Determine the range of valid host IP addresses on each subnet
*
Check that you have met the criteria in step 1 and 2
Calculating the Subnet Mask
Example: We require 8 subnets and we have decided to use a Class B network address of 175.10.0.0. Using a standard Class B subnet, this would give us 1 subnet and 65,000 hosts addresses. Increasing the subnet to 255.255.192.0 will give 4 subnets and 16,000 hosts. If we want to use 8 subnets, a mask of 255.255.224.0 would be sufficient. This would give us 8,000 hosts on each subnet.
Determining the Valid Network Address
1.
Add 1 to the number of subnets you need
2.
Convert this to binary
3.
Find out how many bits you need for the subnet mask
4.
Calculate the rightmost bit as being the first network number
Determining the Range of Valid Host IP Addresses
Not all of the addresses created on each network will be valid; therefore, you have to determine which of the addresses are available for use by each host. To do this, apply the subnet mask to the address and the valid addresses can be created with the remaining bits.
Example: Using a mask of 255.255.224.0 with an address of 120.100.32.0:
In binary, the mask is:
1111.1111.1111.1111.1110.0000.0000.0000
The first available address from the network is 120.100.32.0, but this is invalid because the hosts are all 0s. Therefore, the first valid number is 120.100.32.1. Now determine the last valid number. Increment the hosts until all the host bits are 1s. As we know from the subnet rules above, this address is invalid because all the host bits are set to 1. Therefore, the last valid number is 120.100.63.254.
These articles are created by the engineers at EssingtonITS as part of our day-to-day work supporting real-world systems, projects, and deployments. From Linux administration and networking to Moodle, Docker, automation, and infrastructure management, our goal is to share useful knowledge that helps others solve problems faster and work more efficiently.
person people found this useful.