LinuxCommandLibrary

ipcalc

Calculate IP network information

TLDR

Display network info for an IP address

$ ipcalc [192.168.0.1]
copy

Display network info using CIDR notation
$ ipcalc [192.168.0.1]/[24]
copy

Display network info using a dotted decimal netmask
$ ipcalc [192.168.0.1] [255.255.255.0]
copy

Suppress bitwise output
$ ipcalc [[-b|--nobinary]] [192.168.0.1]
copy

Split a network into specified sized blocks
$ ipcalc [[-s|--split]] [size1 size2 size3 ...] [192.168.0.1]
copy

Display version
$ ipcalc [[-v|--version]]
copy

SYNOPSIS

ipcalc [options] [netmask_or_prefix]
ipcalc [options]

PARAMETERS

-b, --broadcast
    Display the broadcast address of the network.

-n, --network
    Display the network address (or subnet ID).

-m, --netmask
    Display the network mask in dotted-decimal format.

-p, --prefix
    Display the prefix length (CIDR notation).

-h, --hostrange
    Display the range of IP addresses assignable to hosts within the network.

-r, --longrange
    Display the first and last usable IP address in the host range.

-c, --class
    Display the network class (e.g., A, B, C, D, E).

-s, --split
    Split the given network into smaller subnets. Requires an additional argument for the new prefix length.

-d, --dot
    Output IP addresses in dotted decimal format (default for IP addresses).

-x, --hex
    Output IP addresses in hexadecimal format.

-B, --binary
    Output IP addresses in binary format.

--hosts
    Display the total number of addresses in the network.

--all
    Display all calculated network information (network, broadcast, netmask, prefix, hostrange, hosts). This is often the default behavior when no specific flags are used.

--help
    Display a help message and exit.

--version
    Display version information and exit.

DESCRIPTION

ipcalc is a versatile command-line utility for performing calculations and conversions related to IP networks, primarily IPv4. It can determine various network properties such as the network address, broadcast address, netmask, host range, and the number of usable hosts from a given IP address and CIDR prefix or netmask. Beyond basic network calculations, ipcalc also supports conversions between different IP address representations (dotted-decimal, hexadecimal, binary) and can provide details like the network class or split a larger network into smaller subnets. It's a fundamental tool for network administrators and engineers for planning, troubleshooting, and understanding IP addressing schemes.

CAVEATS

Functionality and available options for ipcalc can vary slightly depending on the specific package and Linux distribution it's sourced from (e.g., part of initscripts or a standalone utility). Traditional ipcalc primarily supports IPv4 addresses; IPv6 support is not standard across all versions.

USAGE EXAMPLES

ipcalc can be used to quickly determine network parameters for a given IP address and netmask/CIDR. For instance, to get all details for a specific IP and prefix: ipcalc 192.168.1.5/24.
To specify IP and netmask separately: ipcalc 192.168.1.5 255.255.255.0.
To convert an IP address to binary: ipcalc -B 10.0.0.1.
To split a network into smaller subnets: ipcalc --split 192.168.0.0/22 24 will show all /24 subnets within the /22 range.

HISTORY

ipcalc has been a long-standing, simple, and effective command-line tool in the Linux ecosystem. It was historically often bundled with network initialization scripts (initscripts) or provided as a standalone utility package. Its straightforward approach to IP calculations has kept it relevant for quick network analysis and planning, even with the advent of more comprehensive tools like iproute2.

SEE ALSO

ip(8), ifconfig(8), netstat(8), ping(8)

Copied to clipboard