CIDR Notation – Explained & Examples

CIDR (Classless Inter-Domain Routing) notation is a compact method for specifying IP addresses and their routing suffixes.

For example, we can express the idea that the IP address 192.168.0.1 is associated with the netmask 255.255.255.0 by using the CIDR notation of 192.168.0.1/24, where 24 represents the number of network bits in the IP address (IPv4 address has 32 bits, so the network can be between 0 and 32).

CIDR Notation

CIDR allows subnet masks of variable length – it has replaced the previous system based on fixed-size network classes and gained popularity due to its flexibility and efficiency.

CIDR notation: In IPv4, what is now called CIDR notation came into wide use only after the implementation of CIDR. The original CIDR standards used a dotted-decimal subnet mask after the slash, e.g 192.168.0.1/255.255.255.0. Describing the network prefix’s width as a single number, e.g. 192.168.0.1/24 became incorporated into later standards documents.

The initial goal of CIDR was to slow the increase of routing tables on routers across the internet and decrease the rapid exhaustion of IPv4 addresses.

Before CIDR, IP addresses were divided into general fixed-size classes where the first part of the IP address represented the network address (of 816 or 24 bits) and the latter part represented the host address.

Exhaustion of the Class B network address space. One fundamental cause of this problem is the lack of a network class of a size which is appropriate for mid-sized organization; Class C, with a maximum of 254 host addresses, is too small, while Class B, which allows up to 65534 addresses, is too large for most organizations.
RFC 1519

Note, that if you want to create subnets (especially flexible subnets), it is not enough to simply attach the same suffix to the IP address, for example 192.168.200.5/30 and 192.168.200.9/30 do not belong to the same network:

Address:   192.168.200.5         11000000.10101000.11001000.00000101
Netmask:   255.255.255.252 = 30  11111111.11111111.11111111.11111100
Network:   192.168.200.4/30      11000000.10101000.11001000.00000100
Broadcast: 192.168.200.7         11000000.10101000.11001000.00000111
HostMin:   192.168.200.5         11000000.10101000.11001000.00000101
HostMax:   192.168.200.6         11000000.10101000.11001000.00000110
Hosts/Net: 2

Address:   192.168.200.8         11000000.10101000.11001000.00001000
Netmask:   255.255.255.252 = 30  11111111.11111111.11111111.11111100
Network:   192.168.200.8/30      11000000.10101000.11001000.00001000
Broadcast: 192.168.200.11        11000000.10101000.11001000.00001011
HostMin:   192.168.200.9         11000000.10101000.11001000.00001001
HostMax:   192.168.200.10        11000000.10101000.11001000.00001010
Hosts/Net: 2

Both addresses are therefore not in the same network, but they would have been, however, if the second address had been 192.168.200.6/30:

Address:   192.168.200.6         11000000.10101000.11001000.00000110
Netmask:   255.255.255.252 = 30  11111111.11111111.11111111.11111100
Network:   192.168.200.4/30      11000000.10101000.11001000.00000100
Broadcast: 192.168.200.7         11000000.10101000.11001000.00000111
HostMin:   192.168.200.5         11000000.10101000.11001000.00000101
HostMax:   192.168.200.6         11000000.10101000.11001000.00000110
Hosts/Net: 2

Glossary

What is an IP Address?

InterNIC: IP addresses are allocated to the organizations that administrate computer networks based on TCP/IP protocol by the InterNIC – the organization that administrates the Internet.

An IP (Internet Protocol) address is a 32-bit number that uniquely identifies a host on a TCP/IP network.

It is typically shown as 4 octets of numbers from 0-255 represented in decimal form, e.g. the IP address: 192.168.1.100 in binary form is 11000000.10101000.00000001.01100100.

The IP address consists of two parts: a network ID (the network segment to which the host belongs to) and a host ID (an individual host on some specific network segment).

The length of the these parts is not fixed and depends on a subnet mask.

