Introduction

ipcalc is a DHTML application that calculates all relevant aspects of a given IP address or network, given an IP address and a netmask specification. It's a pretty straightforward ripoff of Keith Owens' original Perl script, but all errors are my fault alone.

Several different items are displayed as a result of a query. Our example for purposes of explanation will use an IP from a fairly standard class C "private" network, 192.168.1.1/24. ipcalc is not limited to outdated conceptions of class, however — any RFC 1817-style VLSM will work, as well. New! Support for input of IP in hexadecimal format; just append the netmask at the end and separate them with a slash as before.

Example: 192.168.1.1/24

IP address 192 . 168 . 1 . 1 / 24 192.168.1.1/24
Netmask bits 11111111 11111111 11111111 00000000
Netmask bytes 255 . 255 . 255 . 0 255.255.255.0
Address bits 11000000 10101000 00000001 00000001
Network 192 . 168 . 1 . 0 192.168.1.0
Broadcast 192 . 168 . 1 . 255 192.168.1.255
First Host 192 . 168 . 1 . 1 192.168.1.1
Last Host 192 . 168 . 1 . 254 192.168.1.254
Total Hosts 254
PTR 1.1.168.192.in-addr.arpa
IP Address (hex) 0xc0a80101

IP Address

The first line in the output contains the original IP address you supplied, with subnet mask, formatted for easy comparison with the following.

Netmask Bits

The second line contains a representation of the netmask as a binary number.

Netmask Bytes

The third line contains a representation of the netmask as a "dotted quad", or the netmask expressed as four byte values separated by periods. This is the most common form in which IP addresses are seen in user space.

Address Bits

The fourth line contains a representation of the IP address as a binary number.

Network

The fifth line contains the network number based on the IP and netmask you supplied.

Broadcast

The sixth line contains the broadcast address (used for traffic that all hosts need to receive, such as ARP/RARP messages).

First Host

The seventh line contains the IP address in dotted quad format of the first host on the network named above.

Last Host

The eighth line contains the IP address in dotted quad format of the last host on the network named above.

Total Hosts

The ninth line gives the number of unique hosts possible on the network.

PTR

The tenth line gives the PTR, or "in-addr.arpa" record for the host or network named in the "IP Address" field.

IP Address (hex)

The final line gives a hexadecimal representation of the IP address listed in line one.

Note

Several of the fields (particularly those that use a preformatted dotted quad presentation) are also provided without the intervening spaces, for ease of cut-and-paste.

Credits

ipcalc was originally written by Keith Owens, as a Perl script. For kicks, I ported it to Javascript, with help from Google. I used and somewhat modified a Javascript printf() library that I found on what appears to be Shigenobu AOKI's Web site (I don't read Japanese, and the code wasn't in English). Thanks to Brent Verner and Greg Knauss for testing.