About
Classless Inter-Domain Routing (CIDR) is a notation that defines a subnet (ip net range)
It is an integer that specifies the number of significant bits in the mask.
Syntax
CIDR notation:
IP Address/prefix
where:
- IP Address is a What is a IP Address? A Unique network IDentifier
- prefix is the subnet mask prefix length.
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
How to find the CIDR of one IP ?
In a whois request, you can see the CIDR back.
Example:
whois 172.70.250.60
NetRange: 172.64.0.0 - 172.71.255.255
CIDR: 172.64.0.0/13
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';