Cover V04, I01
Article
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Sidebar 1

jan95.tar


Subnetting: Networking One Piece at a Time

Chris Hare

When you apply for an IP address for your network, you will be assigned a Class C address unless you have some very exceptional circumstances. This is appropriate for many small organizations, but it creates a problem for organizations that need more than one network, but do not meet the requirements for a class A or class B network. The solution to the problem is to divide the assigned class C subnet into smaller networks by altering the netmask. While this may sound easy, it can in fact get quite complicated. This article gives you a framework for planning a subnet for a class C network.

A, B, and C Network Addresses

An IP address consists of four bytes, or octets. In each of the network address schemes, an IP address is divided into two portions: the network portion and the host portion. These portions differ for each of the three networks,

The first number in the IP address identifies the network class the address belongs to. A class A address has a range of 1 to 126. In binary, the first bit of the first octet is zero, as shown in Figure 1. This means that the first bit identifies the address class, and the remaining seven bits of the first octet identify the network. The remaining 24 bits can be used to identify the host. Because the first bit is zero, there are fewer than 128 class A networks, but each network can contain literally millions of hosts. However, Class A addresses are typically used to create a larger network of small networks through the use of subnets. Creating a subnet using a Class A address is very easy. A potential network is illustrated in Figure 2.

If the first two bits of the IP address consist of 1 0, then it is a class B address, which establishes the address range of 128 to 191. The address format for a class B address is illustrated in Figure 3. In a class B network, the first two bits identify the class of network, the next fourteen bits identify the network itself, and the last sixteen bits identify the host. There are thousands of class B networks available, and each network can contain thousands of hosts. Class B networks are predominantly used by universities and some Internet Service Providers. A sample class B network is shown in Figure 4.

For a class C network, the first three bits of the IP address consist of 1 1 0, as shown in Figure 5. Here the first three bits are class identifiers, the next 21 bits are the network address, and the last eight bits identify the host. This combination calls for millions of class C network addresses, where each network is composed of fewer than 254 hosts. The typical Class C network is shown in Figure 6.

IP addresses are generally expressed in dotted decimal notation, as, for example, 16.0.1.12. Each number represents a byte in the address. Alternatively, the address can be expressed as a single hexadecimal number -- 16.0.1.12 would be expressed as 0x100010C.

Splitting a Class C Network

Splitting a class C network is much more difficult than splitting a class A or B network. The level of difficulty derives from the fact that there are only eight bits to manipulate in the host address portion fo a class C address, while in a class A network there are 24 bits, and in a class B network, 16 bits. Given that eight-bit limitation, the only effective way to alter the number of bits in a class C network address is by creating subnets. To show exactly how and where the splitting occurs, I'll refer to the separate octets by the following syntax:

N -- is the first octet

O -- the second octet

P -- the third octet

Q -- the last octet

In a standard class C network, the network portion of the address consists of N.O.P. This is a constant, and is the same for each host on the network. The last octet, Q, must be different for each host. It is this value that must be split in order to create subnets.

An eight-bit number allows the representation of 256 possible values -- from 0 (all bits off) to 255 (all bits on). As referenced in the Internet Request For Comments RFC 950, the values of all zeros and all ones must not be used for a host address.

Subdividing a class C network requires using some of the bits in the host portion of the address as part of the network portion. While this increases the number of possible networks, it decreases the number of hosts that can be on each subnet.

The Internet RFC 950 also requires that the first and last division of each subnet be reserved. This means that the actual number of usable subnets is two less than the total number of divisions. For example, if you want to split your class C network into two divisions, you cannot connect any hosts! If you want to have six subnets, then you must split your network into eight divisions.

Figure 7 illustrates how the bits in the last octet are set, and how many subnets and hosts can be created for each. As the figure shows, what is effectively available is a minimum of 4 divisions with 2 subnets and 62 hosts per net, or a maximum of 64 divisions with 62 subnets of 2 hosts each. The minimum could be used for two separate ethernet networks, while the maximum could be used for a series of point-to-point protocol links.

The optimal subnet type is determined by the maximum number of users that will be required on any subnet and the minimum number of subnets required. In a recent example, I was involved in revising the network for a technical services department from one network to three. To accomplish this, we decided to create eight divisions, which resulted in six subnets, each with 30 hosts. The following sections outline the steps and changes required to create a network of this type.

Changing the Network

Referring again to Figure 7, you can see that splitting a class C address into eight divisions, or six subnets, requires that the first three bits in the last octet be fixed. The network portions for the division are formed through the evaluation of the non-fixed portion of the last byte. Figure 8 lists the bit combinations and illustrates how the class C address is split into subnets. The top three bits -- 8, 7, and 6 -- are fixed in that they are used as part of the host address. This means that the available networks become

Network
N.O.P.32
N.O.P.64
N.O.P.96
N.O.P.128
N.O.P.160
N.O.P.192

The network entries consisting of all zeros and all ones are disallowed, so these network subnets cannot be used. With the address ranges of the networks established, the next step is to determine the broadcast addresses for each of the networks. The network portion of the last byte is ignored, and all of the remaining bits are set to one. The resulting broadcast address for each network is N.O.P.31. There is only one bradcast address in this case, because all of the subnets share the same number of bits for the host portion of the address.

With the network portions for the subnets and the corresponding broadcast addresses determined, what remains is the netmask. The subnet is interpreted through the netmask, or subnet mask. If the bit is on in the netmask, that equivalent bit in the address is interpreted as a network bit. If the bit is off, then the bit is considered part of the host address. It is important to note that the subnet is known only locally: to the rest of the Internet, the address looks like a standard IP address.

The standard netmask for a class C address is 255.255.255.0. For our subnetted network, the first three bytes remain the same. The fourth byte is created by setting the network portion to ones, and the host portion to zero. Looking back at Figure 8, you can see what the network addresses will be; the same format is used for determining the netmask. This means that the netmasks for these subnets are:

NetworkBroadcastNetmask

N.O.P.32	N.O.P.31	255.255.255.32
N.O.P.64	N.O.P.63	255.255.255.64
N.O.P.96	N.O.P.95	255.255.255.96
N.O.P.128	N.O.P.127	255.255.255.128
N.O.P.160	N.O.P.159	255.255.255.160
N.O.P.192	N.O.P.191	255.255.255.192

Allocating IP Addresses

With the network split into subnets, the next step is allocating IP addresses. The range of addresses available is determined through the following formula:

The lowest host address is the network portion of the fourth byte with the host portion set to one. The value of zero in the host portion is reserved.

The highest host address is the network portion of the fourth byte with the host portion set to all ones except for the last bit (the maximum value is reserved for the broadcast address).

The allocation of addresses for the sample network is illustrated in Figure 9.

Summary

The task of splitting an already established class C network into subnets must be carefully planned and executed. The danger here is that you may wind up with a system where no one will be able to talk to anyone else. As a precautionary measure, you might install a router to split the network into the desired number of subnets, then renumber them in segments. This allows the hosts on one network to communicate amongst themselves while the others are being renumbered, with the router handling the network traffic between them.

About the Author

Chris Hare is the Operations Manager for i*internet Inc., a Canadian Internet Service provider. He has worked in the UNIX environment since 1986, and in 1988 became the first SCO Authorized Instructor in Canada. He is a co-auther of the book Inside UNIX, and he is currently focused on networking, security, and perl.