How IPv4 Subnet Masks Work
If you’ve ever configured a system with an IP address, you probably
noticed that you also had to assign a subnet mask. Have you ever
wondered what this parameter is? Well, now is the time to learn. To
understand how a subnet mask works, you first need to understand that
IP addresses are divided into two parts:
• Network address
• Node address
Part of an IPv4 address is used to identify the network the host
resides on. The rest uniquely identifies a particular host (node) on
the network. The key thing to remember is that every system on the
same network segment must have exactly the same numbers in the network
portion of the address. However, they each must have a unique node
portion. This is shown in Figure 15-4.
How much of the address is used for the network and how much is used
for the node is defined by the subnet mask. Default subnet masks
include the following:
255.0.0.0
255.255.0.0
255.255.255.0
Any subnet mask octet with a 255 in it identifies a portion of the IP
address that is used for the network address. Remember that the
operating system sees IP addresses in binary notation. It also sees
subnet masks in binary notation. If you have an IP address of
192.168.1.1 and a subnet mask of 255.255.255.0, the subnet mask
specifies that the first three octets of the address are network and
the last octet is node. This is shown in Figure 15-5.
IP addresses are divided into five different classes. Each address
class has its own default subnet mask. For our purposes here, we only
need to be concerned with the first three address classes:
• Class A
The decimal value of the first octet must be between 1 and
126. In a Class A address, the first octet is the network address and
the last three octets are the node address. Therefore, the default
subnet mask is 255.0.0.0. Class A allows 126 total possible networks
(that’s not a lot), but they do offer 16.7 million possible node
addresses per network (that is a lot!).
• Class B
B address, the first two octets are the network address and the last
two octets are the node address. Therefore, the default subnet mask is
255.255.0.0. Using Class B addressing allows 16,384 possible networks
with 65,534 million possible nodes each.
• Class C
The decimal value of the first octet must be between 192 and
223. In a Class C address, the first three octets are the network
address while the last octet is the node address. Therefore, the
default subnet mask is 255.255.255.0. Because so much of the address
is used for the network address, a huge number of Class C networks are
available (2,097,152 possible networks). However, only a limited
number of hosts (254 maximum) can exist on any given Class C network.
Subnet masks are sometimes noted using a type of shorthand called CIDR
notation. This is done by adding a slash (/) and the number of bits
used in the mask after the IP address (for example, 192.168.1.1/24).
The /24 parameter indicates 24 bits are used for the subnet mask,
which would be written out in longhand as 255.255.255.0. When using
CIDR notation, the number of bits used in the mask is called the
prefix.
You don’t have to use these default subnet masks. You could define a
subnet mask of 255.255.0.0 for a Class A address, for example. You can
also use only part of an octet for the network address. This is called
partial subnetting or variable-length subnet masking (VLSM). Using
VLSM, we ignore the default subnet mask boundaries and specify a
custom number of subnet mask bits. For example, suppose we defined a
subnet mask of 255.255.252.0 for hosts on our network. In addi- tion
to the first and second octets, this mask would also include the first
six of the eight bits in the third octet to be used for the network
portion of the address. In essence, bits are “stolen” from the
available node addresses to be used for network address, adding
additional subnets. This allows you to create additional networks, but
reduces the number of host addresses available on each.
For example, suppose your network is composed of four separate
physical network segments connected by routers. This network uses the
10.0.0.0 private IP addressing scheme, so you want to divide the
10.0.0.0 network into four separate networks. By default, this network
uses a Class A address (10.0.0.0). This means the first octet is used
for the network address whereas and the last three octets are used for
node addresses.
However, you can create four additional networks (subnets) by
configuring the subnet mask to include the first two bits of the
second octet in the network address to create additional networks.
Instead of using the default Class A subnet mask of
11111111.00000000.00000000.000 00000 (255.0.0.0), you would use a
subnet mask of 11111111.11000000.00000000.00000000 (255.192.0.0). Using CIDR notation,
you would specify a prefix of /10 to indicate you are using 10 bits for the subnet mask.
There are four possible values for these two bits:
• 00 = 0
• 01 = 64
• 10 = 128
• 11 = 192
This will create the four subnets shown in Table 15-1.
The important thing to remember is that for two hosts on the same
network segment to communicate, they need to have exactly the same
network address, which means they must have exactly the same subnet
mask. For example, suppose you have three systems, as shown in Figure
15-6.
Host 1 and Host 2 both have the exact same network address and subnet
mask. These two hosts can communicate on the IP network segment.
However, Host 3 uses a subnet mask of 255.255.252.0 instead of
255.255.255.0. Therefore, Host 3 has a different network address than
Host 1 and Host 2 and won’t be able to communicate with them without
the use of a network router.
LX0-104 Exam Objectives (R)
No comments:
Post a Comment