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.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers perform related Linux system networking queries.
In this context, we shall look into how to install ipcalc on Ubuntu 21.04 Linux system.
You can open the terminal and run the following command to install the ipcalc tool:
$ sudo apt install ipcalc -y
Now, you can run ipcalc command with your ip address (lets say our ip address is 192.168.1.2) to see all information about the network addresses:
$ ipcalc ip_address
$ ipcalc 192.168.1.2
From the output, you will see the Address, Netmask, Wildcard, HostMin, HostMax, Broadcast, Hosts and so on.
To calculate the subnet for 192.168.1.2/24, you can run the following command:
$ ipcalc 192.168.1.2/24
To calculate a single subnet, you can run the following command:
$ ipcalc 192.168.1.2 -s 7
To suppress the binary output, you can run the following command by using -b option with the below command:
$ ipcalc -b 192.168.1.2
If you want to split 192.168.1.2 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.2 -s 10 20 20
To get more details on ipcalc, you can just run the following command:
$ ipcalc --help
Or,
$ man ipcalc
This article covers the ipcalc tool and the steps to use it. In fact, It is an important tool for network related tasks.