Calculate network, broadcast, netmask, etc with ipcalc

Posted by Scurz on Tue 3 Jun 2008 at 14:44

Ipcalc is a simple tool to calculate network, broadcast, netmask, etc. from an IP address. It also gives the class of the IP. It might facilitate the work of network admins. :-)

Here is an example of using it against a "local" IP address:

# ipcalc 192.168.1.1
Address:   192.168.1.1          11000000.10101000.00000001. 00000001
Netmask:   255.255.255.0 = 24   11111111.11111111.11111111. 00000000
Wildcard:  0.0.0.255            00000000.00000000.00000000. 11111111
=>
Network:   192.168.1.0/24       11000000.10101000.00000001. 00000000
HostMin:   192.168.1.1          11000000.10101000.00000001. 00000001
HostMax:   192.168.1.254        11000000.10101000.00000001. 11111110
Broadcast: 192.168.1.255        11000000.10101000.00000001. 11111111
Hosts/Net: 254                   Class C, Private Internet

You may also invoke it with the -h flag to cause the tool to generate HTML output which may be useful for displaying online:

ipcalc -h 192.168.1.1 > mypage.html

To get the ipcalc package installed upon a Debian system simply run "apt-get install ipcalc", or "aptitude install ipcalc".

Further details may be found upon the official project website - don't forget to read the man page, via "man ipcalc" ;-)


This article can be found online at the Debian Administration website at the following bookmarkable URL:

This article is copyright 2008 Scurz - please ask for permission to republish or translate.