Implement IP version 4 (IPv4) addressing, subnetting, and variable-length subnet masking (VLSM)

IPv4 Addressing

IPv4 addresses are 32 bits long; like all network-level addresses, they have a network portion  and a host portion. The network portion uniquely identifies a physical or logical link and is  common to all devices attached to that link. The host portion uniquely identifies a particular device attached to the link. The 32 bits of the address comprise four octets, each of which can be represented with a decimal number between 0 and 255, with dots between the decimal representations. The 32-bit address is mapped into a dotted-decimal representation;

  • 0000101011010110010101110000011 – 10.214.87.131, each decimal octet
    representing 8 bits

An important distinction to remember when working with IPv4 addresses is that dotted decimal is just an easy way for humans to read and write IP addresses. Always remember that the router is not reading an address in terms of four octets; rather, the router sees a 32-bit binary string.

IP addresses may be analyzed using classful or classless logic, depending on the situation.
Classful logic simply means that the main class A, B, and C rules from RFC 791 are  considered. With classful addressing, class A, B, and C networks can be identified as such by their first several bits or by the range of decimal values for their first octets.

There are three sizes of networks as measured by the number of hosts: big (Class A), medium (Class B), and small (Class C). Each class A, B, or C address has two parts (when not subnetted): a network part and a host part. The size of each is implied by the class, and can be stated explicitly using the default mask for that class of network.

Rule Minimum and Maximum Decimal Range
Class A: First bit is always set to
011
00000000 = 0 

01111111 = 127

1 – 126
Class B: First bit is
always set to
101
10000000 = 128 

10111111 = 191

128 – 191
Class C: First bit is
always set to
110
11000000 = 192 

11011111 = 223

192 – 223

The address mask is a 32-bit string, one bit for each bit of the IPv4 address. As a 32-bit string, the mask can be represented in dotted-decimal format just like an IPv4 address. The address mask can be written in dotted decimal as follows;

  • Class A – 11111111000000000000000000000000 – 255.0.0.0
  • Class B – 11111111111111110000000000000000 – 255.255.0.0
  • Class C – 11111111111111111111111100000000 – 255.255.255.0

Private Addressing

Private IP addressing helps to mitigate from the problem of public IP address depletion by allowing computers that will never be directly connected to the Internet to not use public, Internet-routable addresses. For IP hosts that will purposefully have no direct Internet connectivity, you can use several reserved network numbers, as defined in RFC 1918.

Private Address Space;

Class A – 10.0.0.0 to 10.255.255.255

Class B – 172.16.0.0 to 172.31.255.255

Class C – 192.168.0.0 192.168.255.255

Subnets and Subnet Masks

Never lose sight of why network-level addresses are necessary in the first place. For routing to be accomplished, each and every data link must have a unique address; in addition, each and every host on that data link must have an address that both identifies it as a member of the network and distinguishes it from any other host on that network. As defined so far, a single Class A, B, or C address can be used only on a single data link. To build a network, separate addresses must be used for each data link so that those networks are uniquely identifiable. If a separate Class A, B, or C address were assigned to each data link, fewer than 17 million data links could be addressed before all IPv4 addresses were depleted. This approach is obviously impractical.

The only way to make Class A, B, or C addresses practical is by dividing each major address into subnetwork addresses. Remember,

  • The host portion of an IPv4 address can be used as desired.
  • The network portion of an IPv4 address is determined by the address mask assigned to that interface.

If we take the following IPv4 address, 172.24.0.0, and try and use it throughout our network we will run out of address space if we have multiple networking device, routers, and host devices. Each interface on a router is seen as been its own network. So on a link that only connects two routers, we will waste over 65000 addresses, one side of the link will have an address – 172.24.0.1/16, opposite side of the link – 172.24.0.2/16. So to overcome this wasting of address space we can subnet (lend) our host section of our address to become our network section. So instead of having 172.24.0.0/16 as our network address for the link that only connects two routers. We can borrow some subnet bits and bring our network down to a more usable, non wasteful, address – 172.24.0.1/30 (255.255.255.252). So we are only going to be using up 4 addresses but we can only use two usable addresses within that network, the other two addresses will be used for the network address and broadcast address. We will have the new network address as follows;

  • Network Address – 172.24.0.0 /30 (255.255.255.252)
  • Interface IP addresses – Router1 – 172.24.0.1 /30, Router 2 – 172.24.0.2 /30
  • Broadcast Address – 172.24.0.3 /30

The IPv4 address now has three parts: the network part, the subnet part, and the host part. The address mask is now a subnet mask, or a mask that is longer than the standard address mask.

Not all routing protocols can support subnet addresses in which the subnet bits are all zeros or all ones. The reason is that these protocols, called classful protocols, cannot differentiate between an all-zero subnet and the major network number. Classful routing protocols cannot differentiate a broadcast on the all-ones subnet from an all-subnets broadcast address (RIP version 1 and IGRP are both classful routing protocols).

VLSM Subnet

Before deploying new networks, or new parts of a network, you must give some thought to the ranges of IP addresses to be allocated. Also, when assigning subnets for different  locations, you should assign the subnets with thought for how routes could then be summarized. The general rules for choosing VLSM are;

  1. Determine the shortest prefix length required.
  2. Divide the available address block into equal-sized prefixes based on the shortest prefix
  3. Allocate the largest required subnets/prefixes from the beginning of the IP address block, leaving some equal-sized unallocated address blocks at the end of the original large address block.
  4. Choose an unallocated block that you will further subdivide by repeating the first three steps, using the shortest required prefix length for the remaining subnets.
  5. When allocating very small address blocks for use on links between routers, consider using subnets at the end of the address range. This leaves the largest consecutive blocks available in case future requirements change.

Route Summarization

Summarization reduces the amount of information that routers must process, which allows for faster convergence within the network. Summarization also restricts the size of the area that is affected by network changes by hiding detailed topology information from certain areas within the network.

Good IP address assignment practices should always consider the capabilities for route summarization. For instance, if a division of a company needs 15 subnets, an engineer needs to allocate those 15 subnets from the unused portions of the address block available to that internetwork. However, assigning subnets 10.1.101.0/24 through 10.1.115.0/24 would be a poor choice, because those do not easily summarize. Rather, allocate a range of addresses that can be easily summarized into a single route. For instance, subnets 10.1.96.0/24 through  10.1.110.0/24 can be summarized as a single 10.1.96.0/20 route, making those routes a better choice.

Best summarization practices;

  • Inclusive summary routes – A single summarized route that is as small a range of addresses as possible, while including all routes/subnets shown, and possibly including subnets that do not currently exist.
  • Exclusive summary routes – As few as possible summarized routes that include all to-besummarized address ranges, but excluding all other routes/subnets.

Finding the Best Inclusive Summary;

Octet 1 Octet 2 Octet 3 Octet 4
172.159.20.0/24 10101100 10011111 00010100 00000000
172.159.21.0/24 10101100 10011111 00010101 00000000
172.159.22.0/24 10101100 10011111 00010110 00000000
172.159.23.0/24 10101100 10011111 00010111 00000000
Inclusive Summary 10101100 10011111 00010100 00000000
Summary address will be – 172.159.20.0 /22