#cidr #subnet #calculate #ip #networking #cli

app cidr_calc

CLI to easily calculate CIDR subnets

8 releases

0.2.1 May 1, 2024
0.2.0 May 1, 2024
0.1.5 Mar 22, 2024
0.1.4 Nov 29, 2023

#571 in Network programming

Download history 4/week @ 2024-02-15 8/week @ 2024-02-22 1/week @ 2024-02-29 4/week @ 2024-03-07 3/week @ 2024-03-14 144/week @ 2024-03-21 17/week @ 2024-03-28 16/week @ 2024-04-04 1/week @ 2024-04-11 2/week @ 2024-04-18 95/week @ 2024-04-25 118/week @ 2024-05-02

217 downloads per month

MIT license

27KB
500 lines

CLI to easily calculate CIDR subnets

Install

Using Cargo

If you have rust installed:

cargo install --locked cidr_calc

If not check it out! https://www.rust-lang.org/tools/install

Releases Binary

You can also download the release binary from GitHub releases. https://github.com/pitoniak32/cidr_calc/releases

Usage

CLI to easily calculate CIDR subnets

Usage: cidrc [OPTIONS] <IP_CIDR>

Arguments:
  <IP_CIDR>  Usage: X(.,-)X(.,-)X(.,-)X(/,-)X (ex: 10.0.0.1/24, 10-0-0-1-24)

Options:
  -o, --output <OUTPUT>  [default: text] [possible values: text, json]
  -h, --help             Print help
  -V, --version          Print version

Examples

❯ cidrc 10.0.0.1/24
Network Summary
ip...............: 10.0.0.1
cidr.............: 24
subnet_mask......: 255.255.255.0
wildcard_mask....: 0.0.0.255
first_host_addr..: 10.0.0.1
last_host_addr...: 10.0.0.254
usable_hosts.....: 254
network_addr.....: 10.0.0.0
broadcast_addr...: 10.0.0.255
total_hosts......: 256
❯ cidrc 10.0.0.1/24 -o json | jq '.last_host_addr'
"10.0.0.254"
❯ echo "1.1.1.1/1" | xargs cidrc -o json
{
  "ip": "1.1.1.1",
  "cidr": 1,
  "subnet_mask": "128.0.0.0",
  "wildcard_mask": "127.255.255.255",
  "first_host_addr": "0.0.0.1",
  "last_host_addr": "127.255.255.254",
  "usable_hosts": 2147483646,
  "network_addr": "0.0.0.0",
  "broadcast_addr": "127.255.255.255",
  "total_hosts": 2147483648
}

Dependencies

~4–6MB
~105K SLoC