Because a Class B network has 16 bits for host addresses, you have plenty of available bits to play with when figuring out a subnet mask. Remember that you have to start with the leftmost bit and work toward the right. For example, a Class B network would look like x.y.0.0, with the default mask of 255.255.0.0. Using the default mask would give you one network with 65,534 hosts.
The default mask in binary is 11111111.11111111.00000000.00000000. The 1s represent the corresponding network bits in the IP address, and the 0s represent the host bits. When you’re creating a subnet mask, the leftmost bit(s) will be borrowed from the host bits (0s will be turned into 1s) to become the subnet mask. You then use the remaining bits that are still set to 0 for host addresses.
If you use only 1 bit to create a subnet mask, you have a mask of 255.255.128.0. If you use 2 bits, you have a mask of 255.255.192.0, or 11111111.11111111.11000000.00000000.
As with subnetting a Class C address, you now have three parts of the IP address: the network address, the subnet address, and the host address. You figure out the subnet mask numbers the same way as you did with a Class C network (see the previous section, “Calculating Values for an Eight- Subnet Class C Network”), but you’ll end up with a lot more hosts per subnet.
There are four subnets, because 22 = 4. The valid third- octet values for the subnets are 0, 64, 128, and 192 (256 – 192 = 64, so the incremental value of the third octet is 64). However, there are 14 bits (0s) left over for host addressing. This gives you 16,382 hosts per subnet (214 – 2 = 16,382).
The valid subnets and hosts are as follows:
Subnet Hosts Broadcast
x.y.0.0 x.y.0.1 through x.y. 63.254 x.y.63.255
x.y.64.0 x.y.64.1 through x.y.127.254 x.y.127.255
x.y.128.0 x.y.128.1 through x.y.191.254 x.y.191.255
x.y.192.0 x.y.192.1 through x.y.255.254 x.y.255.255
You can add another bit to the subnet mask, making it 11111111.11111111.1110000 0.00000000, or 255.255.224.0. This gives you eight subnets (23 = 8) and 8,190 hosts. The valid subnets are 0, 32, 64, 96, 128, 160, 192, and 224 (256 – 224 = 32). The subnets, valid hosts, and broadcasts are listed here:
Subnet Hosts Broadcast
x.y.0.0 x.y.0.1 through x.y.31.254 x.y.31.255
x.y.32.0 x.y.32.1 through x.y.63.254 x.y.63.255
x.y.64.0 x.y.64.1 through x.y.95.254 x.y.95.255
x.y.96.0 x.y.96.1 through x.y.127.254 x.y.127.255
x.y.128.0 x.y.128.1 through x.y.159.254 x.y.159.255
x.y.160.0 x.y.160.1 through x.y.191.254 x.y.191.255
x.y.192.0 x.y.192.1 through x.y.223.254 x.y.223.255
x.y.224.0 x.y.224.1 through x.y.255.254 x.y.255.255
The following are the breakdowns for a 9- bit mask and a 14- bit mask:
■ If you use 9 bits for the mask, it gives you 512 subnets (29). With only 7 bits for hosts, you still have 126 hosts per subnet (27 – 2 = 126). The mask looks like this:
11111111.11111111.11111111.10000000, or 255.255.255.128
■ If you use 14 bits for the subnet mask, you get 16,384 subnets (214) but only two hosts per subnet (22 – 2 = 2). The subnet mask would look like this:
11111111.11111111.11111111.11111100, or 255.255.255.252
Subnet Mask Use in an ISP |
You may be wondering why you would use a 14- bit subnet mask with a Class B address. This approach is actually very common. Let’s say you have a Class B network and use a subnet mask of 255.255.255.0. You’d have 256 subnets and 254 hosts per subnet. Imagine also that you are an Internet service provider (ISP) and have a network with many WAN links, a different one between you and each customer. Typically, you’d have a direct connection between each site. Each of these links must be on its own subnet or network. There will be two hosts on these subnets— one address for each router port. If you used the mask described earlier (255.255.255.0), you would waste 252 host addresses per subnet. But by using the 255.255.255.252 subnet mask, you have more subnets available, which means more customers—e ach subnet with only two hosts, which is the maximum allowed on a point- to- point circuit. You can use the 255.255.255.252 subnet mask only if you are running a routing algorithm such as Enhanced Interior Gateway Routing Protocol (EIGRP) or Open Shortest Path First (OSPF). These routing protocols allow what is called Variable Length Subnet Masking (VLSM). VLSM allows you to run the 255.255.255.252 subnet mask on your interfaces to the WANs and run 255.255.255.0 on your router interfaces in your local area network (LAN) using the same classful network address for all subnets. It works because these routing protocols transmit the subnet mask information in the update packets that they send to the other routers. Classful routing protocols, such as RIP version 1, don’t transmit the subnet mask and therefore cannot employ VLSM. |
Subnetting Class A
Class A networks have even more bits available than Class B and Class C networks.
A default Class A network subnet mask is only 8 bits, or 255.0.0.0, giving you a whopping 24 bits for hosts to play with. Knowing which hosts and subnets are valid is a lot more complicated than it was for either Class B or Class C networks.
If you use a mask of 11111111.1111111.00000000.00000000, or 255.255.0.0, you’ll have 8 bits for subnets, or 256 subnets (28). This leaves 16 bits for hosts, or 65,534 hosts per subnet (216 – 2 = 65534).
If you split the 24 bits evenly between subnets and hosts, you would give each one
12 bits. The mask would look like this: 11111111.11111111.11110000.00000000, or 255.255.240.0. How many valid subnets and hosts would you have? The answer is 4,096 subnets each with 4,094 hosts (212 – 2 = 4,094).
The second octet will be somewhere between 0 and 255. However, you will need to figure out the third octet. Because the third octet has a 240 mask, you get 16 (256 – 240 = 16) as your incremental value in the third octet. The third octet must start with 0 for the first subnet, the second subnet will have 16 in the third octet, and so on. This means that some of your valid subnets are as follows (not in order):
Subnet Hosts Broadcast
x.0- 255.0.0 x.0- 255.0.1 through x.0- 255.15.254 x.0- 255.15.255
x.0- 255.16.0 x.0- 255.16.1 through x.0- 255.31.254 x.0- 255.31.255
x.0- 255.32.0 x.0- 255.32.1 through x.0- 255.47.254 x.0- 255.47.255
x.0- 255.48.0 x.0- 255.48.1 through x.0- 255.63.254 x.0- 255.63.255
They go on in this way for the remaining third- octet values through 224 in the subnet column.
Working with Classless Inter- Domain Routing
Microsoft uses an alternate way to write address ranges, called Classless Inter- Domain Routing (CIDR; pronounced “cider”). CIDR is a shorthand version of the subnet mask. For example, an address of 131.107.2.0 with a subnet mask of 255.255.255.0 is listed in CIDR as 131.107.2.0/24 because the subnet mask contains 24 1s. An address listed as 141.10.32.0/19 would have a subnet mask of 255.255.224.0, or 19 1s (the default subnet mask for Class B plus 3 bits). This is the nomenclature used in all Microsoft exams (see Figure 4.12).
FIGURE 4.12 Subnet mask represented by 1s
Subnet mask in binary: 1111 1111. 1111 1111. 111 1 1111 . 0000 0000
Subnet mask in decimal: 255 . 255 . 255 . 0
(The spaces in the above example are only for illustrative purposes.
The subnet mask in decimal would actually appear as 255.255.255.0.)
Let’s say an Internet company has assigned you the following Class C address and CIDR number: 192.168.10.0/24. This represents the Class C address of 192.168.10.0 and a subnet mask of 255.255.255.0.
Again, CIDR represents the number of 1s turned on in a subnet mask. For example, a CIDR number of /16 stands for 255.255.0.0 (11111111.11111111.00000000.00000000).
The following is a list of all of the CIDR numbers (starting with a Class A default subnet mask) and their corresponding subnet masks:
CIDR | Mask | CIDR | Mask | CIDR | Mask |
/8 | 255.0.0.0 | /17 | 255.255.128.0 | /25 | 255.255.255.128 |
/9 | 255.128.0.0 | /18 | 255.255.192.0 | /26 | 255.255.255.192 |
/10 | 255.192.0.0 | /19 | 255.255.224.0 | /27 | 255.255.255.224 |
/11 | 255.224.0.0 | /20 | 255.255.240.0 | /28 | 255.255.255.240 |
/12 | 255.240.0.0 | /21 | 255.255.248.0 | /29 | 255.255.255.248 |
/13 | 255.248.0.0 | /22 | 255.255.252.0 | /30 | 255.255.255.252 |
/14 | 255.252.0.0 | /23 | 255.255.254.0 | /31 | 255.255.255.254 |
/15 | 255.254.0.0 | /24 | 255.255.255.0 | /32 | 255.255.255.255 |
/16 255.255.0.0