Subnets and Subnet Masks

A subnet is a division within a computer network. Some administrators of large networks need to divide their networks into subnetworks (or subnets). Subnets allow certain groups of users to share access to certain files or resources. Other administrators divide their networks in order to make the most efficient use of a relatively small address pool. Most small networks do not require subnetting. A basic introduction to subnets and subnet masks is in the paragraphs that follow. You should read this discussion only if it is up to you to subnet your network or to find out the subnet mask.

The subnet mask is a value that allows the system to determine which are the network parts and which are the host parts of an IP address. In IP addressing, there are many different subnet masks. Sometimes the first six digits of an IP address indicate the network; other times the first nine digits indicate the network. The subnet mask is the code that determines which digits indicate the network and which indicate the host.

If you belong to a large subnetted network that someone else set up, you can ask that person for the subnet mask value. If you know that your network is not subnetted, use the following table to find your subnet mask.

Remember: You should use Table 1 only if you are sure that your network is not subnetted.

Table 1. Subnet Mask Default Values According to Network Class

Network Type Left-Most Value of IP Address Subnet Mask Default
Class A 0 through 126 255.0.0.0
Class B 128 through 191 255.255.0.0
Class C 192 through 223 255.255.255.0

An IP address such as 192.168.1.2 is really a dotted decimal expression of a 32-bit binary value. In binary numbers, 192.168.1.2 is expressed as 11000000.10101000.00000001.00000010. Each set of eight numbers (0 or 1) represents eight bits of the IP address. Every IP address contains some bits that identify it as belonging to a particular network. The other bits identify a single host (such as a Network Station) along the network.

Most networks fall into one of three classes: Class A, Class B, or Class C. As Table 1 shows, the network's class can be determined by examining the first eight bits of the network's IP address. When expressed in dotted decimal notation, those first eight bits are the leftmost number of the address, the number that comes before the first dot. In Class A networks, the first eight bits are expressed in decimal as a number from 1 to 126. For Class B networks, that number ranges from 128 to 191. For Class C networks, the value of the first eight bits of the IP address ranges from 192 to 223.

The class of the network determines how much space is available for subnetting. For example, in a Class A network, the network portion of the address is only the first eight bits. In other words, the first eight bits are all that is necessary to indicate the network to which the IP address belongs. That leaves the remaining 24 bits to serve as pointers toward the subnet and the individual hosts that lie on the network. In this discussion, host means any device that has a unique IP address including Network Stations. The IP address of a Class A network is network.host.host.host. The host.host.host does not indicate three separate hosts, but rather that three eight-bit segments (or 24 bits) are required to indicate a single host on the network. Obviously, there can be only a very small number of true Class A networks. In fact, there are only 126 such networks. Most of these belong to large corporations or universities, which acquired their Class A networks in the early days of the Internet when network addresses were plentiful. All Class A network addresses are all assigned.

In a Class B network, the first 16 bits of an IP address indicate the network while the remaining 16 are available for subnetting. IP addresses that belong to Class B networks are network.network.host.host.

In a Class C network, the first 24 bits indicate the network, while only the last eight can be used for subnetting or to identify the host. IP addresses that belong to Class C networks are network.network.network.host. Class C networks are the most common type of network.

You must know more than the class of the network to determine how an IP address is deciphered. When you subnet a network, it is not always apparent what subnet a device belongs to unless you know the subnet mask. For example, given the Class C IP address 192.168.1.45, you know that the network to which the device belongs is 192.168.1.0. You can tell this by applying the simplified formula network.network.network.host. However, you do not know how the network is subnetted or to what subnet the device belongs. Additionally, the class of the network is not always apparent. The subnet mask allows you to determine all of these things.

Like IP addresses, subnet masks are 32-bit values expressed in dotted decimal notation. The subnet mask 255.255.255.0 is expressed in binary as 11111111.11111111.11111111.00000000. A binary 1 in the subnet mask indicates that the corresponding bit in the IP address is treated as part of the network address. Using Boolean algebra, if you perform an "AND" operation on the binary IP address and subnet mask, the result is the IP address of the network. In Boolean algebra, the "AND" function means that if both numbers are 1's, the result is 1. If either number is not a 1, the result is 0. For example, given the IP address 192.168.1.2 and the subnet mask 255.255.255.0, the "AND" operation is as follows:

11000000.10101000.00000001.00000010 = IP add. 192.168.1.2
11111111.11111111.11111111.00000000 = Subnet Mask 255.255.255.0
11000000.10101000.00000001.00000000 = Subnet add. 192.168.1.0.

You can think of the subnet mask as a code for deciphering what an IP address means. You can use Table 2 to determine how many subnets are indicated by specific eight-bit mask values. For example, if you see the address 192.168.1.35 and you know that the subnet mask of the Class C network to which that address belongs is 255.255.255.128, you know how to decipher the address. By using Table 2, you can say that the network address is 192.168.1.0 and that the host whose IP address ends in .35 belongs to the first of two subnets.

