Categories: TutorialsUbuntu

ipcalc – Calculate IP Subnet Address in Linux

In advance or modern networking, you must have knowledge or deal with subnetting. Few of the system administrators or related people can do binary math in their head to calculate the exact subnet mask but some of them need help which is fulfilled by the ipcalc tool in Linux.

In Linux, ipcalc has more abilities in the networking field. Firstly, it collects the data such as IP address and netmask then comes up with the resulting broadcast, network, Cisco wildcard mask, and host range. Also, you can create the subnets and supernets by providing the second netmask. It can be used as the teaching tool by presenting the subnetting results in an easy to understand binary values.

Ipcalc
Sponsored
features

  • Multiple types of bitmaps as output.
  • Address information is retrieved from interfaces.
  • Show hostnames directed as per DNS resolutions.
  • Output is presented as compressed and standard wise.
  • Input address is also presented as compressed and standard wise.
  • Output formats as multiple addresses and netmask.
  • User defined number of extra networks as Output.
  • Output of standard IPV6 network.

How to install ipcalc in Linux

Here, we are going to install ipcalc on Ubuntu 21.04. First open the terminal then run the following command to install the ipcalc tool.

$ sudo apt install ipcalc -y

How to use ipcalc in Linux

Now, you can run ipcalc command with your ip address to see all information about the network addresses.

$ ipcalc 192.168.1.67

Output:

How to calculate the subnet

To calculate the subnet for 192.168.1.0/24, you can run the following command:

$ ipcalc 192.168.1.0/24

Output:

How to calculate a single subnet with 7 hosts

To calculate a single subnet, you can run the following command:

$ ipcalc 192.168.1.0 -s 7

Output:

Sponsored

How to suppress the binary output

To suppress the binary output, you can run the following command by using -b option as shown below:

$ ipcalc -b 192.168.1.0

Output:

How to calculate a multiple subnets with single command

If you want to split 192.168.1.0 into three subnets and total hosts are 50. You have to specify the number of hosts and network mast in each segment.

$ ipcalc 192.168.1.0 -s 10 20 20

Output:

To get more details on ipcalc, you can just run the following command:

$ ipcalc --help

Or,

$ man ipcalc

Conclusion

In this article, you learned about the ipcalc tool and the steps to use it with certain examples. It is an important tool for network related tasks. Thank you!

Ubuntu Server Admin

Recent Posts

Cut data center energy costs with bare metal automation

Data centers are popping up everywhere. With the rapid growth of AI, cloud services, streaming…

22 hours ago

Build the future of *craft: announcing Starcraft Bounties!

Our commitment to building a thriving open source community is stronger than ever. We believe…

22 hours ago

NodeJS 18 LTS EOL extended from April 2025 to May 2032 on Ubuntu

The clock was ticking: Node.js 18’s upstream End of Life (EOL) The OpenJS Foundation is…

22 hours ago

Native integration now available for Pure Storage and Canonical LXD

June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…

2 days ago

Revolutionizing Web Page Creation: How Structured Content is Slashing Design and Development Time

Co-authored with Julie Muzina A year ago, during our Madrid Engineering Sprint, we challenged ourselves…

3 days ago

Ubuntu Weekly Newsletter Issue 897

Welcome to the Ubuntu Weekly Newsletter, Issue 897 for the week of June 15 –…

4 days ago