How to Calculate IPv4 and IPv6 Subnets in Linux Using sipcalc

Designing, configuring, and troubleshooting computer networks requires rapid, precise subnetting calculations. While standard manual calculations or browser-based tools suffice for occasional tasks, system administrators and network engineers managing Linux servers frequently require an offline, scriptable command-line tool. The sipcalc utility is an advanced, console-based IP subnet calculator capable of parsing both IPv4 and IPv6 address formats, producing comprehensive breakdowns of network boundaries, broadcast ranges, netmasks, and usable host allotments.

How to Install sipcalc in Major Linux Distributions

The sipcalc package is available across standard distribution package repositories:

  • Ubuntu, Debian, and Linux Mint:
    sudo apt update && sudo apt install sipcalc
  • Fedora, RHEL, and Rocky Linux:
    sudo dnf install sipcalc
  • Arch Linux:
    sudo pacman -S sipcalc

How to Calculate IPv4 Subnet Details Using sipcalc

To inspect an IPv4 address along with its Classless Inter-Domain Routing (CIDR) prefix, pass the target network directly to sipcalc:

sipcalc 192.168.10.45/26

The command outputs a structured analysis containing essential network metrics:

  • Host address: The parsed IP address (192.168.10.45).
  • Network address: The base subnet identifier (192.168.10.0).
  • Network mask: Dotted-decimal netmask (255.255.255.192) and hexadecimal mask (FFFFFFC0).
  • Broadcast address: The directed broadcast address for the subnet (192.168.10.63).
  • Usable range: Exact first and last host IP addresses (192.168.10.1 to 192.168.10.62).
  • Addresses in network: Total addresses in the block (64) and usable host addresses (62).

How to Calculate IPv6 Subnet Details Using sipcalc

Unlike basic tools such as ipcalc that historically had limited IPv6 capabilities, sipcalc offers comprehensive IPv6 decoding out of the box:

sipcalc 2001:db8:85a3::8a2e:370:7334/64

The utility provides key architectural data, including:

  • Expanded (uncompressed) address: Full 128-bit representation with all leading zeroes restored.
  • Prefix address: The /64 network routing prefix.
  • Prefix length: Specified mask boundary.
  • Network range: The start and end boundary addresses for the IPv6 subnet allocation.
  • Number of addresses: Total reachable IPv6 interface identifiers within the allocated block.

How to Subnet Networks into Smaller Segments Using the -s Flag

When partitioning a large IP assignment into multiple smaller departmental subnets, use the -s option followed by your target subnet mask prefix:

sipcalc -s 28 192.168.1.0/24

This command systematically divides the /24 network block into successive /28 subnets, displaying each individual segment’s network identifier, broadcast IP, and usable host count in sequential order.

Parsing Live Network Interfaces with sipcalc

You can also instruct sipcalc to extract addressing parameters directly from an active network interface by supplying the -i argument:

sipcalc -i eth0

This provides an immediate cryptographic and numerical breakdown of the adapter’s active IPv4 and IPv6 subnet configurations without requiring manual parameter lookups via ip addr.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.