A network mask, or ``netmask'', is used to divide an IP address into a network address and a host address. When you set up a network, the network mask must be common to all network interfaces on that network. The default network masks are 255.0.0.0 for class A, 255.255.0.0 for class B, and 255.255.255.0 for class C networks, as illustrated here:

Subnets are created by extending the network ID portion of an address by taking some bits from the host portion to create a subnet portion. The remaining bits can be used for host addresses within the subnet. The number of subnets that can be created from an m-bits long subnet address is 2^m. The number of host addresses per subnet that are available from an n-bits long host address is (2^n)-2. Unlike the subnet portion of the network address, the host portion cannot consist of all 0's or 1's. See RFC 1812 and RFC 1878 for more information.
The following figure illustrates the effect on a class B address of extending a network mask from 255.255.0.0 to 255.255.255.0:

Subnetting a class B network
This scheme creates 256 (2^8) possible subnet addresses (0 through 255) with 254 (2^8-2) host addresses (1 through 254) per subnet. In this way, you can create subnets for class A and B networks by converting the second and third octets, respectively, from host addresses to subnet addresses. Notice how the netmask changes accordingly:

The class A network 16 can now have up to 256 subnets (16.0 through 16.255). The class B network 172.16 can also have up to 256 subnets (172.16.0 through 172.16.255). While the netmask masks the network portion of the address, the broadcast address exposes the network address and hides the host portion. For example, the broadcast address for the subnet 172.16.246, with a netmask of 255.255.255.0, is 172.16.246.255.
For more information on setting netmask and broadcast addresses using the Network Configuration Manager, see ``Basic TCP/IP configuration parameters''.
For example, if an organization has a class B network, you could assign each physical network in that network a subnet number within that network. The sixteen bits for the host ID could be allocated as eight for subnet and eight for host, or nine for subnet and seven for host, and so on. Your decision would be transparent to everyone outside that organization.
A common example of subnetworking is to apply a class C type subnet mask (255.255.255.0) to a class B network. Applying this mask to a class B network provides you with 256 possible subnets, each one of which can accommodate 254 possible hosts (the host addresses 0 and 255 are not acceptable). If you know that none of your subnets will ever have more than 126 hosts but you need more than 256 but less than 513 subnets, you could decide to use nine bits for the subnet number, and seven bits for the host addresses. The appropriate mask for this would be 255.255.255.128.
Given this scheme and a network address of, for example, 131.60, the addresses of the first and last hosts on the first subnet (131.60.0.0) would be 131.60.0.1 and 131.60.0.126. The broadcast address on this subnet would be 131.60.0.127.
Partitioning a class C address is a similar process as you must take a portion of the fourth octet as the subnet address. For example, you might partition the first three (high order) bits of the fourth octet to represent the subnet, with the last five bits representing the host:

This scheme allows for up to 8 subnets of 30 hosts each, for a total of 240 hosts. The netmask for the hosts on these subnets is 255.255.255.224. The number 224 is a decimal representation of the binary octet 11100000, which masks the subnet portion of the IP address.
Possible subnets for the class C network 221.138.62.0, with associated broadcast addresses, are:
| Subnet | Hosts | Broadcast address |
|---|---|---|
| 221.138.62.0 | .1-.30 | 221.138.62.31 |
| 221.138.62.32 | .33-.62 | 221.138.62.63 |
| 221.138.62.64 | .65-.94 | 221.138.62.95 |
| 221.138.62.96 | .97-.126 | 221.138.62.127 |
| 221.138.62.128 | .129-.158 | 221.138.62.159 |
| 221.138.62.160 | .161-.190 | 221.138.62.191 |
| 221.138.62.192 | .193-.222 | 221.138.62.223 |
| 221.138.62.224 | .225-.254 | 221.138.62.255 |
Follow these steps to change from an internetwork that does not use subnets to one that is subnetted.
The following examples show network installations where subnets are (and are not) in use:
128.32.0.0 Berkeley class B network (subnetted) netmask 255.255.255.0 36.0.0.0 Stanford class A network (subnetted) netmask 255.255.0.0 10.0.0.0 Arpanet class A network (non-subnetted) netmask 255.0.0.0All of the University of California at Berkeley is assigned the network number 128.32.0.0, so that any external router only needs to know one route to reach Berkeley. Within the campus, a class C type subnet mask gives each local network a subnet number, with 254 hosts on each of the 256 possible subnets. Stanford University uses a class A network number with a class B type subnet mask, for 256 subnets of 65,534 hosts each. The Arpanet is a class A network without subnets so the default class A netmask is used.
The number of class A and B addresses that are available for allocation to new networks has been steadily diminishing over time and is now virtually exhausted. If you apply for a network number, you are likely to be assigned a set of several contiguous class C network addresses or a single subnetted class C network address. Which of these you receive will depend on the number of hosts that will exist on your network(s). The scheme that is used to implement the assignment of addresses is known as Classless Interdomain Routing (CIDR) or ``supernetting''. The details of CIDR may be found in RFC 1518 and RFC 1519. As the main purpose of CIDR is to reduce the size of the routing tables for the Internet, these documents will not usually be of interest to you unless you are a service provider or you maintain Internet routing tables on your system.