In the past few years, as the number of hosts connected to the Internet has grown beyond expectations, it has become apparent that the present IP addressing scheme imposes limitations on network size. This has led to two concepts for IP network administrators: subnetting and supernetting.
When a large network is subnetted, the network is divided into at least two smaller subnetworks, with each subnetwork (subnet) having its own subnetwork address (subnetid). When supernetting is performed, several small Class C networks are combined to create one large network, or supernetwork.
In this Daily Drill Down, I’ll cover the procedures involved in subnetting Class A, B, and C networks as well as those involved in supernetting Class C networks.
Each IP address is 32 bits long. A portion of each IP address represents the network (netid), and a portion represents the host (hostid). This means that IP addressing imposes its own hierarchy to follow for reaching any host on an internetwork. The network is first reached using the netid, and then the specific host is reached using the hostid. This addressing scheme approaches all networks as if they are just one large network with several hosts. If this addressing were the only one allowed, there would be two serious limitations on network design:
- Hosts on the network could not be organized into groups. With this scheme, you could not create separate networks for departments within an organization.
- All networks would be at the same level. If all hosts were connected to the same physical network, bandwidth would be quickly consumed during peak usage hours. All users would be sending and receiving over the same cable.
The effect of having all hosts connected to the same physical network is shown in Figure A.
|In this example, all our hosts are connected to the same physical network.|
In Figure A, the hosts are all connected to the same Class B network, with the network address 18.104.22.168. In a Class B network, there are up to 65,534 hosts. If all of these hosts used the same cable, it would be extremely difficult for users to send and receive information efficiently.
A possible solution is to divide one large network into several smaller networks through subnetting. Figure B shows the effect of dividing a large Class B network into three smaller subnetworks.
|Now the Marketing and Finance departments each have their own subnets: 22.214.171.124 and 126.96.36.199, respectively.|
In Figure B, the Marketing and Finance departments now each have their own subnets: 188.8.131.52, and 184.108.40.206, respectively. In addition, the router now uses two interfaces—220.127.116.11 and 18.104.22.168—to provide a separate gateway for each subnetwork. The effect of subnetting the original large Class B network is to reduce the network congestion caused by having all hosts on one large network use the same physical cable. In addition, isolating network problems now becomes easier because problems can be isolated within a smaller subnetwork.
To hosts outside the organization, the effect of subnetting is invisible. All IP information destined for either the 22.214.171.124 subnet or the 126.96.36.199 subnet still goes to the same router. However, when information arriving from the Internet reaches the router, the destination IP address is interpreted differently.
The router now knows that the original 188.8.131.52 network has been subnetted into two smaller subnetworks. The router interprets IP address information in the following manner:
- The first two bits, or octets, 143.15, are used to define the netid (184.108.40.206 or 220.127.116.11).
- The third octet is used to define the subnetid (18.104.22.168 or 22.214.171.124).
- The last octet is used to define the hostid—for example, 126.96.36.199.
Subnetting a large network immediately creates a third level of hierarchy to the IP address format. So now there are three levels:
- Netid—Defines the entire site within the organization
- Subnetid—Defines the physical subnetwork
- Hostid—Identifies each host connected to the subnetwork
This also means that when IP information is sent to the network from the Internet, three steps are involved in routing the information:
- The IP packet is delivered to the site (188.8.131.52).
- The packet is forwarded to the correct subnetwork (184.108.40.206 or 220.127.116.11).
- The packet is delivered to the correct host.
Let's take a look at a Class B network with and without subnetting:
Subnet masking is a process used to extract the physical network address from an IP address. Actually, masking may be done whether there is a subnet in place or not. If there is no subnet, masking extracts the network address. If there is a subnet, masking extracts the subnetwork address.
The first step in understanding subnet masking is to understand how a netmask is created. For example, let’s assume we want to determine the netmask for the 192.168.1.0 network. In binary format, 192.168.1.0 is written as:
The three leftmost bits are 110, so we know that this is a Class C address. This means that the first 24 bits are used for the netid and the last 8 bits are used for the hostid. To determine the netmask, set all the network bits to 1 and all the host bits to zero. In binary format, this is:
Converted to decimal format, this gives us a netmask of 255.255.255.0. To determine the netmask, just remember that all the netid bits are set to 1 and all the hostid bits are set to 0. Let’s look at another example. A network has 10.0.0.0 for the netid. In binary format, this address translates to:
When we set all the network bits to 1 and all the host bits to 0, we get:
Bitwise AND operations
The principle behind bitwise AND operations is simple: If the first operator has a value of 1 (true) AND the second operator has a value of 1 (true), then the value returned is true. In all other cases, the value is false (0).
Let’s look at an example. To determine if the IP address 192.168.1.130 belongs to the local network—which has a netmask of 255.255.255.128—the computer sending the IP packet performs the following:
11000000.10101000.00000001.10000010 (which is 192.168.1.130)
11111111.11111111.11111111.10000000(which is 255.255.255.128)
11000000.10101000.00000001.10000000 (which is 192.168.1.128)
In this case, the bitwise operation returns a network address of 192.168.1.128 for the IP address 192.168.1.130.
Now let’s look at another example. When a Class C network is left intact, the netmask is 255.255.255.0. If we want to create two individual subnets, we must first create a netmask.
This is accomplished by setting one or more bits in the host portion of the default mask to 1. To divide the 192.168.1.0 network into two equal subnetworks, we set the most significant (leftmost) bit in the host portion of the address to 1. This gives us:
11111111.11111111.1111111.10000000 (which is 255.255.255.128)
This produces a new netmask that divides the original 192.168.1.0 network into two equal subnetworks: the 192.168.1.0 subnet and the 192.168.1.128 subnet. Both networks use the same netmask: 192.168.1.128. Now let’s try another bitwise AND operation. Given the IP address 192.168.1.21, let’s determine which network this address belongs to by performing a bitwise AND operation:
11000000.10101000.00000001.00010101 (which is 192.168.1.21)
11111111.11111111.11111111.10000000 (which is 255.255.255.128)
11000000.10101000.00000001.00000000 (which is 192.168.1.0)
The bitwise AND operation returns a network address of 192.168.1.0 for the IP address 192.168.1.21.
Now try the same operation for the IP address 192.168.1.140:
11000000.10101000.00000001.10001100 (which is 192.168.1.140)
11111111.11111111.11111111.10000000 (which is 192.168.1.128)
11000000.10101000.00000001.10000000 (which is 192.168.1.128)
For the IP address 192.168.1.140, the bitwise AND operation returns a network address of 192.168.1.128.
To determine how many subnets can be created from a full Class A, B, or C network, use the formula:
Number of subnets = 2x – 2
where x represents the number of host bits.
For example, let’s say 8 host bits are available in a Class C network. Although it would appear that there are 27, or 128 possible subnets, we also lose some IP addresses for broadcast and network addresses. Because of these practical limitations, most administrators limit Class C subnetting to 16 subnets.
Linux comes with a very useful utility for determining which network an IP address belongs to. This tool is capable of calculating the broadcast address, netmask, network, and network address for any given IP address/netmask combination. The ipcalc tool is easy to use. Simply enter the IP address and subnet mask into ipcalc. For example, to determine the broadcast and network addresses for the IP address 192.168.1.1 with a netmask of 255.255.255.128, use the command:
ipcalc –network –broadcast 192.168.1.1 255.255.255.128
The ipcalc command would then return the following values:
Other IP calculator tools include a tool for the Palm Pilot (called IPcalc) and IPCalc for the Windows operating system.
Below, I have outlined examples for subnetting Class A, B, and C networks. In each example, I offer a table of how the network looks with the original subnet masking and then with the new subnet masking.
Subnetting Class A networks
First, remember some key points about Class A networks:
- The first byte in a Class A address is the netid.
- The remaining three bytes are the hostid.
- A Class A network may have up to 16,777,214 (224 minus 2) hosts connected to the network.
For this example, we use an organization with a Class A network with the network address 18.104.22.168. There is now a requirement for at least 1,000 subnetworks. Using this information, the administrator can make the following decisions:
- The organization will actually require at least 1,002 subnetworks to account for subnetids composed of all 1’s and all 0’s.
- The minimum number bits that may be assigned for subnetting is 10 (210 = 1,024).
- This leaves 16 bits for use as hostids.
- IP addresses with all subnetid bits set to 1 and all subnetid bits set to 0 are reserved.
- This leaves a maximum of 16,382 (214 minus 2) hosts connected to each subnetwork.
|New Subnet Mask||255.255.192.0|
Now we identify the subnetworks. The subnetid actually contains 10 bits. The last two bits in the subnetid belong to the third byte of the original IP address. The last two bits represent 26, or 64, and 27, or 128. This means that the first subnetid available for use is 22.214.171.124, and the last subnetid available is 126.96.36.199.
Now we’ll show the network with the default netmask and with subnet masking applied.
|First subnet||This network IP||First address||Last address||Broadcast|
|Last subnet||This network IP||First address||Last address||Broadcast|
Subnetting Class B networks
A Class B network uses the first two bytes of the IP address for the netid and the last two bytes for the hostid. A Class B network can have one large physical network with up to 65,534 (216 minus 2) hosts. Let’s look at an example of subnetting on a large Class B network.
Let’s assume your company has obtained a Class B network with the network address 188.8.131.52, and it now needs a minimum of 12 subnetworks. Let’s determine the subnet mask and configuration for each subnet.
In this example, your company will need a minimum of 14 subnets. This accounts for the 12 required subnets, plus two subnets reserved for special purposes. This requires the new subnet mask to have an additional 4 bits (24 = 16). Here is the Class B network before and after the subnet mask is applied.
|Subnet mask = 255.255.0.0|
|New subnet mask = 255.255.240.0|
Using the new subnet mask 255.255.240.0, the network is now divided into 16 subnetworks, with two network addresses reserved for special purposes. This new subnet mask leaves 12 bits to define hostids on each subnet. The new configuration allows for 4,096 (212) hosts to be connected to each subnetwork. With the first address reserved to define the subnetwork and the last address reserved for a broadcast address, there may actually be a maximum of 4,094 hosts on each subnet. The range of netids used for the new subnetted network is from 184.108.40.206 to 220.127.116.11.
In the example below, I’m subnetting a Class B network into 14 smaller subnets. This forces me to use four bits (1111) in the new subnet mask. This creates 16 new subnets. Two of these subnets are reserved: one subnet, with all subnetid bits set to 1, and another subnet with all subnetid bits set to 0.
|First subnet||Subnet address||First address||Last address||Broadcast|
|Last subnet||Subnet address||First address||Last address||Broadcast|
Subnetting Class C networks
Class C IP addresses use three bytes for the netid and one byte for the hostid. A business using a class address may have one physical network and up to 254 (28 minus 2) hosts connected to that network. The company could also subnet the one large physical network into several smaller subnetworks. Let’s look at an example of subnetting a Class C network.
A business has been granted the Class C address 18.104.22.168. To make this address useful, the company will need to subnet this address into six subnetworks.
The organization will actually require eight subnetworks, six physical subnets, and two reserved addresses. This means there should be an additional three bits to the subnet mask (23 = 8). This will allow for six physical subnetworks and an additional two subnetids reserved for special addresses. With five bits remaining for hostids, there may be up to 32 hosts connected to each subnet. However, hostids with all bits set to 0 and hostids with all bits set to 1 are reserved, so the actual limit for each subnet is 30 hosts. The first available subnetid address is 22.214.171.124, and the last available subnetid address is 126.96.36.199.
Now we’ll work on a Class C network with and without subnet masking:
|Subnet mask = 255.255.255.0|
|New subnet mask = 255.255.255.224|
In Figure C, we show the original class network subnetted into six smaller subnetworks.
|The original class network is subnetted into six smaller subnetworks.|
The TCP/IP protocol suite provides the basis for Internetworking. A thorough knowledge of TCP/IP is essential to managing computer networks—and almost any other device connected to the Internet. In this Daily Drill Down, we covered the procedures for subnetting TCP/IP networks. We looked at the disadvantages of maintaining large IP networks and the advantages gained from subnetting these networks. In addition, we provided an introduction to creating subnet masks and performing bitwise AND operations to determine the network address from any given IP address. We provided subnetting examples for Class A, B, and C networks.