IPv4 Address Calculator

IP address/mask length:
network address: netmask address:
broadcast address: count: 256
reverse name:


current IPv4 addresses 0.0-255.0-255.0-255
class A private IPv4 addresses 10.0-255.0-255.0-255
shared IPv4 addresses 100.64-127.0-255.0-255
loopback IPv4 addresses 127.0-255.0-255.0-255
link-local IPv4 addresses 169.254.0-255.0-255
class B private IPv4 addresses 172.16-31.0-255.0-255
IETF protocol IPv4 addresses
dual-stack lite IPv4 addresses
test-net-1 IPv4 addresses
benchmark IPv4 addresses 198.18-19.0-255.0-255
test-net-2 IPv4 addresses
deplicated 6to4 IPv4 addresses
class C private IPv4 addresses 192.168.0-255.0-255
test-net-3 IPv4 addresses
class D multicast IPv4 addresses 224-239.0-255.0-255.0-255
class E reserved IPv4 addresses 240-255.0-255.0-255.0-255
limited broadcast IPv4 addresses 240-255.0-255.0-255.0-255

IPv4 | IPv6


string - IPv4 address string
number - IPv4 address number
h - shift-left count
Return value
inet_aton returns 32-bit integer value of IPv4 address.
inet_ntoa returns string of IPv4 address.
inet_mask returns 32-bit integer value of IPv4 netmask address.
inet_ntoa_reverse returns domain name of IPv4 address for reverse lookup.
inet_aton(""); // 65535
inet_ntoa(65535); // ""
inet_mask(8); // -256 == 0xffffff00
inet_ntoa_reverse(65535); // ""


To get the network address and the broadcast address from, the 32-bit interger \(w\) such as \[ \begin{aligned} w &= \text{}\\ &= \underbrace{\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}.\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}.\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}.\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}}_{32\text{-bit}}\\ &= \lnot 0 \land (\text{ffffffff})_{16}. \end{aligned} \] The network address \(n\) and the broadcast address \(b\) are obtained as follows: \[ \begin{aligned} n &= a \land (w \ll (32 - l) \land w) = \text{},\\ b &= a \lor \lnot(w \ll (32 - l) \land w) = \text{}, \end{aligned} \] where \(\ll\) means logical shift left, \(a = \text{}\), \(l = 24\) and \(w\ll (32 - l) = \text{} \land w\) means the netmask address such as \[ \begin{aligned} h &= 32 - l,\\ w \ll h \land w &= \underbrace{\underbrace{\text{11111111}_{(2)}.\text{11111111}_{(2)}.\text{11111111}_{(2)}}_{l(24)\text{-bit}}.\underbrace{\text{00000000}_{(2)}}_{h(8)\text{-bit}}}_{32\text{-bit}}\\ &= \text{}. \end{aligned} \] The address \(a\) is represented by the network part and the host part as follows: \[ \begin{aligned} a &= \text{}/24,\\ &= \underbrace{\text{11000000}_{(2)}.\text{10101000}_{(2)}.\text{00000000}_{(2)}}_{l(24)\text{-bit network part}}.\underbrace{\text{00000001}_{(2)}}_{h(8)\text{-bit host part}}\\ \end{aligned} \]

The number of addresses \(N\) is clearly \[ \begin{aligned} N &= 2^{32 - l} = 2^h\\ &= 2^8 = 256. \end{aligned} \]

Reverse lookup .in-addr.arpa domain name is a 32-bit address with 8 bits each in reverse order and join them with a period in decimal such as \[ \begin{aligned} &\text{``''}. \end{aligned} \]

Written by Taiji Yamada <taiji@aihara.co.jp>