Classless Inter-Domain Routing (CIDR)

About

Classless Inter-Domain Routing (CIDR) is a notation that defines a subnet

Syntax

CIDR notation:

IP Address/prefix

where:

Example

The world

0.0.0.0/0

where:

  • 0.0.0.0 is the wildcard IP address that match any possible machines

Only one IP

x.x.x.x/32

where the routing prefix 32 means that there is only one host on this network.

Example:

143.176.206.82/32

Operation

Range to Cidr

In Postgress from numeric IP with inet_merge

SELECT 
    inet_merge(
        '0.0.0.0'::inet + ip_from, 
        '0.0.0.0'::inet + ip_to
   ) 
from ip where ctry = 'NL';

Documentation / Reference


Powered by ComboStrap