Since beginning my Microsoft networking career, creating subnets has
consistently been a source of pain for me. Anyone that knows me realizes
that I‘ve never claimed to be a rocket scientist, or advanced mathematician,
and subnets have been my albatross. It’s not that the calculations are
overly complex. Give me a calculator and a chart, and I can make subnets
all day! But there are often situations where the calculator and chart
are not available (like when taking some certification exams); and when
the pressure is on, I’ve gotten a mental block from subnets. Can you believe
that I am often called upon to teach others how to create these dreaded
subnets? So, it’s become important for me to devise an easy way to perform
the necessary calculations to serve me in pressure situations. This month,
a former student of mine with several years of experience with networks
sat me down and explained subnets in plain English—in a way that I would
like to now pass on to you.
| NOTE: |
To understand networks and subnets, some basic
number theory is required. If you understand decimal and binary number
systems, skip this section. Otherwise, read on for a short primer… |
Numbering Systems
All numbering systems work the same way.
Using the decimal system (Base-10), all numbers are represented by powers
of 10, using 0 – 9. To obtain the value 1024, you take 1000 + 20 + 4, which
may also be expressed as: (1*10^3) + (0*10^2) + (2*10^1) + (4*10^0).
| NOTE: |
The carat symbol (^) represents “raised to the
power of,” which simply means that 10^3 equals 10*10*10. |
The binary system (Base-2), allows the use of only two numbers, 0 and
1. A single 0 or 1 in binary is called a bit (binary digit), and groups
of bits create binary numbers. The binary number 1101 is expressed as (1*2^3)
+ (1*2^2) + (0*2^1) + (1*2^0).
Since computers use binary (often groups of 8-bits, called a byte),
it’s often necessary to convert between binary and decimal. To determine
the decimal equivalent of the former expression, one must merely add the
placeholders together: 8 + 4 + 0 + 1 = 13.
Networks and Subnets
Most networks today are based upon TCP/IP. Such networks, of which
the Internet is a prime example, identify individual devices on the network
(hosts) using an IP address. This address consists of four numbers, separated
by periods. The format is x.x.x.x, where x can be any number between 0
and 255. A typical IP address might appear as 192.168.1.1.
But we said computers use binary!
The decimal numbers of the IP address must be converted. Knowing that
255 is the highest possible value for any particular number in the address,
it is possible to determine that these numbers can be represented with
8 bits. Each 8-bit representation is called an octet. For example, the
decimal number 255 equals the binary number 11111111.
Easy conversions can be made using the following table:
| Base-2 |
2^7 |
2^6 |
2^5 |
2^4 |
2^3 |
2^2 |
2^1 |
2^0 |
| Base-10 |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
| Binary |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
Using 8-bits, one can determine that the binary number 11111111 equals
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 or the decimal number 255.
Thus, the IP address 192.168.1.1 equals 11000000.10101000.00000001.00000001.
In TCP/IP, addresses consist of two parts: the first portion represents
the network, and the second portion defines the actual host. Think of IP
addresses as street addresses—with the network portion identifying which
street you live on and the host portion identifying which specific house
you live in on that street. To determine the network and host portions
of the address, a subnet mask is employed. Subnet masks allow the computer
to “mask” portions of the IP address based upon bit usage.
Many are accustomed to defining networks based upon class, as defined
in the TCP/IP standards. The following chart illustrates some of the defined
classes, and their default subnet masks.
| Class |
Decimal |
Binary |
Subnet Mask |
| A |
1 – 126 |
0xxxxxxx |
255.0.0.0 |
| B |
128 – 191 |
10xxxxxx |
255.255.0.0 |
| C |
192 – 223 |
110xxxxx |
255.255.255.0 |
Class A networks are identified by the first octet, Class B networks
by the second octet, and Class C by the third. Following our example, one
can determine that 192.168.1.1 is Class C, with the default subnet mask
of 255.255.255.0. This mask is represented in binary as 11111111.11111111.11111111.00000000.
The network portion thus becomes 192.168.1, with the host being represented
by the final octet.
| NOTE: |
The IP address/subnet mask combination may also
be expressed as 192.168.1.1/24, where 24 refers to the 1-bits used in the
mask (3 sets of 8). |
In TCP/IP networking, the first IP address of a network is required
to represent that particular network (or street) and the final IP address
is required to represent a broadcast (or a message sent to every house
on the street). This means that 192.168.1.0 is our sample network address
and 192.168.1.255 is our sample broadcast address. That leaves us with
192.168.1.1 – 254 to assign to hosts on the network, for a total of 253
possible nodes. These are the defining numbers for individual devices on
the network that can interact with each other locally.
One can easily see situations where assigning networks by class can
cause problems. There are only a finite number of IP addresses available.
If a network is assigned more hosts than it needs, the unused IP addresses
are wasted. And what can you do if you’re assigned a single Class C range
of addresses, but need to create separated networks? This is when you need
subnets.
Creating subnets requires you to alter the default subnet mask by masking
additional bits. To do this, one must determine the required number of
networks, the number of hosts, and which IP address ranges belong to a
particular network. These answers are obtained using some simple formulas.
To determine the number of possible networks: take 2^x, where x is the
number of 1-bits in the subnet mask. To determine the number of possible
hosts: take 2^x – 2, where x is the number of 0-bits in the subnet mask.
You must subtract 2 when figuring the possible number of hosts, since the
first possible address is reserved for the network and the last address
is reserved for the broadcast. Your IP address range is thus defined by
the remaining possible host numbers.
Let’s say that a network designer decided that she needed to create
8 separate networks (subnets) using a single Class C network of 192.168.1.0.
To increase the number of networks available, she must borrow additional
bits from the last octet in the subnet mask. Using the formulas above,
2^3 = 8. She needs 3 more 1’s. Enter those three 1’s into the table:
| 128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
| 1 |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
The decimal value of the binary created here is 128 + 64 + 32 or 224.
The appropriate subnet mask to create these 8 networks is 255.255.255.224.
This can also be represented as 192.168.1.0/27.
She can now use the table above to determine the maximum number of hosts
that will be available to her: 2^5 – 2 = 32 – 2 = 30 hosts.
So, how can you use this information?
Common scenarios involve being confronted with an IP address and a subnet
mask, and being asked to determine what other IP addresses exist on the
same network. As many of my students so often hear when preparing for certification,
“You may see this again!”
Using the table above, you can create another simple table to guide
you in defining the starting and ending points of the subnets. Take the
decimal value represented by the final 1 of the subnet mask, and use this
as a step value—adding it all the way down the first column of the following
table.
| Network ID |
Host Range |
Broadcast |
| 0 |
1-30 |
31 |
| 32 |
33-62 |
63 |
| 64 |
65-94 |
95 |
| 96 |
95-126 |
127 |
| 128 |
129-158 |
159 |
| 160 |
161-190 |
191 |
| 192 |
193-222 |
223 |
| 224 |
225-253 |
254 |
Using 192.168.1.0/27 as our example, the range of 192.168.1.1-30 comprises
the usable host IP’s for that network, with 192.168.1.31 as the broadcast.
It would then logically follow that you could answer the following question:
Given a host address of 192.168.1.165/27, are the following IP addresses
on the same network:
| 192.168.1.150 |
No |
| 192.168.1.161 |
Yes |
| 192.168.1.190 |
Yes |
| 192.168.1.193 |
No |
Hopefully, this has made the art of creating and determining subnets
a little more understandable. With the use of simple formulas and tables
which can be created on the fly, it really doesn’t have to be that complicated.
There is no need to fear the subnet. They are, after all, there for your
safety!
|