TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ipcalc – Command line CIDR calculator with IPv6 support

83 点作者 jaden将近 3 年前

11 条评论

nickjj将近 3 年前
If you&#x27;re only interested in the total number of hosts within a CIDR block for IPv4 addresses you can do this Python 1 liner:<p><pre><code> python3 -c &quot;import ipaddress; print(ipaddress.ip_network(&#x27;10.0.0.0&#x2F;16&#x27;).num_addresses)&quot; </code></pre> You could turn that into a shell function that takes a CIDR block as input if you wanted an alias-like shortcut.<p>While I didn&#x27;t cover this function specifically, I did recently create an IP address allow list with CIDR block support in Python and found myself exploring the ipaddress module. It&#x27;s pretty useful to determine things like if an IP address is in a specific range, etc.. I ended up making a blog post and video about it here: <a href="https:&#x2F;&#x2F;nickjanetakis.com&#x2F;blog&#x2F;create-an-ip-address-allow-list-with-cidr-block-support-in-python" rel="nofollow">https:&#x2F;&#x2F;nickjanetakis.com&#x2F;blog&#x2F;create-an-ip-address-allow-li...</a>
评论 #32298737 未加载
coderholic将近 3 年前
For another cli based IP address utility check out IPinfo.io&#x27;s CLI: <a href="https:&#x2F;&#x2F;github.com&#x2F;ipinfo&#x2F;cli" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ipinfo&#x2F;cli</a><p>It doesn&#x27;t currently support calculations, but it does support conversion of start-end ranges to CIDRs (via `range2cidr` and `cidr2range`) and `grepip`. If you just want to get details for an IP it&#x27;s gives a great overview, and supports bulk lookup too:<p><pre><code> $ ipinfo 8.8.8.8 Core - IP 8.8.8.8 - Anycast true - Hostname dns.google - City Mountain View - Region California - Country United States (US) - Location 37.4056,-122.0775 - Organization AS15169 Google LLC - Postal 94043 - Timezone America&#x2F;Los_Angeles ASN - ID AS15169 - Name Google LLC - Domain google.com - Route 8.8.8.0&#x2F;24 - Type business Company - Name Google LLC - Domain google.com - Type business Privacy - VPN false - Proxy false - Tor false - Relay false - Hosting false - Service Abuse - Address US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043 - Country United States (US) - Email network-abuse@google.com - Name Abuse - Network 8.8.8.0&#x2F;24 - Phone +1-650-253-0000</code></pre>
评论 #32298363 未加载
nixcraft将近 3 年前
We have a script called ipcalc[1] has written in Perl on Linux and Unix. It takes an IPv4 address and netmask and calculates the resulting broadcast, network, Cisco wildcard mask, and host range. So this name is confusing, I guess.<p>]1] <a href="https:&#x2F;&#x2F;packages.debian.org&#x2F;search?keywords=ipcalc" rel="nofollow">https:&#x2F;&#x2F;packages.debian.org&#x2F;search?keywords=ipcalc</a>
评论 #32301093 未加载
iso1631将近 3 年前
Presumably the idea is to give a little more info than the standard jodie&#x27;s ipcalc which comes with your OS, and far better ipv6 support?<p>The examples don&#x27;t make it clear what happens when you type &quot;ipcalc 1.1.1.41&#x2F;27&quot;, which I often do to find the top and bottom of a given &#x2F;27 (or &#x2F;29, or &#x2F;26, etc). I&#x27;m not interested in typing<p>&quot;ipcalc -pnmb --minaddr --maxaddr --geoinfo --addrspace&quot;
评论 #32295984 未加载
评论 #32296512 未加载
评论 #32295970 未加载
lucb1e将近 3 年前
I always used `apt install sipcalc`, that does ipv6 just fine since years. Why another tool?<p>It always seemed confusing that &quot;sip calc&quot; has nothing to do with SIP whatsoever, but then seeing &quot;ipcalc&quot; it&#x27;s also quite the generic name and not any better for searching on.<p>Edit: Was wondering who predates whom. Sipcalc had its last release in 2013; the earliest commit here is from 2015. I guess that settles the matter, don&#x27;t need to find sipcalc&#x27;s commit history :D. Anyway, I never noticed bugs in sipcalc and I&#x27;m also not missing any new features or anything.
评论 #32297459 未加载
c7DJTLrn将近 3 年前
Any idea why it doesn&#x27;t give a HostMin&#x2F;HostMax&#x2F;Hosts field when passing an IPv6 range?<p><pre><code> $ ipcalc 2600:1ff2:4000::&#x2F;40 Address: 2600:1ff2:4000:: 0010011000000000:0001111111110010:0100000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000 Netmask: 40 1111111111111111:1111111111111111:1111111100000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000 Prefix: 2600:1ff2:4000::&#x2F;40 0010011000000000:0001111111110010:0100000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000</code></pre>
评论 #32299291 未加载
评论 #32298930 未加载
luckman212将近 3 年前
I discovered this tool years ago and it&#x27;s been very useful, but difficult to build on macOS. I filed an issue[0] that remains open.<p>Not sure if things have changed since then.<p>[0]: <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;ipcalc&#x2F;ipcalc&#x2F;-&#x2F;issues&#x2F;20" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;ipcalc&#x2F;ipcalc&#x2F;-&#x2F;issues&#x2F;20</a>
wootest将近 3 年前
Slightly off-topic, but according to that page, the project has &quot;-1246658 Bytes Project Storage&quot;.
评论 #32296871 未加载
traceroute66将近 3 年前
Minor moan... such a shame the tool is written in C and not Rust or Go.<p>Instead of being able to compile out of the box, I&#x27;ve seemingly got to install some tools I&#x27;ve never heard of (mesa and ninja). They could have at least allowed you to compile using bog-standard make.
评论 #32298408 未加载
borlox将近 3 年前
lol, it shows address classes. If I was in kindergarten when classes became deprecated, I could be a grandfather by now.
评论 #32299097 未加载
elktea将近 3 年前
related, I like `sipcalc` for the great --v6split functionality