7 min read

On Classless Networks

This is the second article in a two-part series:

  1. Classful Networks
  2. Classless Networks


What are classless networks not?

  • Unsophisticated
  • Rubish

Classless Networks

Classless networks were implemented in 1993 by the Internet Engineering Task Force to supplant the classful network architecture. Two of the most important needs to address were:

  1. Slowing IPv4 address exhaustion.
  2. Slowing the growth of routing tables due to the inability to do route aggregation.

To address these goals, classless networks introduced the idea of variable-length subnet masking (VLSM). This allowed for the allotting of arbitrary-length network prefixes and allowed each network to be divided into power-of-2 sized subnets. In other words, their size was not limited to 8-bit groups that resulted in blocks of Class A, B and C addresses like the classful networking scheme. So, they can be sized according to need.

The new system does away with the importance of the first three bits of an IP address to identify a class network. Because of this, the new scheme was to be known as classless and the old system was to be known as classful. Neat!

CIDR Notation

Classless Inter-Domain Routing (CIDR) became the new method for allocating IP addresses and for IP routing. It included the routing prefix and a decimal suffix, the latter being the netmask used to determine how many addressable machines are on a particular network or subnetwork. This way of specifying an address and a suffix is now widely known as CIDR notation*.

Importantly, routing protocols were updated to carry not just the IP address but also the new decimal suffix (the subnet mask), and routers and other devices were reprogrammed to be able to understand this new notation.


What are some examples of CIDR notation?

  • 2001:db8::/32 (IPv6)
  • /16
  • 10/8

The last three are functionally equivalent.

Initially, the subnet mask was expressed as a full 32-bits dotted-decimal string like the IP address:

What we now come to know as CIDR notation was only introduced later as network engineers came to prefer the more succinct version:


What are some properties of CIDR notation?

  • The decimal number suffix is the netmask and are represented as the leading 1 bits in the network mask.
  • The number of hosts can be calculated using the following formula: 2address length − prefix length:
    • The address length is 32 for IPv4.
    • The address length is 128 for IPv6.
  • The network prefix bits are always contiguous.

A subnet mask encodes the same information as a prefix length.

Calculating Hosts from CIDR Notation

I’m only going to be working with IPv4 in these examples. Also, we’ll use the table below to help us in our calculations.

Octets/Bytes Bits Hosts
1 8 256
2 16 65,536
3 24 16,777,216
4 32 4,294,967,296

Example 1

  • There are 32 total addresses.
  • Range:
    • -
  • 32 - 2 = 30 addressable hosts.
    • Addresses that can’t be used:
      • network address.
      • broadcast address.

Calculating a CIDR range when there are less than 256 addresses is easy. Since the last octet is the only one in play, so to speak, it’s simply a matter of adding the number of addressable hosts from 1 - n, inclusive.

Example 2

  • There are 32,768 total addresses.
  • There are 32,766 addressable hosts.
  • Range:
    • -

Let’s break that down:

First, let's calculate the number of hosts.

Let's recall the forumula:

    2address length − prefix length

Since it is an IPv4 address, the address length is 32 bits.
The prefix length is the decimal suffix, 17.

    232 − 17
    = 215
    = 32,768

    Let's not forget about our friend bc!  He's here to help!
    $ bc <<< 2^15

Easy peasy lemon squeezy.

Now, onward to calculate the range.

So, we know the maximum number of hosts in the subnet is 32,768.  We need to know the
number of octets that are encompassed by the number of hosts.

The address space to calculate is not greater than 2 bytes.  That means that the number of
octets that it encompasses is just one, so we'll divide by the number of hosts in one octet.

32768 / 256 = 128
log25632768 = 128

The 4th octet is easy: 254 (remember, 255 is the broadcast address and cannot
be used for a host).
So, the 3th octet will start at 128 and add 128, which will be 255 (inclusive).

We now have our range: -

Example 3

  • There are 1,048,576 total addresses.
  • There are 1,048,574 addressable hosts.
  • Range:
    • -
232 − 12
= 220
= 1,048,576

The address space to calculate is not greater than 3 bytes.  That means that the number of
octets that it encompasses is two, so we'll divide by the number of hosts in 2 octets.

1048576 / 65535 = 16
log6553532768 = 16 -

Example 4

  • There are 67,108,864 total addresses.
  • There are 67,108,862 addressable hosts.
  • Range:
    • -
232 − 6
= 226
= 67,108,864

The address space to calculate is not greater than 4 bytes.  That means that the number of
octets that it encompasses is two, so we'll divide by the number of hosts in 3 octets.

67108864 / 16777215 = 4
log1677721567108864 = 4 -

Q. Is there a command-line tool to do this?

A. There sure is, Jack!

$ sudo apt install sipcalc
$ sipcalc
-[ipv4 :] - 0

Host address            -
Host address (decimal)  - 134217728
Host address (hex)      - 8000000
Network address         -
Network mask            -
Network mask (bits)     - 6
Network mask (hex)      - FC000000
Broadcast address       -
Cisco wildcard          -
Addresses in network    - 67108864
Network range           - -
Usable range            - -


Calculating a Supernetwork

I’ll briefly touch on how to create a supernet before we leave and all go back to our happy places. Recall that one of the needs that CIDR addresses is the growth of the routing tables because of the inability to do route aggregation with the classful networking system.

Let’s see an example of how CIDR allows us to do route aggregation and thus create supernetworks that can simply be a single entry in a routing table.

Let’s say there are 5 subnets:


How do we determine the address of the supernet? For instance, we only have IP addresses with no information about the network perfix. How do we determine that?

Let’s look at the bits they have in common. We’ll concentrate on the 3rd octet, since we can tell just at a glance that the other octets are the same and thus have the same bits in common (the last octet is just the network address).

$ for n in {198..202}; do asbits $n 2; done
1100 0110
1100 0111
1100 1000
1100 1001
1100 1010

The bits in common are the nibble highlighted in brown. And, look, it’s our old pal asbits! He is always there when you need him! That’s the mark of a true friend.

So, what is 11000000 in decimal?

There are lots of tools to do this conversion, here we’ll use Python:

$ python -c 'print(int("11000000", 2))'

It’s safe to assume the that second argument to int is the base, but you can execute the following at the cli as a sanity check: python -c "help(int)".

Append that as the third octet:

Ok, almost there. The last thing to do is determine the suffix for the CIDR notation. We can easily do this by counting the 1 bits, starting from the first octet (so, count up to the right-most 1 bit):


That would be 18. So, the final result is:

And verify it with our new friend sipcalc:

$ sipcalc
-[ipv4 :] - 0

Host address            -
Host address (decimal)  - 3232284672
Host address (hex)      - C0A8C000
Network address         -
Network mask            -
Network mask (bits)     - 18
Network mask (hex)      - FFFFC000
Broadcast address       -
Cisco wildcard          -
Addresses in network    - 16384
Network range           - -
Usable range            - -



* Invented by Phil Karn