Get the opposite of a CIDR Range
I'd like to make a list of CIDR ranges that represent the addresses outside of the CIDR range I specify.
As a simplified example:
If I have the IP ranges from 8.8.8.8 to 8.8.8.10, I would be able to express this with CIDR ranges 8.8.8.8/31 and 8.8.8.10/32. But how could I express the opposite of these ranges in CIDR notation?
I'm new to CIDR so if this kind of tool exists already in a popular format please excuse my question.
As an additional note, I would like to eventually implement this filtering in R so if you can express your answer using R that would be preferable but I'm really mostly interested in how to build the algorithm to solve this kind of problem.
Basically, if you have a range (X, Y) of IP addresses and want to represent all IP addresses that are not in (X, Y) then it can be expressed as two ranges: (0.0.0.0, X-1) and (Y+1, 255.255.255.255).
Then you just convert the two ranges into CIDRs. A range may result in multiple CIDRs.
In the specific example you want ranges: (0.0.0.0, 8.8.8.7) and (8.8.8.11, 255.255.255.255). I have no idea of how to do this in R but here is a handy calculator here: http://www.ipaddressguide.com/cidr
(0.0.0.0, 8.8.8.7):
(8.8.8.11, 255.255.255.255):
8.8.8.11/32
8.8.8.12/30
上一篇: 对Styled Media Receiver css进行故障排除
下一篇: 获取CIDR范围的对立面