IPv4 Addressing and Subnetting
IPv4 Addressing and Subnetting
IPv4
The IP version currently being used on the Internet
Class A, B, C, D, and E
The five classes of IPv4
Note
The 0.0.0.0 and 127.x.x.x addresses are special-purpose addresses. The 0.0.0.0 IP
address refers to the source host on this network. The 127.x.x.x addresses are used
as the Internet loopback address. A datagram sent by a higher-level protocol to an
address anywhere within this block should loop back inside the host. The most
common loopback address used is 127.0.0.1. The 127.x.x.x addresses should never
appear on the network.
Each IP address consists of four 8-bit octets, providing a total binary data length of 32 bits.
Figure 6-12 shows the 32-bit structure for the IP address. Each octet in the IP address is
expressed in terms of its decimal equivalent. The decimal equivalent representation of the
four octets shown in Figure 6-12 is 10.10.20.1. Table 6-8 provides the breakdown for
determining each octet in decimal and binary.
FIGURE 6-13 The octets making up the network and host portions of the IPv4 address
for classes A, B, and C.
Private IP Addresses
Address ranges in class A, B, and C have been set aside for private use. These addresses,
called private addresses, are not used for Internet data traffic but are intended to be used
specifically on internal networks called intranets. Table 6-11 lists the private address
ranges.
IP Address Assignment
IP address allocation is governed by the Internet Assigned Number Authority (IANA). To
coordinate the global effort of IP allocation more effectively, IANA delegates the
allocation to the regional Internet registries (RIRs), each of which is responsible for a
different area. The five RIRs accounting for the different regions of the world are as
follows:
• AfriNIC: Africa Region
• APNIC: Asia/Pacific Region
RIRs
Regional Internet registries, IANA-designated governing organizations
responsible for IP address allocation by geographical location
ARIN
American Registry for Internet Numbers
ARIN also assigns end users IP addresses. Once again, the end user must qualify to
receive a block of addresses from ARIN. This usually means that the end user must be
large. For example, many universities and large businesses can receive a block of IP
addresses from ARIN. However, most end users will get their IP addresses from an ISP
(for example, Telco) or have IP addresses assigned dynamically when they connect to the
ISP.
Section 6-4 Review
This section has covered the following Network+ Exam objectives.
1.8 Given a scenario, implement and configure the appropriate addressing
schema
The classes of IP addresses were presented in Table 6-7. Make sure you can identify
the class for each range of addresses. This section also listed the ranges for private
IP addresses in Table 6-11.
Test Your Knowledge
1. The home IP address for a network is assigned by which of these?
a. ARIN, the association of Registered Internet Numbers
b. ARIN, the American Registry for Internet Names
c. ARIN, the American Registry for Internet Numbers
d. ARNN, the American Registry for Internet Names and Numbers
2. The IP address 192.168.20.5 is an example of what? (Select all that apply.)
a. Class C IP address
b. Class B IP address
c. Class A IP address
d. A private IP address
Subnet Mask
Identifies the network/subnet portion of an IP address
Subnets are created by borrowing bits from the host portion of the IP address. This is
shown in Figure 6-14. The network portion of the IP address and the new subnet bits are
used to define the new subnet. Routers use this information to properly forward data
packets to the proper subnet. The class C network shown in Figure 6-15 is partitioned into
four subnets. It takes 2 bits to provide four possible subnets; therefore, 2 bits are borrowed
from the host bits. This means the process of creating the 4 subnets reduces the number of
bits available for host IP addresses.
FIGURE 6-14 Borrowing bits from the host to create subnets.
FIGURE 6-16 The breakdown of the IP address to allow for the creation of four
subnets.
The equations for calculating the number of subnets created and the number of
hosts/subnet are provided in Equations 6-1 and 6-2.
where x = # of bits borrowed from the host bits
y = # host bits for the class of network
(A = 24, B = 16, C = 8)
Breaking down the 192.168.12.0 network into four subnets requires borrowing two host
bits. Therefore, x = 2, and because this is a class C network, y = 8.
x = 2 (the number of bits used from the host)
y = 8 (number of bits for a class C network)
Applying these values to equation 6-2 yields
The number of subnets created = 2x = 2(2) = 4
The number of hosts/subnet = 2(y - x) = 2(8 - 2) = 64
When creating subnets, it is important to note that each subnet will have both a network
and a broadcast address. Taking this into consideration, the equations for calculating the
number of hosts/subnet are modified to account for the number of usable hosts/subnet.
The modified equations are as follows:
The number of usable hosts/subnet = 2(y - x) – 2 [Equation 6-3]
The next step is to determine the subnet mask required for creating the four subnets.
Recall that creating the four subnets required borrowing 2 host bits. The two most
significant bit (MSB) positions, borrowed from the host and network portion of the IP
address, must be included in the subnet mask selection. The purpose of the subnet mask is
to specify the bit positions used to identify the network and subnet bits. Applying the
subnet mask is basically a logical AND operation. Setting the subnet mask bit position to a
1 enables the bit value from the IP address to pass. Setting the subnet mask bit value to 0
disables the IP address from appearing on the output. This is shown in the truth table for a
logical AND operation:
Notice that when the subnet mask bit is set to 0, the output is forced to 0. When the subnet
mask bit is set to 1, the output follows the IP address bit.
The subnet mask consists of bit position values set to either a 1 or a 0. A bit position set to
a 1 indicates that the bit position is used to identify a network or subnet bit. The subnet
mask for identifying the class C network 192.168.12.0 will be 255.255.255.x. This
conversion is shown next.
The subnet mask also identifies the subnet bits. The two MSBs were borrowed from the
host bits; therefore, the last octet of the subnet mask will be
where the 1 indicates this place is used for the subnet mask and the x means that the place
value is left for the host address. Summing the two bit position values that have a 1 yields
128 + 64 = 192. The 192 is placed in the last octet of the subnet mask. The complete
subnet mask is 255.255.255.192.
The two subnet bits create four subnets, and each subnet has its own network address. The
network addresses are used to route data packets to the correct subnet. Table 6-12 shows
the four subnet addresses listed in both binary and decimal format.
TABLE 6-12 Binary and Decimal Equivalents for the Subnet’s Network Address
(Note: The six host bits are all set at 0 in a subnet’s network address.)
Each subnet will also have its own broadcast address. The broadcast address for the subnet
is used to broadcast packets to all hosts in the subnet. (Note: All host bits are set to 1 for a
broadcast.) Table 6-13 shows the binary and decimal equivalents for the subnet’s
broadcast address.
TABLE 6-13 Binary and Decimal Equivalents for the Subnet’s Broadcast Address
Given this information, the network and broadcast address can be defined for the four
subnets of the 192.168.12.0 network. Table 6-14 provides these addresses for the four
subnets.
TABLE 6-14 Network and Broadcast Addresses for the Four Subnets of the
192.168.12.0 Network
The same technique for subnet masking can be applied to class A, B, or C addresses. The
following examples demonstrate subnet mask selection in a network.
Example 6-8
Given a network address of 10.0.0.0, divide the network into 8 subnets. Specify the
subnet mask, the network and broadcast addresses, and the number of usable
hosts/subnet.
Solution:
Creating 8 subnets requires borrowing 3 host bits; therefore, x = 3. This is a class A
network, so y = 24.
Using Equation 6-1, the number of subnets = 23 = 8.
Using Equation 6-3, the number of usable hosts = 2(24-3) – 2 = 2097150
The 8 subnets will be:
Therefore, the network and broadcast addresses for the 8 subnets will be
The 224 in Example 6-8 comes from setting the subnet mask to select the three MSB
positions in the host portion of the address, as shown in Figure 6-17.
FIGURE 6-17 The network, subnet, and host bit positions for creating the eight
subnets in Example 6-8.
Another way to look at selecting a subnet mask is by specifying how many usable hosts
are available to be assigned in a subnet. For example, assume that 62 usable host addresses
are to be available in a subnet. Assume this is for a class C network. Using Equation 6-2,
62 = 2(8-x) – 2
64 = 2(8-x)
Using logarithms to solve for x:
log 64 = (8–x) (log 2)
log 64/(log 2) = 8–x
6 = 8–x therefore, x = 2
Instead of using logarithms, a table such as that shown in Table 6-15 can be used.
Example 6-9 shows how the table can be used to determine the subnet mask.
TABLE 6-15 Number of Bits Borrowed to Create a Specific Number of Usable Hosts
Example 6-9
Determine the subnet mask required for the router-to-router link shown in Figure 6-
18 if only two host addresses are required for this link.
FIGURE 6-18 Setting a subnet mask for a router-to-router link that provides two host
addresses.
Solution:
Using Table 6-15 to determine the number of host bits borrowed for creating a
subnet with two usable hosts, we find that 14 host bits are borrowed for this class B
network. This means the first 3 octets plus the 6 MSB positions of the fourth octet
will be used to create the subnet mask. The decimal equivalent for the 6 MSB bit
positions is 128 + 64 + 32 + 16 + 8 + 4 = 252.
Computers use the subnet mask to control data flow within networks. Computers in a
LAN use a subnet mask to determine whether the destination IP address is intended for a
host in the same LAN or if the data packet should be sent to the gateway IP address of the
LAN. The gateway IP address is typically the physical network interface on a layer 3
switch or a router.
For example, assume that the IP address of the computer in the LAN is 172.16.35.3. A
subnet mask of 255.255.255.0 is being used. This means that all data packets with an IP
address between 172.16.35.0 and 172.16.35.255 stay in the LAN. A data packet with a
destination IP address of 172.16.34.15 is sent to the LAN gateway. The 255.255.255.0
subnet mask indicates that all bits in the first three octets must match each other to stay in
this LAN.
This can be verified by “ANDing” the subnet mask with the destination address as shown:
172.16.35.3
255.255.255.0
172.16.35.0 is in the same LAN subnet sent to the gateway
172.16.34.15
255.255.255.0
176.16.34.0 not in the same subnet as the LAN
This section has demonstrated techniques for establishing subnets and subnet masks in
computer networks. Examples have been presented that guide the reader through the
process of borrowing bits to determine the number of available hosts in the subnet. The
next section examines the concepts of expanding the subnet IP address range past the class
boundaries using CIDR blocks.