Introduction to TCP/IP |
Although the conceptual notion of subnetting by utilizing host bits is straightforward, the actual mechanics of subnetting are a bit more complicated. Subnetting requires a three step procedure:
The number of host bits being used for subnetting determines the possible number of subnets and hosts per subnet. Before you choose the number of host bits, you should have a good idea of the number of subnets and hosts you will have in the future. Using more bits for the subnet mask than required saves you the time of reassigning IP addresses in the future.
The more host bits that are used, the more subnets (subnetted network IDs) you can have — but with fewer hosts. Using too many host bits allows for growth in the number of subnets but limits the growth in the number of hosts. Using too few hosts allows for growth in the number of hosts but limits the growth in the number of subnets.
For example, Figure 1.9 illustrates the subnetting of up to the first 8 host bits of a class B network ID. If you choose one host bit for subnetting, you obtain 2 subnetted network IDs with 16,382 hosts per subnetted network ID. If you choose 8 host bits for subnetting, you obtain 256 subnetted network IDs with 254 hosts per subnetted network ID.
Figure 1.9 Subnetting a Class B Network ID
In practice, network administrators define a maximum number of nodes they want on a single network. Recall that all nodes on a single network share all the same broadcast traffic; they reside in the same broadcast domain. Therefore, growth in the number of subnets is favored over growth in the number of hosts per subnet.
Follow these guidelines to determine the number of host bits to use for subnetting.
To determine the desired subnetting scheme, start with an existing network ID to be subnetted. The network ID to be subnetted can be a class-based network ID, a subnetted network ID, or a supernet. The existing network ID contains a series of network ID bits that are fixed and a series of host ID bits that are variable. Based on your requirements for the number of subnets and the number of hosts per subnet, choose a specific number of host bits to be used for the subnetting.
Table 1.16 shows the subnetting of a class A network ID. Based on a required number of subnets, and a maximum number of hosts per subnet, a subnetting scheme can be chosen.
Table 1.16 Subnetting a Class A Network ID
Required Number of Subnets | Number of Subnet Bits | Subnet Mask |
Number of Hosts per Subnet |
---|---|---|---|
1-2 | 1 | 255.128.0.0 or /9 | 8,388,606 |
3-4 | 2 | 255.192.0.0 or /10 | 4,194,302 |
5-8 | 3 | 255.224.0.0 or /11 | 2,097,150 |
9-16 | 4 | 255.240.0.0 or /12 | 1,048,574 |
17-32 | 5 | 255.248.0.0 or /13 | 524,286 |
33-64 | 6 | 255.252.0.0 or /14 | 262,142 |
65-128 | 7 | 255.254.0.0 or /15 | 131,070 |
129-256 | 8 | 255.255.0.0 or /16 | 65,534 |
257-512 | 9 | 255.255.128.0 or /17 | 32,766 |
513-1,024 | 10 | 255.255.192.0 or /18 | 16,382 |
1,025-2,048 | 11 | 255.255.224.0 or /19 | 8,190 |
2,049-4,096 | 12 | 255.255.240.0 or /20 | 4,094 |
4,097-8,192 | 13 | 255.255.248.0 or /21 | 2,046 |
8,193-16,384 | 14 | 255.255.252.0 or /22 | 1,022 |
16,385-32,768 | 15 | 255.255.254.0 or /23 | 510 |
32,769-65,536 | 16 | 255.255.255.0 or /24 | 254 |
65,537-131,072 | 17 | 255.255.255.128 or /25 | 126 |
131,073-262,144 | 18 | 255.255.255.192 or /26 | 62 |
262,145-524,288 | 19 | 255.255.255.224 or /27 | 30 |
524,289-1,048,576 | 20 | 255.255.255.240 or /28 | 14 |
1,048,577-2,097,152 | 21 | 255.255.255.248 or /29 | 6 |
2,097,153-4,194,304 | 22 | 255.255.255.252 or /30 | 2 |
Table 1.17 shows the subnetting of a class B network ID.
Table 1.17 Subnetting a Class B Network ID
Required Number of Subnets | Number of Subnet Bits | Subnet Mask |
Number of Hosts per Subnet |
---|---|---|---|
1-2 | 1 | 255.255.128.0 or /17 | 32,766 |
3-4 | 2 | 255.255.192.0 or /18 | 16,382 |
5-8 | 3 | 255.255.224.0 or /19 | 8,190 |
9-16 | 4 | 255.255.240.0 or /20 | 4,094 |
17-32 | 5 | 255.255.248.0 or /21 | 2,046 |
33-64 | 6 | 255.255.252.0 or /22 | 1,022 |
65-128 | 7 | 255.255.254.0 or /23 | 510 |
129-256 | 8 | 255.255.255.0 or /24 | 254 |
257-512 | 9 | 255.255.255.128 or /25 | 126 |
513-1,024 | 10 | 255.255.255.192 or /26 | 62 |
1,025-2,048 | 11 | 255.255.255.224 or /27 | 30 |
2,049-4,096 | 12 | 255.255.255.240 or /28 | 14 |
4,097-8,192 | 13 | 255.255.255.248 or /29 | 6 |
8,193-16,384 | 14 | 255.255.255.252 or /30 | 2 |
Table 1.18 shows the subnetting of a class C network ID.
Table 1.18 Subnetting a Class C Network ID
Required Number of Subnets | Number of Subnet Bits | Subnet Mask |
Number of Hosts per Subnet |
---|---|---|---|
1-2 | 1 | 255.255.255.128 or /25 | 126 |
3-4 | 2 | 255.255.255.192 or /26 | 62 |
5-8 | 3 | 255.255.255.224 or /27 | 30 |
9-16 | 4 | 255.255.255.240 or /28 | 14 |
17-32 | 5 | 255.255.255.248 or /29 | 6 |
33-64 | 6 | 255.255.255.252 or /30 | 2 |
Based on the number of host bits you use for your subnetting, you must list the new subnetted network IDs. There are two main approaches:
Either method produces the same result: the enumerated list of subnetted network IDs.
Note
There are a variety of documented shortcut techniques for subnetting. However, they only work under a specific set of constraints (for example, only up to 8 bits of a class-based network ID). The following methods described are designed to work for any subnetting situation (class-based, more than 8 bits, supernetting, variable length subnetting).
To create the enumerated list of subnetted network IDs using the binary method
For each binary representation, the bits of the network ID being subnetted are fixed to their appropriate values and the remaining host bits are set to all 0's. The host bits chosen for subnetting vary.
For example, create a 3-bit subnet of the private network ID 192.168.0.0. The subnet mask for the new subnetted network IDs is 255.255.224.0 or /19. Based on n = 3, construct a table with 8 (= 23) entries. The entry for subnet 1 is the all 0's subnet. Additional entries in the table are successive increments of the subnet bits, as shown in Table 1.19. The host bits used for subnetting are underlined.
Table 1.19 Binary Subnetting Technique for Network ID 192.168.0.0
Subnet | Binary Representation | Subnetted Network ID |
---|---|---|
1 | 11000000.10101000.00000000.00000000 | 192.168.0.0/19 |
2 | 11000000.10101000.00100000.00000000 | 192.168.32.0/19 |
3 | 11000000.10101000.01000000.00000000 | 192.168.64.0/19 |
4 | 11000000.10101000.01100000.00000000 | 192.168.96.0/19 |
5 | 11000000.10101000.10000000.00000000 | 192.168.128.0/19 |
6 | 11000000.10101000.10100000.00000000 | 192.168.160.0/19 |
7 | 11000000.10101000.11000000.00000000 | 192.168.192.0/19 |
8 | 11000000.10101000.11100000.00000000 | 192.168.224.0/19 |
To create the enumerated list of subnetted network IDs using the decimal method
N = w*16777216 + x*65536 + y*256 + z
I = 2h
W = INT(s/16777216)
X = INT((s mod(16777216))/65536)
Y = INT((s mod(65536))/256)
Z = s mod(256)
INT( ) denotes integer division, mod( ) denotes the modulus, the remainder upon division.
For example, create a 3-bit subnet of the private network ID 192.168.0.0. Based on n = 3, construct a table with 8 entries. The entry for subnet 1 is the all 0's subnet. N, the decimal representation of 192.168.0.0, is 3232235520, the result of 192*16777216 + 168*65536. Because there are 13 host bits remaining, the increment I is 213 = 8192. Additional entries in the table are successive increments of 8192 as shown in Table 1.20.
Table 1.20 Decimal Subnetting Technique for Network ID 192.168.0.0
Subnet | Decimal Representation | Subnetted Network ID |
---|---|---|
1 | 3232235520 | 192.168.0.0/19 |
2 | 3232243712 | 192.168.32.0/19 |
3 | 3232251904 | 192.168.64.0/19 |
4 | 3232260096 | 192.168.96.0/19 |
5 | 3232268288 | 192.168.128.0/19 |
6 | 3232276480 | 192.168.160.0/19 |
7 | 3232284672 | 192.168.192.0/19 |
8 | 3232292864 | 192.168.224.0/19 |
Note
RFC 950 forbade the use of the subnetted network IDs where the bits being used for subnetting are set to all 0's (the all-zeros subnet) and all 1's (the all-ones subnet). The all-zeros subnet caused problems for early routing protocols and the all-ones subnet conflicts with a special broadcast address called the all-subnets directed broadcast address.
However, RFC 1812 now permits the use of the all-zeros and all-ones subnets in a CIDR-compliant environment. CIDR-compliant environments use modern routing protocols that do not have a problem with the all-zeros subnet and the all-subnets directed broadcast is no longer relevant.
The all-zeros and all-ones subnets may cause problems for hosts or routers operating in a classful mode. Before you use the all-zeros and all-ones subnets, verify that they are supported by your hosts and routers. Windows 2000 and Windows NT support the use of the all-zeros and all-ones subnets.
Based on the enumeration of the subnetted network IDs, you must now list the valid IP addresses for new subnetted network IDs. To list each IP address individually would be too tedious. Instead, enumerate the IP addresses for each subnetted network ID by defining the range of IP addresses (the first and the last) for each subnetted network ID. There are two main approaches:
Either method produces the same result: the range of IP addresses for each subnetted network ID.
To create the range of IP addresses using the binary method
For example, the range of IP addresses for the 3 bit subnetting of 192.168.0.0 is shown in Table 1.21. The bits used for subnetting are underlined.
Table 1.21 Binary Enumeration of IP Addresses
Subnet | Binary Representation | Range of IP Addresses |
---|---|---|
1 | 11000000.10101000.00000000.00000001 - 11000000.10101000.00011111.11111110 |
192.168.0.1 - 192.168.31.254 |
2 | 11000000.10101000.00100000.00000001 - 11000000.10101000.00111111.11111110 |
192.168.32.1 - 192.168.63.254 |
3 | 11000000.10101000.01000000.00000001 - 11000000.10101000.01011111.11111110 |
192.168.64.1 - 192.168.95.254 |
4 | 11000000.10101000.01100000.00000001 - 11000000.10101000.01111111.11111110 |
192.168.96.1 - 192.168.127.254 |
5 | 11000000.10101000.10000000.00000001 - 11000000.10101000.10011111.11111110 |
192.168.128.1 - 192.168.159.254 |
6 | 11000000.10101000.10100000.00000001 - 11000000.10101000.10111111.11111110 |
192.168.160.1 - 192.168.191.254 |
7 | 11000000.10101000.11000000.00000001 - 11000000.10101000.11011111.11111110 |
192.168.192.1 - 192.168.223.254 |
8 | 11000000.10101000.11100000.00000001 - 11000000.10101000.11111111.11111110 |
192.168.224.1 - 192.168.255.254 |
To create the range of IP addresses using the decimal method
J = 2h - 2
W = INT(s/16777216)
X = INT((s mod(16777216))/65536)
Y = INT((s mod(65536))/256)
Z = s mod(256)
INT( ) denotes integer division, mod( ) denotes the modulus, the remainder upon division.
For example, the range of IP addresses for the 3-bit subnetting of 192.168.0.0 is shown in Table 1.22. The increment J is 213 - 2 = 8190.
Table 1.22 Decimal Enumeration of IP Addresses
Subnet | Decimal Representation | Range of IP Addresses |
---|---|---|
1 | 3232235521 - 3232243710 | 192.168.0.1 - 192.168.31.254 |
2 | 3232243713 - 3232251902 | 192.168.32.1 - 192.168.63.254 |
3 | 3232251905 - 3232260094 | 192.168.64.1 - 192.168.95.254 |
4 | 3232260097 - 3232268286 | 192.168.96.1 - 192.168.127.254 |
5 | 3232268289 - 3232276478 | 192.168.128.1 - 192.168.159.254 |
6 | 3232276481 - 3232284670 | 192.168.160.1 - 192.168.191.254 |
7 | 3232284673 - 3232292862 | 192.168.192.1 - 192.168.223.254 |
8 | 3232292865 - 3232301054 | 192.168.224.1 - 192.168.255.254 |