7 ms·
Ipcalc – Command line CIDR calculator with IPv6 support
- iso1631 4y agoPresumably the idea is to give a little more info than the standard jodie's ipcalc which comes with your OS, and far better ipv6 support? The examples don't make it clear what happens when you type "ipcalc 1.1.1.41/27", which I often do to find the top and bottom of a given /27 (or /29, or /26, etc). I'm not interested in typing "ipcalc -pnmb --minaddr --maxaddr --geoinfo --addrspace"
- sgjohnson 4y agoalias iprange=“ipcalc -pnmb --minaddr --maxaddr --geoinfo --addrspace”
- circularfoyers 4y agoLast I checked (unless I missed something), this didn't have the ability to perform VLSM. Which is what I thought distinguished Jodie's tool from every other similar command line tool. Which is frustrating that this is what replaced Jodie's tool on Fedora.
- zamadatix 4y agoThis seems to do FLSM splitting via --split but I didn't even know VLSM was an option in Jodies, how does the syntax for that work?
- Reventlov 4y ago[remy@typhoon:~]$ ipcalc 1.1.1.41/27 Address: 1.1.1.41 Network: 1.1.1.32/27 Netmask: 255.255.255.224 = 27 Broadcast: 1.1.1.63 Address space: Internet HostMin: 1.1.1.33 HostMax: 1.1.1.62 Hosts/Net: 30
- nixcraft 4y agoWe 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. ]1] https://packages.debian.org/search?keywords=ipcalc https://packages.debian.org/search?keywords=ipcalc
- mbakke 4y agoI also expected that one. It's available as a web service too: https://jodies.de/ipcalc https://jodies.de/ipcalc
- coderholic 4y agoFor another cli based IP address utility check out IPinfo.io's CLI: https://github.com/ipinfo/cli https://github.com/ipinfo/cli It doesn'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's gives a great overview, and supports bulk lookup too: $ 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/Los_Angeles ASN - ID AS15169 - Name Google LLC - Domain google.com - Route 8.8.8.0/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/24 - Phone +1-650-253-0000
- kruptos 4y agoI wish they had a hacker/developer pricing tier. I don't need 150k requests with their full feature set. I need 200/month.
- coderholic 4y agoIt's free for up to 50k req/month. EDIT: Ah, do you mean for the full data set, at lower request volumes? What hacker/dev price point for all data at low volumes do you think makes sense?
- metadat 4y ago1000/mo. for free? Could be a good conversion funnel for paid accounts. Any serious user will naturally graduate to requiring a paid plan.
- wootest 4y agoSlightly off-topic, but according to that page, the project has "-1246658 Bytes Project Storage".
- mdaniel 4y agoSeems to be tracked by this, and its associated, issue: https://gitlab.com/gitlab-org/gitlab/-/issues/368326 https://gitlab.com/gitlab-org/gitlab/-/issues/368326
- lucb1e 4y agoI always used `apt install sipcalc`, that does ipv6 just fine since years. Why another tool? It always seemed confusing that "sip calc" has nothing to do with SIP whatsoever, but then seeing "ipcalc" it's also quite the generic name and not any better for searching on. 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't need to find sipcalc's commit history :D. Anyway, I never noticed bugs in sipcalc and I'm also not missing any new features or anything.
- icehawk 4y agoipcalc is older than 2015, but it lived in a different repository: https://github.com/fedora-sysv/initscripts/commits/3137737948ea40b3c7b69ea1f35199749e78b870/src/ipcalc.c https://github.com/fedora-sysv/initscripts/commits/313773794... ipcalc gets removed here: https://github.com/fedora-sysv/initscripts/commit/76201baf7a731c936e57369549dd537bfcd6a191 https://github.com/fedora-sysv/initscripts/commit/76201baf7a... All in all it looks like ipcalc predates sipcalc by three years (1998 vs 2001)
- nilespotter 4y ago
- luckman212 4y agoI discovered this tool years ago and it's been very useful, but difficult to build on macOS. I filed an issue[0] that remains open. Not sure if things have changed since then. [0]: https://gitlab.com/ipcalc/ipcalc/-/issues/20 https://gitlab.com/ipcalc/ipcalc/-/issues/20
- c7DJTLrn 4y agoAny idea why it doesn't give a HostMin/HostMax/Hosts field when passing an IPv6 range? $ ipcalc 2600:1ff2:4000::/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::/40 0010011000000000:0001111111110010:0100000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000
- zamadatix 4y ago"HostMin" = Prefix. "HostMax" = Prefix followed by all f's. "Hosts" = some ungodly large number (i.e. "small" for this is 2^64) you typically don't care about anymore. If someone did something atypical like use a /123 (mask >64, mask not a multiple of 4) and you do actually want to see host max and host count as a result you can pass "--all-info". Otherwise a combination of the ridiculous size and hex encoding makes everything but "what is the prefix and netmask" irrelevant.
- peppermint_tea 4y agoshameless plug, I made an ipcalc6 in rust that does it (with colors) https://github.com/ba9f11ecc3497d9993b933fdc2bd61e5/ipcalc6 https://github.com/ba9f11ecc3497d9993b933fdc2bd61e5/ipcalc6 user@box:~/Documents/code/rust/ipcalc6$ cargo run 2600:1ff2:4000::/40 Finished dev [unoptimized + debuginfo] target(s) in 0.01s Running `target/debug/ipcalc6 '2600:1ff2:4000::/40'` WARNING : netmask /40 is smaller than /48, this is unusual if ip of type : Global Unicast Address and Link-Local Address Type: Unicast Global Address: 2600:1ff2:4000:0000:0000:0000:0000:0000 NetMask: 40 Hosts/Net: 19342813113834066795298816 Address: 0010011000000000.0001111111110010.0100000000000000.0000000000000000.0000000000000000.0000000000000000.0000000000000000.0000000000000000 NetMask: 1111111111111111.1111111111111111.1111111111111111.0000000000000000.0000000000000000.0000000000000000.0000000000000000.0000000000000000 HostMin: 0010011000000000.0001111111110010.0100000000000000.0000000000000000.0000000000000000.0000000000000000.0000000000000000.0000000000000000 HostMax: 0010011000000000.0001111111110010.0100000000000000.1111111111111111.1111111111111111.1111111111111111.1111111111111111.1111111111111111
- nickjj 4y agoIf you're only interested in the total number of hosts within a CIDR block for IPv4 addresses you can do this Python 1 liner: python3 -c "import ipaddress; print(ipaddress.ip_network('10.0.0.0/16').num_addresses)" You could turn that into a shell function that takes a CIDR block as input if you wanted an alias-like shortcut. While I didn'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'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: https://nickjanetakis.com/blog/create-an-ip-address-allow-list-with-cidr-block-support-in-python https://nickjanetakis.com/blog/create-an-ip-address-allow-li...
- zamadatix 4y agoI use both JS and Python for networking all the time and sometimes I wish there was just a first class way to say "these are u32" and "these are u128" because it can make things like this dead simple and blazing fast (pseudocode): function <u1> inSubnet(<u32>networkAddress, <u32>networkMask, <u32>testIP) { <u32>lower = networkAddress; <u32>upper = networkAddress + ~netmask; return (testIP >= lower) && (testIP <= upper); } Number of IPs in a subnet is "~netmask + 1", network address of a host with a given netmask is "host & netmask", mask length to integer form is "0xFFFFFFFF << (32 - maskLength)", and so on. Subnet logic is all designed to be clear, lightweight, and fast from the ground up. Of course it's also nice to have built in libraries like "ipaddress" too as most (if not all) of what you were wanting to do will likely already be done for you but in the cases it doesn't you're back to wishing you could just specify a type to save a lot of work.
- teaearlgraycold 4y agoAgreed. Python defaulting to magic bigints is nice when you're in a math domain, but terrible when in a computer domain. The stdlib really needs some nice simple u32(), i64() etc. constructors.
- borlox 4y agolol, it shows address classes. If I was in kindergarten when classes became deprecated, I could be a grandfather by now.
- zamadatix 4y agoWhat, no shock about it having IPv4 support even though that was replaced when you were in 2nd grade :p.
- wolrah 4y ago> What, no shock about it having IPv4 support even though that was replaced when you were in 2nd grade :p. IPv4 is still unfortunately relevant to almost every real world network, where address classes have been irrelevant to basically everyone for decades.
- traceroute66 4y agoMinor moan... such a shame the tool is written in C and not Rust or Go. Instead of being able to compile out of the box, I've seemingly got to install some tools I've never heard of (mesa and ninja). They could have at least allowed you to compile using bog-standard make.
- jeroenhd 4y agoIt's just a matter of what tools you happen to have preinstalled. Meson and Ninja are easier to install than the entire Rust suite or Go (using their official guide, anyway). They're in the standard repos rather than piping curl to bash or manually managing tar.gz downloads. I would appreciate a Makefile for a project this simple but I do prefer the Meson/Ninja build system for projects like these.
- traceroute66 4y ago> easier to install than Go Huh?!?!?! I don't know about Rust (I know they like their install script), but for Go you can download a pre-compiled binary and you're instantly up and running. That option is not exactly hidden[1]. You don't even have to use an OS installer, e.g. for Linux/Mac you can download a .tar.gz file[1] unzip it anywhere and just run "go" based commands to compile stuff immediately (maybe adding it to your $PATH to make life easier). But really. Go is a million times quicker and smaller than usual bunch of stuff you need to install to get a C thing compiled (and that's just the standard tools, before we start talking about random stuff like Meson or Ninja) The point I was making is that Ipcalc is a simple CLI utility. It doesn't need all the baggage that comes with C compiling. Its practically made for Rust or Go. You can also easily cross-platform compile with Go. Try that with C without jumping through hoops ! [1] https://go.dev/dl/ https://go.dev/dl/
- jeroenhd 4y agoPerhaps "install" is the wrong word. I want my software to be upgraded through the normal means. I don't want to monitor the Go website for new versions and I don't want the tools themselves to phone home with update checks (especially if Google is behind them). I now notice that Ubuntu packages golang-go in their repositories, so I suppose Go is on par with Meson and Ninja. Strange that they don't mention that on their download page, though. > You can also easily cross-platform compile with Go. Try that with C without jumping through hoops ! Clang has "--target=arm-linux-gnueabihf" to cross compile to ARM. You might need to go more specific (i.e. "--target=riscv64 -march=rv64gc" for specific RISCV configurations) but it's just a single command line flag. With GCC/G++ you need the dedicated compiler packaged separately to save space, but you'd use environment variables (export CC="arm-linux-gnueabihf-gcc"; export CXX="export CC="arm-linux-gnueabihf-g++"). The only difficulty you'd run into is when you want to dynamically link the produced binary (because you need a compatible .so to link against). You'll have the same problem in any language, though.
- elktea 4y agorelated, I like `sipcalc` for the great --v6split functionality