What changes when the address is IPv6
For the lookup itself, very little changes. We asked the IPCheckHQ API about 203.0.113.7 and 2001:db8::1, which are reserved for documentation in IPv4 and IPv6, and the two responses had identical field paths. What changes is the address you feed in: its length, the ways it can be written, and which special ranges it can fall into. The rest of this page checks each of those against real output.
$ curl -s https://ipcheckhq.com/api/v1/ip/203.0.113.7 | jq -c '{ip, version, special_range}'
{"ip":"203.0.113.7","version":4,"special_range":"documentation"}
$ curl -s https://ipcheckhq.com/api/v1/ip/2001:db8::1 | jq -c '{ip, version, special_range}'
{"ip":"2001:db8::1","version":6,"special_range":"documentation"}
$ diff <(curl -s https://ipcheckhq.com/api/v1/ip/203.0.113.7 | jq -c '[paths|map(tostring)|join(".")]') \
<(curl -s https://ipcheckhq.com/api/v1/ip/2001:db8::1 | jq -c '[paths|map(tostring)|join(".")]') \
&& echo "identical field paths"
identical field pathsBoth responses list location and network as unavailable, which is what you would expect for a range that no network owns. The version field states the family explicitly, so a consumer that branches on IPv4 versus IPv6 can read it rather than guess from the presence of a colon.
| Property | IPv4 | IPv6 |
|---|---|---|
| Length | 32 bits | 128 bits |
| Possible addresses | 2^32 = 4,294,967,296 | 2^128 = 340,282,366,920,938,463,463,374,607,431,768,211,456 |
| Written as | Four decimal numbers separated by dots | Up to eight hexadecimal groups separated by colons, with one optional :: |
| Reserved for documentation | 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | 2001:db8::/32 |
| Reverse DNS zone | in-addr.arpa | ip6.arpa, one label per hexadecimal digit |
The lengths come from the address architecture and the IPv6 specification, the two documentation ranges from RFC 5737 and RFC 3849, and the counts are 2 raised to the length, which we computed with Python (shown below). The reverse zones are visible in the Python output on this page.
How to read an IPv6 address
An IPv6 address is eight groups of up to four hexadecimal digits, separated by colons. Two shortening rules apply: leading zeros inside a group may be dropped, and one run of all-zero groups may be replaced by a double colon, but only once per address. That is why 2001:0db8:0000:0000:0000:0000:0000:0001 and 2001:db8::1 are the same address.
Because one address has many valid spellings, RFC 5952 recommends a single canonical text form: drop leading zeros, replace the longest run of zero groups with a double colon (the first run if two tie) but never a single zero group, and write the letters a to f in lowercase. Software should accept any valid spelling and write this one.
Python's ipaddress module shows the views of one address side by side. The last value is the name you query for reverse DNS: one label per hexadecimal digit of the fully expanded address, which is also the form used for DNS-based ASN lookups in our ASN article.
$ python3 -c "import ipaddress as i; a=i.ip_address('2001:db8::1'); print(a.exploded, a.compressed, a.reverse_pointer)"
2001:0db8:0000:0000:0000:0000:0000:0001 2001:db8::1 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa
$ python3 -c "import ipaddress as i; print(i.ip_address('8.8.8.8').reverse_pointer)"
8.8.8.8.in-addr.arpaThe size of the space is the other thing that changes. Interface identifiers in most unicast addresses are 64 bits long, so one IPv6 subnet is normally a /64, and a single /64 holds 2^64 addresses. That is 4,294,967,296 times the number of addresses in the whole IPv4 space.
$ python3 -c "print(2**32); print(2**128); print(2**64); print(2**64 // 2**32)"
4294967296
340282366920938463463374607431768211456
18446744073709551616
4294967296Normalise before you store or compare
A lookup that echoes the address it parsed makes normalisation visible. We sent three spellings of one IPv6 address and the IPv4-mapped form of 203.0.113.7.
$ for a in 2001:0db8:0000:0000:0000:0000:0000:0001 2001:DB8:0:0:0:0:0:1 2001:db8::1 ::ffff:203.0.113.7; do
printf '%s -> ' "$a"; curl -s "https://ipcheckhq.com/api/v1/ip/$a" | jq -c '[.ip, .version]'
done
2001:0db8:0000:0000:0000:0000:0000:0001 -> ["2001:db8::1",6]
2001:DB8:0:0:0:0:0:1 -> ["2001:db8::1",6]
2001:db8::1 -> ["2001:db8::1",6]
::ffff:203.0.113.7 -> ["203.0.113.7",4]All three IPv6 spellings came back as 2001:db8::1. The mapped form came back as the IPv4 address 203.0.113.7 with version 4. RFC 4291 defines the mapped form as 80 zero bits, then 16 one bits, then the IPv4 address. Collapsing it to IPv4 is how this API treats it. A library may not, as the next run shows.
$ cat mapped.py
import ipaddress as i
mapped = i.ip_address("::ffff:203.0.113.7")
plain = i.ip_address("203.0.113.7")
print(str(mapped))
print(mapped == plain)
print(mapped.ipv4_mapped)
try:
print(sorted([i.ip_address("203.0.113.7"), i.ip_address("2001:db8::1")]))
except TypeError as error:
print("sorted ->", error)
$ python3 mapped.py
::ffff:cb00:7107
False
203.0.113.7
sorted -> 2001:db8::1 and 203.0.113.7 are not of the same versionHere the mapped and plain forms are different strings and different objects, so a rate limit, allowlist or deduplication keyed on the raw value would count one visitor twice. Sorting a list that mixes both families also failed with a TypeError. Normalise once, at the boundary where an address enters your system.
$ cat normalise.py
import ipaddress
def normalise(text):
address = ipaddress.ip_address(text.strip())
if address.version == 6 and address.ipv4_mapped:
address = address.ipv4_mapped
return str(address)
for sample in ["2001:0db8:0000:0000:0000:0000:0000:0001", "2001:DB8:0:0:0:0:0:1", "::ffff:203.0.113.7", "203.0.113.7", "[2001:db8::1]:8080"]:
try:
print(f"{sample:42} -> {normalise(sample)}")
except ValueError as error:
print(f"{sample:42} -> ValueError: {error}")
$ python3 normalise.py
2001:0db8:0000:0000:0000:0000:0000:0001 -> 2001:db8::1
2001:DB8:0:0:0:0:0:1 -> 2001:db8::1
::ffff:203.0.113.7 -> 203.0.113.7
203.0.113.7 -> 203.0.113.7
[2001:db8::1]:8080 -> ValueError: '[2001:db8::1]:8080' does not appear to be an IPv4 or IPv6 addressThe last line is deliberate. Some proxies, for example an Application Load Balancer with client port preservation, write an IPv6 address in square brackets with a port appended, and the parser rejects that. Strip the brackets and port first. Our X-Forwarded-For article shows where those forms appear and how to handle them.
Special ranges have their own labels in each family
The special_range field labels addresses that are not ordinary public addresses. We ran five IPv6 examples, plus two IPv4 addresses for comparison.
$ for a in ::1 fe80::1 fd00::1 2002:cb00:7107::1 64:ff9b::203.0.113.7 10.0.0.1 100.64.1.1; do
printf '%s -> ' "$a"; curl -s "https://ipcheckhq.com/api/v1/ip/$a" | jq -c '[.ip, .version, .special_range]'
done
::1 -> ["::1",6,"loopback"]
fe80::1 -> ["fe80::1",6,"link-local"]
fd00::1 -> ["fd00::1",6,"unique-local"]
2002:cb00:7107::1 -> ["2002:cb00:7107::1",6,"translation"]
64:ff9b::203.0.113.7 -> ["64:ff9b::cb00:7107",6,"translation"]
10.0.0.1 -> ["10.0.0.1",4,"private"]
100.64.1.1 -> ["100.64.1.1",4,"shared-cgnat"]
$ curl -s -o /dev/null -w 'CIDR 2001:db8::/32 -> HTTP %{http_code}\n' 'https://ipcheckhq.com/api/v1/ip/2001:db8::/32'
CIDR 2001:db8::/32 -> HTTP 404
$ curl -s 'https://ipcheckhq.com/api/v1/ip/2001:db8::/32' | jq -c .
{"success":false,"error":{"code":"NOT_FOUND","message":"Unknown API endpoint. See /openapi.json."}}| Input | API label | What the RFC says about the prefix |
|---|---|---|
| ::1 | loopback | Loopback address. A node uses it to send packets to itself, and such packets must not leave the node (RFC 4291). |
| fe80::1 | link-local | Inside fe80::/10. Routers must not forward packets with link-local source or destination addresses to other links (RFC 4291). |
| fd00::1 | unique-local | Inside the unique local range fc00::/7, intended for local communications, routable inside a more limited area such as a site, and not expected to be routable on the global Internet (RFC 4193). |
| 2002:cb00:7107::1 | translation | Inside 2002::/16, the 6to4 prefix, where the next 32 bits carry an IPv4 address (RFC 3056). The label "translation" is this API's wording, not the RFC's. |
| 64:ff9b::203.0.113.7 | translation | Inside the well-known prefix 64:ff9b::/96, which maps an IPv4 address into the last 32 bits (RFC 6052). |
The prefixes in the table come from RFC 4291 (loopback and link-local), RFC 4193 (unique local), RFC 3056 (6to4) and RFC 6052 (the 64:ff9b prefix).
For comparison, the API labelled 10.0.0.1 private and 100.64.1.1 shared-cgnat. RFC 6598 reserves 100.64.0.0/10 as shared address space for carrier-grade NAT between a provider's CGN devices and customer premises equipment. This article does not go further into those IPv4 ranges.
Of the three inputs that carry an IPv4 address, the mapped form was handled differently from the other two. The mapped address from the previous section came back as IPv4 with the documentation label. The translation-prefix address stayed IPv6 and was printed with the IPv4 part in hexadecimal (64:ff9b::cb00:7107, the same form Python printed), and the label said translation, not documentation. The response did not report the embedded IPv4 address as a field; it appears only inside the hexadecimal ip value. If you need it from a 64:ff9b address, take the last 32 bits yourself; RFC 6052 places it there for a /96 prefix. The 6to4 address 2002:cb00:7107::1 behaved like the 64:ff9b one: it stayed IPv6, kept its own text, and was labelled translation. RFC 3056 puts the IPv4 address in bits 17 to 48, not the last 32. The API groups 6to4 under translation even though 6to4 is a tunnelling mechanism (RFC 3056); that label is the API's wording.
A CIDR block is not an address. Requesting 2001:db8::/32 returned HTTP 404 with an Unknown API endpoint message. The slash adds a path segment that matches no route, so this is a routing 404 and not a verdict on the prefix. The endpoint takes one address, so look up an address inside the block instead.
A location estimate belongs to an address, not a host
One operator often runs both families, and DNS ties them together by name. The first run below shows one name with both record types, and the same reverse DNS name for 8.8.8.8 and 2001:4860:4860::8888. The second looks up three IPv4 and IPv6 pairs in the IPCheckHQ API.
$ dig @1.1.1.1 +short A one.one.one.one
1.1.1.1
1.0.0.1
$ dig @1.1.1.1 +short AAAA one.one.one.one
2606:4700:4700::1111
2606:4700:4700::1001
$ dig @1.1.1.1 +short -x 8.8.8.8
dns.google.
$ dig @1.1.1.1 +short -x 2001:4860:4860::8888
dns.google.$ for a in 1.1.1.1 2606:4700:4700::1111 103.102.166.224 2001:df2:e500:ed1a::1 8.8.8.8 2001:4860:4860::8888; do
curl -s "https://ipcheckhq.com/api/v1/ip/$a" | jq -c '{ip, version, rdns: .reverse_dns, asn: .network.asn, country: .location.country_code, city: .location.city, tz: .location.timezone, agree: .agreement.country}'
done
{"ip":"1.1.1.1","version":4,"rdns":"one.one.one.one","asn":13335,"country":"AU","city":"Sydney","tz":"Australia/Sydney","agree":"single-source"}
{"ip":"2606:4700:4700::1111","version":6,"rdns":"one.one.one.one","asn":13335,"country":"CA","city":"Montreal","tz":"America/Toronto","agree":"single-source"}
{"ip":"103.102.166.224","version":4,"rdns":"text-lb.eqsin.wikimedia.org","asn":14907,"country":"US","city":"San Francisco (Financial District)","tz":"America/Los_Angeles","agree":"single-source"}
{"ip":"2001:df2:e500:ed1a::1","version":6,"rdns":"text-lb.eqsin.wikimedia.org","asn":14907,"country":"JP","city":"Shinagawa","tz":"Asia/Tokyo","agree":"single-source"}
{"ip":"8.8.8.8","version":4,"rdns":"dns.google","asn":15169,"country":"US","city":"Mountain View","tz":"America/Los_Angeles","agree":"single-source"}
{"ip":"2001:4860:4860::8888","version":6,"rdns":"dns.google","asn":15169,"country":"CA","city":"Montreal","tz":"America/Toronto","agree":"single-source"}| Address | Version | Reverse DNS | ASN | Location estimate | Time zone |
|---|---|---|---|---|---|
| 1.1.1.1 | 4 | one.one.one.one | 13335 | AU, Sydney | Australia/Sydney |
| 2606:4700:4700::1111 | 6 | one.one.one.one | 13335 | CA, Montreal | America/Toronto |
| 103.102.166.224 | 4 | text-lb.eqsin.wikimedia.org | 14907 | US, San Francisco (Financial District) | America/Los_Angeles |
| 2001:df2:e500:ed1a::1 | 6 | text-lb.eqsin.wikimedia.org | 14907 | JP, Shinagawa | Asia/Tokyo |
| 8.8.8.8 | 4 | dns.google | 15169 | US, Mountain View | America/Los_Angeles |
| 2001:4860:4860::8888 | 6 | dns.google | 15169 | CA, Montreal | America/Toronto |
Within each pair the reverse DNS name and the ASN match, and the location estimate does not: the country differs in all three pairs, and the time zone changes with it. A shared reverse DNS name is a name set by whoever controls the reverse zone, so it does not show that both addresses sit on one machine. The estimate is a property of one address in one database, not of the host behind it. Do not copy an IPv4 result onto the IPv6 address of the same service, and be careful about deriving a visitor's time zone from either one.
Read this with the limits in mind. All six addresses are public infrastructure addresses, and we did not check where any of them is actually served. Every response reports its country agreement as single-source, which means only one data source supplied a value, so there was no second source to compare it with. The agreement.location_source field reads dbip. We compared three pairs and had no ground truth for where any of the traffic is served, so this does not show that IPv6 location estimates are better or worse than IPv4 ones. Reverse DNS and ASN matched within every pair and only the location fields differed; our ASN guide explains how to read the ASN, and the Learn page on ASNs covers the concept.
The lookup page is the quickest way to try your own addresses. The JSON API described on the developers page is what the runs above used: it accepts either family, normalises IPv6 input and returns the same fields for both.