IP Type Range Addresses CIDR
IPv4 from 0.0.0.0 to 255.255.255.255 232 0.0.0.0/0

What is a Subnet Mask (or Netmask)?

Routers & Subnets: Routers use subnet masks to route data packets to the right subnet. It reads the network ID for a packet’s destination address and determines whether that packet should remain on the current subnet or be routed to a different subnet. When a router delivers a packet to the correct subnet, it uses then the host ID portion of the destination address to deliver the packet to its final destination.

A subnet mask is used to divide an IP address into the network and host addresses.

It is a 32-bit number created by setting host bits to all 0s and network bits to all 1s.

For example, 192.168.0.1/255.255.255.0 (the same as 192.168.0.1/24 in CIDR notation):

11000000.10101000.00000001.01100100 - IP address (192.168.1.100)
11111111.11111111.11111111.00000000 - Subnet mask (255.255.255.0)

The first 24 bits of 1s in the subnet mask are identified as the network address part, while the last 8 bits of 0s are identified as the host address, that gives us the following addresses:

11000000.10101000.00000001.00000000 - Network address (192.168.1.0)
11111111.11111111.11111111.01100100 - Host address (0.0.0.100)

So in this example, the subnet mask 255.255.255.0 divides the IP address 192.168.0.1, into the network ID 192.168.1.0 and the host address 0.0.0.100.

When a packet arrives on the 192.168.1.0 subnet the router then will use the host ID portion of the destination address i.e. 0.0.0.100 to deliver the packet to its final destination.

Info: The 255 address is always assigned to a broadcast address, and the 0 address is always assigned to a network address. Neither can be assigned to hosts, as they are reserved for these special purposes.

What is a Subnet?

The process of dividing a network into smaller network sections is called subnetting.

This can be useful for many different purposes and helps isolate groups of hosts from each other to deal with them more easily.

Through subnetting, a network traffic can travel a shorter distance without passing through unnecessary routers to reach its destination.

What is an IP Routing?

Info: A host can communicate directly with other hosts only on the same subnet. To communicate with the hosts on another subnets, it must use a router.

IP Routing is the process of determining the path for data to follow across multiple networks from its source to its destination.

When a router receives a packet, it reads its header to see the destination IP and refers to its internal routing table to determine the next hop address.

The next router repeats the process using its own routing table until the packet reaches its destination.

What are the Network Classes?

Network Classes: IPv4 network classes have been deprecated and replaced with CIDR since the publication of RFC 1519 in 1993.

Before the introduction of CIDR in 1993, all the IP addresses had been divided into five classes based on the leading four address bits.

Classes A, B, and C had provided unicast addresses for networks of three different network sizes, class D had been for multicast networking and the class E address range had been reserved for future or experimental purposes.

Network Class Range Addr. per Net. Netmask CIDR
Class A 0.0.0.0 → 127.255.255.255 16,777,216 (224) 255.0.0.0 /8
Class B 128.0.0.0 → 191.255.255.255 65,536 (216) 255.255.0.0 /16
Class C 192.0.0.0 → 223.255.255.255 256 (28) 255.255.255.0 /24
 
  • 0 Los Usuarios han Encontrado Esto Útil
¿Fue útil la respuesta?

Artículos Relacionados

What Is My Router’s IP Address (Default Gateway)

A router is a device that communicates between the Internet (or public network) and the devices...

Disable IPv6 on Linux – Ubuntu, Debian, CentOS

To disable IPv6 on Linux it is required to modify Linux kernel parameters. IPv6 can be temporary...

169.254.0.0/16 – Disable ZEROCONF Route

You may notice that in your routing table you have a route 169.254.0.0/16. It is so called...

What is my Public IP address?

Use one of the following commands to check your public IP address from the Linux command line....

Finding Active Computers in Local Network from Linux

Searching for Linux command that can list all IP addresses of devices connected to the network?...