CIDR range checker/generator

栏目: IT技术 · 发布时间: 4年前

内容简介:A CLI tool to assist you with CIDR ranges and IPs.You can download the

cidrchk

A CLI tool to assist you with CIDR ranges and IPs.

Install it

You can download the latest binary for Linux (Intel and Arm), macOS, and Windows.

For example, to install cidrchk from binary on macOS, do the following:

curl -L https://github.com/mhausenblas/cidrchk/releases/latest/download/cidrchk_darwin_amd64.tar.gz \
    -o cidrchk.tar.gz && \
    tar xvzf cidrchk.tar.gz cidrchk && \
    mv cidrchk /usr/local/bin && \
    rm cidrchk*

Use it

cidrchk can do three things for you: 1. check CIDR ranges for inclusion, 2. check for CIDR range overlaps, and 3. generate all IPs in a CIDR range.

Note that cidrchk uses OPA Rego to perform CIDR operation, to be precise the built-in Net functions .

Check for CIDR range inclusion

To check if a CIDR range contains an IP or another CIDR range:

$ cidrchk contains 192.168.0.0/16 192.168.0.42
yes

This also works for IPv6 addresses, for example:

$ cidrchk contains \
          0:0:0:0:0:ffff:c0a8:0/30 \
          0:3:ffff:ffff:ffff:ffff:ffff:ffff
yes

Check for CIDR range overlaps

To check if two CIDR ranges overlap you can do:

$ cidrchk overlaps 192.168.0.0/16 192.168.1.0/24
yes

Generate IPs from CIDR range

To expand a CIDR range, that is, to generate all IPs in it do the following:

$ cidrchk expand 192.168.0.0/30 | jq .
{
  "cidr": "192.168.0.0/30",
  "ips": [
    [
      "192.168.0.0",
      "192.168.0.1",
      "192.168.0.2",
      "192.168.0.3"
    ]
  ]
}

One can also answer questions like "How many IP addresses are there in a CIDR range", for example:

$ cidrchk expand 192.168.0.0/16 | jq '.ips[] | length'
65536

以上所述就是小编给大家介绍的《CIDR range checker/generator》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

BLOG启示录

BLOG启示录

胡嘉玺 / 清华大学出版社 / 2010-7 / 48.00元

《BLOG启示录:WordPress博客建设与经营》分三大部分,共17章。第一部分(1~5章)主要是介绍Web 2.0、博客,以及LAMP的安装和架设,更有完整的主机、域名、DNS、WordPress安装、申请、交费等步骤,读者即使对计算机、主机、网络、域名等知识完全不懂,也可以依照《BLOG启示录:WordPress博客建设与经营》的步骤来落实整个WordPress基础建设的架构及安装。 ......一起来看看 《BLOG启示录》 这本书的介绍吧!

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具