8 Steps To Understanding IP Subnetting
8 Steps To Understanding IP Subnetting
Source: Flickr/goblinbox
Introduction
Understanding IP subnetting is a fundamental requirement for almost any
techie - whether you’re a coder, a database administrator or the CTO.
However, as simple as the concepts are, there is a general difficulty in
understanding the topic.
Here we’ll break this topic into eight simple steps and help you put the
pieces together to fully understand IP subnetting.
These steps will give you the basic information needed in order to configure
routers or understand how IP addresses are broken down and how
subnetting works. You'll also learn how to plan a basic home or small office
network.
These numbers are called IP addresses, and they have the important
function of figuring out not only the address of "things," but how
communication can occur between them. It is not enough to just have an
address. It is necessary to figure out how a message can be sent from one
address to another.
Each device on each subnet has an address that logically associates it with
the others on the same subnet. This also prevents devices on one subnet
from getting confused with hosts on the other subnet.
With the decimal system, we can represent larger and larger numbers by
tacking numbers together. So, there are single-digit numbers, like 1, double-
digit numbers, like 12, triple-digit numbers, like 105, and so on and so on.
As numbers get larger, each digit represents a progressively greater value.
There is a 1's place, a 10’s place, a 100’s place and so on.
With this number, we have a 5 in the 1’s place, a 0 in the 10’s place and a 1
in the 100’s place. Hence,
1 x 100 + 0 x 10 + 5 x 1 = 105
Binary numbering systems are based on the same concept except that
because the binary system only has two numbers, 0 and 1, it takes a lot
more groupings to represent the same number. For example, the binary
equivalent of 105 is 01101001 (actually, it would be usually written as
1101001 because just like in the decimal numbering system, leading zeros
are dropped. However, we’ll keep that first zero in place in order to explain
the next concept).
0 x 128 + 1 x 64 + 1 x 32 + 0 x 16 + 1 x 8 + 0 x 4 + 0 x 2 + 1 x 1
equals:
0 + 64 + 32 + 0 + 8 + 0 + 0 + 1 = 105
Step 3 - IP Addresses
The "IP" in IP addresses refers to the Internet Protocol, where protocol is
loosely defined as "rules of communication". Imagine using a two-way radio
in a police car. Your conversations would probably end with "over" to
indicate you are finishing a particular part of the conversation. You might
also say "over and out" when you are finished the conversation itself. These
are nothing more than the rules of talking over a two-way radio - or the
protocol.
Any one of the numbers between the dots can be between 0 and 255, so
example IP addresses include:
205.112.45.60
34.243.44.155
These numbers can also be written in binary form by taking each of the
decimal values separated by dots and converting to binary. So a number like
205.112.45.60 could be written as:
11001101.01110000.00101101.00111100
Notice that the number 127 is not included. That’s because it is used in a
special, self reflecting number called a loopback address. Think of this as an
address that says, “this is my address.” Note that only the first three classes
- A, B and C - are used by network administrators. These are the commonly
used classes. The other two, D and E, are reserved.
You define the class of an IP address by looking at its first octet value, but
the structure of an IP address for any one class is different. Each IP address
has a network address and a host address. The network part of the address
is the common address for any one network, while the host address part is
for each individual device on that network. So, if your phone number is 711-
612-1234, the area code (711) would be the common, or network,
component of the telephone system, while your individual phone number of
(612-1234) would be your host address.
If the bit is a 0, then that will be one subnet; if the bit is a 1, that would be
the second subnet. Of course, with only one borrowed bit we can only have
two possible subnets. By the same token, that also reduces the number of
hosts we can have on the network to 127 (but actually 125 useable
addresses given all zeros and all ones are not recommended addresses),
down from 255.
So how can you tell how many bits should be borrowed, or, in other words,
how many subnets we want to have on our network?
Subnet masks sound a lot scarier than they really are. All that a subnet
mask does is indicate how many bits are being “borrowed” from the host
component of an IP address. If you can’t remember anything about
subnetting, remember this concept. It is the foundation of all subnetting.
The reason a subnet mask has this name is that it literally masks out the
host bits being borrowed from the host address portion of the IP address.
In the following diagram, there is a subnet mask for a Class C address. The
subnet mask is 255.255.255.128 which, when translated into bits, indicates
which bits of the host part of the address will be used to determine the
subnet number.
Note that this combination of IP addresses and subnet masks in the charts
are written as two separate values, such as Network Address =
205.112.45.60, Mask = 255.255.255.128, or as an IP address with the
number of bits indicated as being used for the mask, like 205.112.45.60/25.
However, not all addresses are available. Some are used for special
purposes. For example, any IP address ending in 255 is a special broadcast
address.
Anyone can use a private IP address on the understanding that all traffic
using these addresses must remain local. It would not be possible, for
example, to have an email message associated with a private IP address to
move across the Internet, but it is quite reasonable to have the same private
IP address work well in the company network.
The private IP addresses that you can assign for a private network can be
from the following three blocks of the IP address space:
A typical network setup using public and private IP addresses with a subnet
mask would look like:
1. The “205” in the first octet means this IP address would normally
contain 24 bits to represent the network portion of the address. With
eight bits to an octet, the arithmetic is 3 x 8 = 24, or looking at it the
other way around, “/24” means no bits are being borrowed from the
last octet.
2. But this is “/25,” which indicates it is “borrowing” one bit from the host
portion of the address.
3. With only one bit, there can only be two unique subnets.
4. So this is the equivalent of a net mask of 255.255.255.128, where
there is a maximum of 126 host addresses addressable on each of the
two subnets.
So why did CIDR become so popular? Because it’s a much more efficient
allocator of the IP address space. Using CIDR, a network admin can carve
out a number of host addresses that’s closer to what is required than with
the class approach.
What must be appreciated about VLSM is how RIP 1 routers work. Originally,
the IP addressing scheme and RIP 1 routing protocol did not take into
consideration the ability to have different subnet masks on the same
network. When a RIP 1 router receives a packet destined for a subnet, it has
no idea of the VLSM that has been used to generate the packet address. It
just has an address to work with without any knowledge of what CIDR prefix
was originally applied - and therefore no knowledge of how many bits are
used for the network address and how many are for the host address.
A RIP 1 router would handle this by making some assumptions. If the router
has a subnet of the same network number assigned as the local interface,
then it assumes the incoming packet has the same subnet mask as the local
interface, otherwise it assumes there is no subnet involved and applies a
classful mask.
The relevance of this is that RIP1 only allows a single subnet mask, making
it impossible to get the full benefit of VLSM. You must use a newer routing
protocol like Open Shortest Path First (OSPF) or RIP2, where the network
prefix length or mask value is sent along with route advertisements from
router to router. With these in use, it is possible to use VLSM to its full
potential and have more than one subnet or sub-subnets.
IPv6 increases the IP address size from 32 bits to 128 bits. A 128-bit
number supports 2128 values, or
340,282,366,920,938,463,463,374,607,431,768,211,456 possible IP
addresses. This number is so big there is not even a name for it.
Even the text representation of IPv6 is different from that of IPv4, although
it does have a similar-looking dotted decimal look. You will see an IPv6
address written one of three ways:
Preferred
Compressed
Mixed
2001:0db8:85a3:0000:0000:8a2e:0370:7D34
2001:0db8:85a3::8a2e:0370:7D34
There are some rules to follow when doing this zero substitution. First, a
substitution can only be done on one "section," or a full 16-bit group;
second, the double colon can only be used one time in any given address.
There is one other slightly confusing consideration: a double colon
automatically suppresses neighboring leading or trailing zeros in an address.
Therefore, the above address only indicates one set of double colons as a
compressed IPv6 address even though there are two sets of zeros.