To put it more simply, the network address 192.168.1.0 means that devices whose addresses begin with 192.168.1 belong to the 192.168.1 network. The first 24 bits of the address indicate the network, and the last eight bits of the address indicate the subnet and host. The way that you arrived at this distinction was by applying the subnet mask. Because the subnet mask ends in 128, you know that the network is broken into two subnets. If you want to divide the Class C network 192.168.1.0 into two subnets, you should use a subnet mask of 255.255.255.128. The first 24 bits of the address indicate the network. The last eight bits of the address indicate the hosts.

Since the maximum value of each eight bits is 11111111 in binary or 255 in decimal, there are, theoretically, 255 possible hosts in the two subnets. Therefore, the theoretical number of possible hosts per subnet is 255 hosts that are divided by two subnets, or 128 hosts per subnet. You could theoretically use the IP addresses 192.168.1.0 through 192.168.1.127 for the first subnet and 198.165.1.128 through 192.168.1.255 for your second subnet. In reality, you would have to give up some of these addresses. The first and last addresses in each subnet have special values. You cannot assign the first and last addresses to any devices on the network. The first address in each subnet is the subnet address; the last address is the broadcast address. Therefore, the true range of your addresses is 192.168.1.1 to 192.168.1.126 and 192.168.1.129 to 192.168.1.254.

If you need to subnet a Class C network, the way in which you specify the last eight bits of the subnet mask determines how you divide your network. Table 2 shows the number of available subnets according to the value that is given to an eight-bit subnet mask in a Class C network.

Table 2. Subnet Mask Values For Class C Addresses

Subnet Mask Binary Value Number of Subnets Number of Hosts Per Subnet
255.255.255.0 00000000 1 254
255.255.255.128 10000000 2 126
255.255.255.192 11000000 4 62
255.255.255.224 11100000 8 30
255.255.255.240 11110000 16 14
255.255.255.248 11111000 32 6
255.255.255.252 11111100 64 2
255.255.255.254 11111110 128 0
255.255.255.255 11111111 254, Do not use on Class C networks 0

Suppose that you want to break the same Class C network into four subnets instead of two. Using Table 2, you choose the subnet mask 255.255.255.192. You can then configure a network with 248 hosts on four subnets. Since 248 hosts divided by four subnets equals 62, you could have 62 hosts on each of your four subnets. You can create a table for planning your network that looks like Table 3.

By planning ahead, you should allocate IP and mask addresses to anticipate a maximum number of controllers and Network Stations. If you do not do this and your network environment changes, you will have to reallocate your initial assignments. Then your initial devices will receive different IP addresses.

Table 3. Subnet Mask 255.255.255.192 Example

Subnet IP Address Comments
1st Subnet 192.168.1.0 Network Address (not assigned to any host)
1st Subnet 192.168.1.1 Network Station #1
1st Subnet 192.168.1.2 Network Station #2
 :  :  :
1st Subnet 192.168.1.62 Network Station #62
1st Subnet 192.168.1.63 Broadcast Address (not assigned to any host)
2nd Subnet 192.168.1.64 Network Address (not assigned to any host)
2nd Subnet 192.168.1.65 Network Station #63
2nd Subnet 192.168.1.66 Network Station #64
 :  :  :
2nd Subnet 192.168.1.126 Network Station #124
2nd Subnet 192.168.1.127 Broadcast Address (not assigned to any host)
3rd Subnet 192.168.1.128 Network Address (not assigned to any host)
3rd Subnet 192.168.1.129 Network Station #125
3rd Subnet 192.168.1.130 Network Station #126
 :  :  :
3rd Subnet 192.168.1.190 Network Station #186
3rd Subnet 192.168.1.191 Broadcast address (not assigned to any host)
4th Subnet 192.168.1.192 Network Address (not assigned to any host)
4th Subnet 192.168.1.193 Network Station #187
4th Subnet 192.168.1.194 Network Station #188
 :  :  :
4th Subnet 192.168.1.254 Network Station #248
4th Subnet 192.168.1.255 Broadcast Address (not assigned to any host)

Of course, you could assign any network device to any IP address. We simply filled the Comment section of our sample tables with "Network Station #X" by way of illustration. In reality, you must devote IP addresses to routers, Domain Name Servers, and other devices on your network.

Class C networks are not the only networks to be subnetted. Class B networks are often subnetted. The only difference in subnetting a Class B network is that the network portion of its address is shorter (and its host portion is longer) than that of a Class C address. For example, the network portion of the Class B address 192.168.0.0 is 192.168. That leaves the last 16 bits (the 0.0) free for subnetting. To divide that network into two large subnets, you would use the subnet mask 255.255.192.0. That configuration results in the two subnets 192.168.0.0 through 192.168.127.0 and 192.168. 128.0 through 192.168.254.0.

Subnets are meaningful only to hosts on your physical network. Hosts outside of your network are concerned only with the network portion of the IP address. Routers inside your network apply the subnet mask to IP addresses to determine how to deliver information packets inside the network.

For more information about subnets, refer to "Setting up subnets".