A tool that is more than likely not used very often in Backtrack is the ipcalc which is a command line to that will quickly provide you broadcast address, network address, netmask, and Cisco wildcard mask. If you do a lot of Backtrack Linux installations that each require different IP information for various networks this tool can be really useful to verify settings made in the networks file in Ubuntu/Backtrack. I used to find myself breaking out a iPhone IP calculator on a regular basis and while I still do use that application I prefer ipcalc from the command line if its readily available. Below are details regarding ipcalc and the various switches available to it.
- root@bt:~# ipcalc --help
- IP Calculator 0.41
- Enter your netmask(s) in CIDR notation (/25) or dotted decimals (255.255.255.0).
- Inverse netmask are recognized. If you mmit the netmask, ipcalc uses the default
- netmask for the class of your network.
- Look at the space between the bits of the addresses: The bits before it are
- the network part of the address, the bits after it are the host part. You can
- see two simple facts: In a network address all host bits are zero, in a
- broadcast address they are all set.
- The class of your network is determined by its first bits.
- If your network is a private internet according to RFC 1918 this is remarked.
- When displaying subnets the new bits in the network part of the netmask are
- marked in a different color.
- The wildcard is the inverse netmask as used for access control lists in Cisco
- routers. You can also enter netmasks in wildcard notation.
- Do you want to split your network into subnets? Enter the address and netmask
- of your original network and play with the second netmask until the result
- matches your needs.
- Questions? Comments? Drop me a mail...
- krischan at jodies.de
- http://jodies.de/ipcalc
- Thanks for your nice ideas and help to make this tool more useful:
- Bartosz Fenski
- Denis A. Hainsworth
- Foxfair Hu
- Frank Quotschalla
- Hermann J. Beckers
- Igor Zozulya
- Kevin Ivory
- Lars Mueller
- Lutz Pressler
- Oliver Seufer
- Scott Davis
- Steve Kent
- Sven Anderson
- Torgen Foertsch
- Usage: ipcalc [options]
- <address>[[/]] [NETMASK]
- ipcalc takes an IP address and netmask and calculates the resulting broadcast,
- network, Cisco wildcard mask, and host range. By giving a second netmask, you
- can design sub- and supernetworks. It is also intended to be a teaching tool
- and presents the results as easy-to-understand binary values.
- -n --nocolor Don't display ANSI color codes.
- -b --nobinary Suppress the bitwise output.
- -c --class Just print bit-count-mask of given address.
- -h --html Display results as HTML (not finished in this version).
- -v --version Print Version.
- -s --split n1 n2 n3
- Split into networks of size n1, n2, n3.
- -r --range Deaggregate address range.
- --help Longer help text.
- Examples:
- ipcalc 192.168.0.1/24
- ipcalc 192.168.0.1/255.255.128.0
- ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
- ipcalc 192.168.0.1 0.0.63.255
- ipcalc - deaggregate address range
- ipcalc
- <address>/ --s a b c
- split network to subnets
- where a b c fits in.
- ! New HTML support not yet finished.
- ipcalc 0.41
- root@bt:~#
If you viewed the ipcalc help output by clicking the above link you will see the mini book but don’t fear if you simply type “ipcalc” from the command line without any switches or data following you will get the shorter version of help that provides a brief explanation of each switch available to ipcalc. I am really glad that the tool provides the -n or –nocolor option because lots of ANSI color makes my head hurt! All of the examples below will use the -n switch to surpress the color output even though it would not display in this post regardless. Anyhow ipcalc is really easy to use as shown in the below examples.The current version of ipcalc in Backtrack 0.41 is the actual latest version of ipcalc which has not been updated since 2006.
The first example below shows how I typically use ipcalc when I know a IP address and Netmaks but want to verify the broadcast and network addresses associated to the IP address. This initial command would also be a great tool for Cisco administrators that are looking for a quick way to verify Cisco wildcards masks.
ipcalc : Basic Usage Without Binary Output
- root@bt:~# ipcalc -n -b 10.47.10.59/28
- Address: 10.47.10.59
- Netmask: 255.255.255.240 = 28
- Wildcard: 0.0.0.15
- =>
- Network: 10.47.10.48/28
- HostMin: 10.47.10.49
- HostMax: 10.47.10.62
- Broadcast: 10.47.10.63
- Hosts/Net: 14 Class A, Private Internet
- root@bt:~#
The switches used in the above command include -n for no ANSI color output and -b for no binary output. The binary output may be useful for some but personally I would rarely need such output so I always use -b to surpress it. The example below is the exact same command without the -b switch.
ipcalc : Basic Usage With Binary Output
- root@bt:~# ipcalc -n 10.47.10.59/28
- Address: 10.47.10.59 00001010.00101111.00001010.0011 1011
- Netmask: 255.255.255.240 = 28 11111111.11111111.11111111.1111 0000
- Wildcard: 0.0.0.15 00000000.00000000.00000000.0000 1111
- =>
- Network: 10.47.10.48/28 00001010.00101111.00001010.0011 0000
- HostMin: 10.47.10.49 00001010.00101111.00001010.0011 0001
- HostMax: 10.47.10.62 00001010.00101111.00001010.0011 1110
- Broadcast: 10.47.10.63 00001010.00101111.00001010.0011 1111
- Hosts/Net: 14 Class A, Private Internet
- root@bt:~#
One other option that ipcalc provides that is pretty cool is the ability to output numerous network size configurations which could assist you in setting up a network. The -s switch allows you to specify the number of hosts needed in a network and will take up to three different amounts of hosts. If you were trying to determine what the subnet mask would be if you needed say 1000 hosts in a subnet, 2000 hosts in a subnet, or 3000 hosts in a subnet. In the example below we show use of the -s switch which again could assist in network architecture or planning.
ipcalc : Example For Network Architecture & Network Planning
- root@bt:~# ipcalc -s 1000 2000 3000 192.168.1.1/16
- Address: 192.168.1.1 11000000.10101000. 00000001.00000001
- Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000
- Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111
- =>
- Network: 192.168.0.0/16 11000000.10101000. 00000000.00000000
- HostMin: 192.168.0.1 11000000.10101000. 00000000.00000001
- HostMax: 192.168.255.254 11000000.10101000. 11111111.11111110
- Broadcast: 192.168.255.255 11000000.10101000. 11111111.11111111
- Hosts/Net: 65534 Class C, Private Internet
- 1. Requested size: 1000 hosts
- Netmask: 255.255.252.0 = 22 11111111.11111111.111111 00.00000000
- Network: 192.168.24.0/22 11000000.10101000.000110 00.00000000
- HostMin: 192.168.24.1 11000000.10101000.000110 00.00000001
- HostMax: 192.168.27.254 11000000.10101000.000110 11.11111110
- Broadcast: 192.168.27.255 11000000.10101000.000110 11.11111111
- Hosts/Net: 1022 Class C, Private Internet
- 2. Requested size: 2000 hosts
- Netmask: 255.255.248.0 = 21 11111111.11111111.11111 000.00000000
- Network: 192.168.16.0/21 11000000.10101000.00010 000.00000000
- HostMin: 192.168.16.1 11000000.10101000.00010 000.00000001
- HostMax: 192.168.23.254 11000000.10101000.00010 111.11111110
- Broadcast: 192.168.23.255 11000000.10101000.00010 111.11111111
- Hosts/Net: 2046 Class C, Private Internet
- 3. Requested size: 3000 hosts
- Netmask: 255.255.240.0 = 20 11111111.11111111.1111 0000.00000000
- Network: 192.168.0.0/20 11000000.10101000.0000 0000.00000000
- HostMin: 192.168.0.1 11000000.10101000.0000 0000.00000001
- HostMax: 192.168.15.254 11000000.10101000.0000 1111.11111110
- Broadcast: 192.168.15.255 11000000.10101000.0000 1111.11111111
- Hosts/Net: 4094 Class C, Private Internet
- Needed size: 7168 addresses.
- Used network: 192.168.0.0/19
- Unused:
- 192.168.28.0/22
- 192.168.32.0/19
- 192.168.64.0/18
- 192.168.128.0/17
- root@bt:~#
Last but not least ipcalc can output results to HTML though it is noted in the ipcalc documentation that the HTML portion is not completed. This may be useful if you created a custom system to track IP (Internet Protocol) address space for a large organization or something. Below there is an example of the command you would issue to output a single addresses information to HTML followed by a screenshot of what the HTML page looks like.
ipcalc : Basic Usage Output To HTML
- root@bt:~# ipcalc -n -b -h 10.47.10.59/28
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
- <title>
- 10.47.10.59/28</title>
- </head>
- <body>
- <!-- Version 0.41 -->
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td><tt><font color="#000000">Address:&nbsp;&nbsp;&nbsp;&nbsp;</font></tt></td>
- <td><tt><font color="#0000ff">10.47.10.59&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></tt></td>
- </tr>
- <tr>
- <td><tt><font color="#000000">Netmask: </font></tt></td>
- <td><tt><font color="#0000ff">255.255.255.240 = 28 </font></tt></td>
- </tr>
- <tr>
- <td><tt><font color="#000000">Wildcard: </font></tt></td>
- <td><tt><font color="#0000ff">0.0.0.15 </font></tt></td>
- </tr>
- <tr>
- <td colspan="3"><tt>=></tt></td>
- </tr>
- <tr>
- <td><tt><font color="#000000">Network:&nbsp;&nbsp;&nbsp;&nbsp;</font></tt></td>
- <td><tt><font color="#0000ff">10.47.10.48/28&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></tt></td>
- </tr>
- <tr>
- <td><tt><font color="#000000">HostMin: </font></tt></td>
- <td><tt><font color="#0000ff">10.47.10.49 </font></tt></td>
- </tr>
- <tr>
- <td><tt><font color="#000000">HostMax: </font></tt></td>
- <td><tt><font color="#0000ff">10.47.10.62 </font></tt></td>
- </tr>
- <tr>
- <td><tt><font color="#000000">Broadcast: </font></tt></td>
- <td><tt><font color="#0000ff">10.47.10.63 </font></tt></td>
- </tr>
- <tr>
- <td valign="top"><tt><font color="#000000">Hosts/Net: </font></tt></td>
- <td valign="top"><tt><font color="#0000ff">14 </font></tt></td>
- <td><font color="#009900">Class A</font><font color="#000000">, <a href="http://www.ietf.org/rfc/rfc1918.txt">Private Internet</a></font></td>
- </tr>
- </table>
- <p>
- <a href="http://validator.w3.org/check/referer"><img border="0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- </p>
- root@bt:~#
ipcalc : Basic Usage Output To HTML
One of the great things about ipcalc is that it is written in Perl so it is easy to make modifications to the code. I made a small change to the code so when results are output to HTML it includes the IP Address/Netmask as the title of the HTML page itself.
Anyhow this is a great little tool and while it is super basic and not fancy I believe if more people were aware of ipcalc it would get more use. Unfortunately it is one of the many gems in Backtrack that gets overlooked.
Click here for more information about ipcalc or click here for more Kali Linux articles.