How to Calculate IP Subnet Address with Ipcalc in Linux

How to Calculate IP Subnet Address with Ipcalc in Linux

Learning how to calculate IP subnet address with Ipcalc in Linux is an essential practice of networking, and here’s everything you need to know about it. 

Ipcalc is a helpful utility for the Linux platform that can validate IP addresses and calculate subnet details, broadcast addresses, and other details. 

We will discuss the installation and usage of the tool in detail. The following section starts with a brief discussion on why we need Ipcalc, as the same can be calculated manually. The installation details and usage of the tool are illustrated. We then conclude the discussions on how to Calculate IP Subnet Address with the Ipcalc tool.

Why do we need Ipcalc?

Some network engineers need help calculating address ranges, netmasks, and subnets. The IP4 addresses are 32-bit binary numbers converted into octets of 8-bit fields in decimal notation. The reason is that these decimal numbers are easier to manage than long binary numbers. However, calculating address ranges in decimal digits is tricky and error-prone. You often have to double-check and verify every address used in the calculation. Several online tools are available for this purpose as well.

However, while working on the router console and configuring them, a command line tool is highly desired. For this purpose, the Ipcalc can be used. It provides a range of valuable features for IP address-related calculations.

Introduction to Ipcalc

Ipcalc tool is used during any form of basic and advanced subnetting process. It can calculate the broadcast, network, Cisco wildcard mask, and host range from an IP address and netmask. The following are the essential features of this tool:

  • Supports multiple formats for addresses and netmasks. This includes formats such as dotted quad, hex, and the number of bits.
  • The output information consists of the broadcast address, network class, hosts/ range, and network range.
  • You can calculate the number of subnets, subnetting masks, and various IP-related information.
  • Using the Terminal, you can access multiple networks.
  • It can be used for hostname resolution using domain name service (DNS).
  • You can create subnets and supernets by specifying second masks.
  • It can also be used for teaching subnetting.

Installation of Ipcalc

The installation of Ipcalc on the Linux platform is straightforward. Open the Terminal and type the following command:

$ sudo apt-get install ipcalc

For other distributions such as CentOS/RHEL/Fedora, you can install with the following commands:

# yum install initscripts     #RHEL/CentOS
# dnf install initscripts     #Fedora

After the installation, you may want to verify that the installation is successful. Open the Terminal and type the following command:


It will give you help with the tool with some basic examples. If everything goes fine, you are ready to go with the examples.

Working with Ipcalc

We will now provide some examples of Ipcalc and how to calculate IP subnet address with Ipcalc.

Know information about an IP address

Open your terminal in Linux and then type the following command on the Terminal to run Ipcalc:

$ ipcalc

The above command will show detailed information about anything you want to know about the IP address. This will show the following information:

Address:        11000000.10101000.00000000. 10000111
Netmask: = 24   11111111.11111111.11111111. 00000000
Wildcard:            00000000.00000000.00000000. 11111111
Network:       11000000.10101000.00000000. 00000000
HostMin:          11000000.10101000.00000000. 00000001
HostMax:        11000000.10101000.00000000. 11111110
Broadcast:        11000000.10101000.00000000. 11111111
Hosts/Net: 254                   Class C, Private Internet

Most of the information shown above is self-explanatory. As can be seen, the Ipcalc shows the IP addresses in binary, and therefore netmask addresses can be easily seen and visualized. Such information is difficult to understand in decimal numbers. In the above example, the Ipcalc shows the network address range, i.e.,, the first address (, and the last one in the range (

This is a class C IP address. The 8-bit field implies that 28 = 256 possible values. The first value, 00000000, is reserved as the network address, and the last value, 11111111 = 255, is reserved as a broadcast address. These two reserved addresses can’t be used as host addresses. So in the last line, Ipcalc reports available addresses as 254.

Note: You can suppress the binary information with the –b flag

Calculate IP Subnet Address with Ipcalc

You can also calculate a subnet using Ipcalc. For this purpose, type the following command on the Terminal:

$ ipcalc

The above command will show the information shown in the snapshot.

IPCalc information

Calculate a subnet with 5 hosts

Now, suppose you want to calculate a subnet with 5 hosts. Use the following command to perform this job:

$ ipcalc -s 5

This will show the information shown in the snapshot.

Ipcalc details window

Calculate multiple subnets in Ipcalc

Suppose you want to split into three subnets with 50 hosts distributed in each subnet. You can use the following command:

$ ipcalc -s 10 20 20

Tip: You can also get the information in HTML format with the --html option. You can also get the bit count mask of the address with the --class option. 

In this article, we have discussed the Ipcalc utility in detail and how to calculate IP subnet address with Ipcalc. It can calculate information related to IP addresses, such as subnet masks, hosts detail, etc. We have discussed the installation details for the tool and various usage scenarios. There is also a new tool called ipv6calc which deals with all the complexities and new features introduced in IPv6.

If this guide helped you, please share it.

Related Posts