IPv6 Address Calculator

IP address/mask length: redundant: 0:0:0:0:0:0:ffff:192.168.0.0/120
network address: ::ffff:192.168.0.0 netmask address: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00
broadcast address: ::ffff:192.168.0.255 count: 256
reverse name: 0.0.0.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa

Preset

current IPv4-mapped IPv6 addresses 0.0-255.0-255.0-255
class A private IPv4-mapped IPv6 addresses 10.0-255.0-255.0-255
shared IPv4-mapped IPv6 addresses 100.64-127.0-255.0-255
loopback IPv4-mapped IPv6 addresses 127.0-255.0-255.0-255
link-local IPv4-mapped IPv6 addresses 169.254.0-255.0-255
class B private IPv4-mapped IPv6 addresses 172.16-31.0-255.0-255
IETF protocol IPv4-mapped IPv6 addresses 192.0.0.0-255
dual-stack lite IPv4-mapped IPv6 addresses 192.0.0.0-7
test-net-1 IPv4-mapped IPv6 addresses 192.0.2.0-255
benchmark IPv4-mapped IPv6 addresses 198.18-19.0-255.0-255
test-net-2 IPv4-mapped IPv6 addresses 198.51.100.0-255
deplicated 6to4 IPv4-mapped IPv6 addresses 192.88.99.0-255
class C private IPv4-mapped IPv6 addresses 192.168.0-255.0-255
test-net-3 IPv4-mapped IPv6 addresses 203.0.113.0-255
class D multicast IPv4-mapped IPv6 addresses 224-239.0-255.0-255.0-255
class E reserved IPv4-mapped IPv6 addresses 240-255.0-255.0-255.0-255
limited broadcast IPv4-mapped IPv6 addresses 240-255.0-255.0-255.0-255
unspecified IPv6 addresses ::
loopback IPv6 addresses ::1
IPv4-mapped IPv6 addresses ::ffff:0-255.0-255.0-255.0-255
IPv4 translators IPv6 addresses 64:ff9b::-ffff:-ffff
discard-only IPv6 addresses 100::-ffff:-ffff:-ffff:-ffff
IETF protocol IPv6 addresses 2001:-1ff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
teredo IPv6 addresses 2001:0:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
benchmark IPv6 addresses 2001:2:0:-ffff:-ffff:-ffff:-ffff:-ffff
documentation IPv6 addresses 2001:db8:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
ORCHID IPv6 addresses 2001:10-1f:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
deplicated 6to4 IPv6 addresses 2002:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
unique-local IPv6 addresses fc00-fdff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
linked-scoped unicast IPv6 addresses fe80-febf:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff

IPv4 | IPv6

Javascript

Systax
inet64_aton(string)
inet6_aton(string)
inet64_ntoa(number)
inet6_ntoa(number)
inet6_mask(h)
inet6_ntoa_reverse(number)
Parameters
string - IPv6 address string
number - IPv6 address number
h - shift-left count
Return value
inet64_aton returns 8 elements of 16-bit integer value of IPv4-mapped IPv6 address if string is "::ffff:*.*.*.*", otherwise inet6_aton.
inet6_aton returns 8 elements of 16-bit integer value of IPv6 address.
inet64_ntoa returns string of IPv4-mapped IPv6 address if number is [ 0, 0, 0, 0, 0, 0xffff, 0-0xffff, 0-0xffff ], otherwise inet6_ntoa.
inet6_ntoa returns string of IPv6 address.
inet6_mask returns 8 elements of 16-bit integer value of IPv6 netmask address.
inet6_ntoa_reverse returns domain name of IPv6 address for reverse lookup.
Usage
inet64_aton("::ffff:255.255.255.255"); // [ 0, 0, 0, 0, 0, 65535, 65535, 65535 ]
inet64_ntoa([ 0, 0, 0, 0, 0, 65535, 65535, 65535 ]); // "::ffff:255.255.255.255"
inet6_aton("fe80::").map(e => e.toString(16)); // [ "fe80", "0", "0", "0", "0", "0", "0", "0" ]
inet6_ntoa([ "fe80", "0", "0", "0", "0", "0", "0", "0" ].map(e => parseInt(e, 16))); // "fe80::0:"
inet6_mask(16).map(e => e.toString(16)); // [ "ffff", "ffff", "ffff", "ffff", "ffff", "ffff", "ffff", "0" ]
inet6_ntoa_reverse([ "fe80", "0", "0", "0", "0", "0", "0", "0" ].map(e => parseInt(e, 16))); // "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa"

Calculate

To get the network address ::ffff:192.168.0.0 and the broadcast address ::ffff:192.168.0.255 from ::ffff:192.168.0.1/120, the 8 elements of 16-bit integer value \(w\) such as \[ \begin{aligned} w &= \underbrace{\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}}_{128\text{-bit}}\\ &= \left(\underbrace{\lnot 0 \land \text{ffff}_{(16)}, \lnot 0 \land \text{ffff}_{(16)}, ...}_{i=0, 1, 2, \cdots, 7}\right). \end{aligned} \] The network address \(n\) and the broadcast address \(b\) are obtained as follows: \[ \begin{aligned} n &= a \land (w \ll (128 - l) \land w) = \text{::ffff:192.168.0.0},\\ b &= a \lor \lnot(w \ll (128 - l) \land w) = \text{::ffff:192.168.0.255}, \end{aligned} \] where \(\ll\) means logical shift left, \(a = \text{::ffff:192.168.0.1}\), \(l = 120\) and \(w\ll (128 - l) \land w = \text{ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00}\) means the netmask address, generally obtained by \[ \begin{aligned} h &= 128 - l,\\ j &= \lfloor h/16\rfloor,\\ k &= h\mod 16,\\ w\ll h \land w &= \left(\underbrace{\text{ffff}_{(16)}, \cdots\text{or }\emptyset, }_{i=0,\cdots\;(i < 7-j)}\underbrace{\text{ffff}_{(16)}\ll k\land\text{ffff}_{(16)}, }_{\phantom{(}i = 7-j\phantom{)}}\underbrace{\,\emptyset\text{ or }\text{0000}_{(16)}, \cdots}_{(7-j < i)\;i=\cdots, 7}\right). \end{aligned} \] The address \(a\) is represented by the network part and the host part as follows: \[ \begin{aligned} a &= \text{::ffff:192.168.0.1},\\ &= \underbrace{\text{0000}_{(16)}:\text{0000}_{(16)}:\text{0000}_{(16)}:\text{0000}_{(16)}:\text{0000}_{(16)}:\text{ffff}_{(16)}:\text{11000000}_{(2)}.\text{10101000}_{(2)}.\text{00000000}_{(2)}}_{l(120)\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^{128 - l} = 2^h\\ &= 2^8 = 256. \end{aligned} \]

Reverse lookup .ip6.arpa domain name is a 128-bit address with 4 bits each in reverse order and join them with a period in hexadecimal such as \[ \begin{aligned} &\text{``1.0.0.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa''}. \end{aligned} \]

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