ipcalc
The ipcalc
command is a powerful and often overlooked utility in the Linux command line that's incredibly useful for network administrators, developers, and anyone working with IP addresses and subnets. It provides a wealth of information about an IP address, its network, and related parameters, making network calculations much easier and less error-prone. also helps you avoid relying on online resources and calculators.
This is a valuable tool for anyone who regularly works with TCP/IP networking. By providing clear and concise information about IP addresses and subnets, it simplifies network calculations and helps you better understand your network's structure. The next time you need to figure out network boundaries or subnet details, give ipcalc
a try!

What ipcalc Does
At its core, ipcalc
takes an IP address (and optionally a netmask or CIDR prefix) as input and outputs details about the network it belongs to. This includes:
- Network address: The starting address of the network.
- Broadcast address: The address used to send data to all hosts on the network.
- Netmask: The mask used to distinguish the network portion from the host portion of an IP address.
- CIDR prefix: The number of bits used for the network portion (e.g.,
/24
). - Host address range: The valid IP addresses that can be assigned to devices on the network.
- Number of hosts: The total number of usable IP addresses in the subnet.
- Inverse mask: The opposite of the netmask, sometimes used in access control lists.
- Class: The traditional IP address class (A, B, or C) if applicable.
Basic Usage
The simplest way to use ipcalc
is to provide an IP address. It will attempt to infer the network information based on the IP address class.
ipcalc 10.11.12.13
This will likely give you results for a Class A network:
Address: 10.11.12.13 00001010.00001011.00001100. 00001101
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
Network: 10.11.12.0/24 00001010.00001011.00001100. 00000000
HostMin: 10.11.12.1 00001010.00001011.00001100. 00000001
HostMax: 10.11.12.254 00001010.00001011.00001100. 11111110
Broadcast: 10.11.12.255 00001010.00001011.00001100. 11111111
Hosts/Net: 254 Class A, Private Internet
Specifying Netmask or CIDR
To get information for a specific subnet, you can provide the netmask or the CIDR prefix after the IP address.
Using a netmask:
ipcalc 10.0.0.5 255.255.255.192
Using a CIDR prefix:
ipcalc 10.0.0.5/26
Both commands would analyze the IP address within a /26 subnet, providing details specific to that network size.
Useful Options
ipcalc
has several options to customize the output:
-n, --network
: Display only the network address.-h, --hostname
: Attempt to resolve the hostname of the IP address.-m, --netmask
: Display only the netmask.-b, --broadcast
: Display only the broadcast address.-p, --prefix
: Display only the CIDR prefix.-H, --host_min
: Display only the first usable host address.-L, --host_max
: Display only the last usable host address.-s, --split <prefix>
: Split the current network into smaller subnets of the specified prefix length.
Example: Displaying only the network address and broadcast address
ipcalc -n -b 172.16.10.30/20
Example: Splitting a network
Let's split a /24 network into /26 subnets:
ipcalc -s 26 192.168.1.0/24
This would output the details for each of the four /26 subnets within the original /24 network.
Why Use ipcalc?
- Accuracy: Avoids manual calculation errors when determining network ranges, broadcast addresses, etc.
- Efficiency: Quickly get all relevant network information with a single command.
- Subnetting: Easily see the details of subnets when splitting or analyzing network divisions.
- Troubleshooting: Quickly identify network parameters when troubleshooting connectivity issues.
- ← Previous
htop vs gotop