Sometime while working on Linux machine we have to understand Networking things in such way that we need to calculate and understand provided subnets, usually for same we take help of various subnet calculator those are easily provided on internet. So I tried to find same on Linux command line.

Yes, we have one command which act as same, this is ipcalc which make provide us user-friendly output for Linux users.

Through this We can easily analyze complex IP subnets and can share details with other team members as well.

Let’s see how we can use this command. For same I am using Ubuntu 16.04 LTS, as described below.

# uname  -r
4.4.0-116-generic

# lsb_release -d
Description:  Ubuntu 16.04.4 LTS

Example

In this example, we need to create three subnets in 10.12.45.0/25. Let’s see how this command do this work.

With above image, we can understand this command will display following sections.

1. Subnet descriptions and Details.

Address:   10.12.45.0           00001010.00001100.00101101.0 0000000
Netmask:   255.255.255.128 = 25 11111111.11111111.11111111.1 0000000
Wildcard:  0.0.0.127            00000000.00000000.00000000.0 1111111
=>
Network:   10.12.45.0/25        00001010.00001100.00101101.0 0000000
HostMin:   10.12.45.1           00001010.00001100.00101101.0 0000001
HostMax:   10.12.45.126         00001010.00001100.00101101.0 1111110
Broadcast: 10.12.45.127         00001010.00001100.00101101.0 1111111
Hosts/Net: 126                   Class A, Private Internet

2. Requested size subnets with their details

1. Requested size: 30 hosts
Netmask:   255.255.255.224 = 27 11111111.11111111.11111111.111 00000
Network:   10.12.45.64/27       00001010.00001100.00101101.010 00000
HostMin:   10.12.45.65          00001010.00001100.00101101.010 00001
HostMax:   10.12.45.94          00001010.00001100.00101101.010 11110
Broadcast: 10.12.45.95          00001010.00001100.00101101.010 11111
Hosts/Net: 30                    Class A, Private Internet

2. Requested size: 60 hosts
Netmask:   255.255.255.192 = 26 11111111.11111111.11111111.11 000000
Network:   10.12.45.0/26        00001010.00001100.00101101.00 000000
HostMin:   10.12.45.1           00001010.00001100.00101101.00 000001
HostMax:   10.12.45.62          00001010.00001100.00101101.00 111110
Broadcast: 10.12.45.63          00001010.00001100.00101101.00 111111
Hosts/Net: 62                    Class A, Private Internet

3. Requested size: 20 hosts
Netmask:   255.255.255.224 = 27 11111111.11111111.11111111.111 00000
Network:   10.12.45.96/27       00001010.00001100.00101101.011 00000
HostMin:   10.12.45.97          00001010.00001100.00101101.011 00001
HostMax:   10.12.45.126         00001010.00001100.00101101.011 11110
Broadcast: 10.12.45.127         00001010.00001100.00101101.011 11111
Hosts/Net: 30                    Class A, Private Internet

Needed size:  128 addresses.
Used network: 10.12.45.0/25
Unused:

This Detail is enough to understand subnets, It contain Netmask, Network, Start IP Address, last IP Address, Broadcast Address , Total number of IP Address . It contain most of information that any Linux admin required to understand while coordinating with network team or allocating IP address to machines.

Below is another examples that show it also cover unused subnets within range of subnet.