On this page
IP version 6 address format explained
IPv4 addresses are 32 bits long and written as four decimal numbers, like 192.0.2.10. IPv6 addresses are four times as long, 128 bits, so decimal would be far too long to read. They are written in hexadecimal instead.
The 128 bits are cut into eight groups of 16 bits. Each group is four hex digits (0 to 9 and a to f), and colons separate the groups. Here is one address in its full form:
2001:0db8:0000:0000:0000:ff00:0042:8329Four hex digits, which is 16 bits.
A colon sits between every two groups, seven in total.
Eight groups make the full 128 bits.
Nobody types that out in daily use. The same address in its usual short form is 2001:db8::ff00:42:8329. Both strings mean exactly the same 128 bits. The rules for getting from one to the other are next.
How do you shorten an IPv6 address?
Two rules come from the IPv6 addressing architecture in RFC 4291. A later standard, RFC 5952, tightens them so every address has one recommended way to be written.
Rule one: drop leading zeros in each group
Zeros at the start of a group can go. 0db8 becomes db8, 0042 becomes 42 and 0000 becomes 0. Zeros at the end of a group must stay: ff00 is ff00, never ff.
2001:0db8:0000:0000:0000:ff00:0042:8329
2001:db8:0:0:0:ff00:42:8329Rule two: use :: once for the longest run of zero groups
A double colon replaces one or more groups that are all zeros. You may use it only once per address, because otherwise nobody could tell how many zero groups each :: stands for.
2001:db8:0:0:0:ff00:42:8329
2001:db8::ff00:42:8329RFC 5952 adds three details for the recommended form: put :: on the longest run of zero groups, pick the leftmost run when two are the same length, and do not use :: for a single zero group. It also recommends lowercase letters.
Valid and invalid IPv6 format examples
| Address | Result | Why |
|---|---|---|
| 2001:db8:0:0:0:ff00:42:8329 | Valid | Leading zeros removed, no :: used |
| 2001:db8::ff00:42:8329 | Valid | :: stands in for three zero groups |
| 2001:db8::1:0:0:1 | Valid | Two runs of zeros tie, so :: goes on the leftmost one |
| ::1 | Valid | Seven zero groups, then 1 (the loopback address) |
| :: | Valid | All 128 bits are zero (the unspecified address) |
| 2001:db8::ff:42:8329 | Valid, but a different address | Trailing zeros of ff00 were dropped, which changes the value |
| 2001:db8::1::1 | Invalid | :: appears twice |
| 2001:db8:ff00:42:8329 | Invalid | Only five groups and no :: to fill the gap |
| 2001:db8:0:ff00:42:8329:1:2:3 | Invalid | Nine groups, one too many |
| 2001:db8::ff001:1 | Invalid | A group has five hex digits |
| 2001:db8::fg00:1 | Invalid | g is not a hex digit |
If you want to expand a short address back to all eight groups, Python's standard library can do it in one line:
python3 -c "import ipaddress; print(ipaddress.ip_address('2001:db8::ff00:42:8329').exploded)"It prints 2001:0db8:0000:0000:0000:ff00:0042:8329. Use .compressed instead of .exploded to get the short form.
Which IPv6 address types will you see?
The first bits of an address tell you what kind it is. Here are IPv6 addresses examples for the types you will meet most often. The IANA special-purpose address registry lists every reserved range.
| Type | Prefix | Example | Where you see it |
|---|---|---|---|
| Global unicast | 2000::/3 | 2001:db8:abcd:12::1a2b | Public addresses on the internet; they start with 2 or 3 |
| Link-local | fe80::/10 | fe80::1a2b:3c4d:5e6f:7a8b | Every IPv6 interface, valid only on the local link |
| Unique local | fc00::/7 | fd12:3456:789a:1::1 | Private internal networks, in practice always starting with fd |
| Loopback | ::1/128 | ::1 | The machine talking to itself, like 127.0.0.1 |
| Documentation | 2001:db8::/32 | 2001:db8::ff00:42:8329 | Examples in guides and manuals, never routed |
| IPv4-mapped | ::ffff:0:0/96 | ::ffff:192.0.2.1 | Dual-stack software showing an IPv4 client in IPv6 form |
Global unicast addresses
These are the public IPv6 addresses your provider gives you, the IPv6 version of a public IPv4 address. The /3 prefix means only the first three bits are fixed (001), so every global address today starts with the hex digit 2 or 3.
Link-local addresses starting with fe80
Every interface with IPv6 turned on creates one by itself, with or without a router. Devices use it to find neighbours and the router on the same link. Routers never forward it. Because the same fe80 address can exist on several interfaces, you often see a zone index after it, such as fe80::1a2b:3c4d:5e6f:7a8b%eth0.
Unique local addresses
Unique local addresses play the role that 10.0.0.0/8 and 192.168.0.0/16 play in IPv4. The range is fc00::/7, but only the fd00::/8 half is in use: you pick a random 40-bit ID after fd so two private networks are unlikely to clash if they ever merge.
Loopback, documentation and IPv4-mapped addresses
::1 is the loopback address. 2001:db8::/32 is reserved for documentation by RFC 3849, which is why it appears in examples like this post. IPv4-mapped addresses put a full IPv4 address in the last 32 bits after ::ffff:. You will see them in server logs when a dual-stack program accepts an IPv4 connection, for example ::ffff:203.0.113.5.
Writing docs, tests or sample configs? Use 2001:db8::/32 for IPv6 examples, just as you would use 192.0.2.0/24 for IPv4. Nobody's real network sits in that range.
How does the prefix length split an IPv6 address?
Like IPv4 CIDR notation, an IPv6 address can carry a slash and a number. The number says how many bits from the left belong to the network. The rest identify one interface on that network.
2001:db8:abcd:12::1a2b/64Bits 1 to 32, here the documentation /32.
Bits 33 to 48. A /48 is a common size for one site.
Bits 49 to 64, so one site can have 65,536 subnets.
The last 64 bits, which name one device on the subnet.
With /64, the network is 2001:db8:abcd:12::/64 and the interface ID is the last four groups, 0000:0000:0000:1a2b. /64 is the standard size for a single LAN: automatic address setup (SLAAC) expects a 64-bit interface ID.
The handy part is that 64 is a multiple of 16. Each group is 16 bits, so a /64 always ends after the fourth group, a /48 after the third and a /32 after the second. Prefixes like /56 split a group in the middle: in a /56 the network ends after the first two hex digits of the fourth group.
How to check an IPv6 address yourself
Reading about addresses only gets you so far. These three Pingie tools let you look at real ones.
Enter an IPv4 address to get its IPv4-mapped, compressed mapped, 6to4 and deprecated IPv4-compatible IPv6 forms. Enter an IPv6 address to pull out any IPv4 address embedded in it.
Shows the IPv4 and IPv6 address your connection uses. If the IPv6 field says not detected, your connection reached the site over IPv4.
Looks up a domain's AAAA and A records, lists the addresses, and tries to reach the first IPv6 address on port 80, then 443.
For example, type 192.0.2.1 into the IP Converter and you get ::ffff:192.0.2.1 as the IPv4-mapped form and 2002:c000:201:: as the 6to4 form. Paste a native address such as 2001:db8::ff00:42:8329 instead and the tool tells you it has no IPv4 equivalent, since only mapped, 6to4, NAT64 and IPv4-compatible addresses carry one.
To see what your own device uses, open What Is My IP. To check whether a site publishes an IPv6 address at all, run its domain through the IPv6 Website Test: an AAAA record alone does not prove the site is reachable over IPv6, which is why the tool also tries a connection. If you wonder why so many sites still have no AAAA record, our post on IPv6 adoption covers the slow transition.
IP ConverterSee the IPv4-mapped and 6to4 forms of any IPv4 address
IPv6 Website TestCheck a domain's AAAA records and IPv6 reachability
Frequently asked questions
A fully expanded IPv6 address has 39 characters: 32 hex digits plus 7 colons. Shortened forms are shorter, down to just two characters for ::. When the last 32 bits are written as a dotted IPv4 address, the longest form reaches 45 characters, which is why database columns for IP addresses are often sized at 45.
No. The double colon may appear only once. With two of them, like 2001:db8::1::1, nobody could tell how many zero groups each one replaces, so the address would be ambiguous. Use :: on the longest run of zero groups and write any other zero groups as a single 0.
That is a link-local address. Every interface with IPv6 enabled creates one automatically, even without a router or internet access. Your device uses it to talk to neighbours and the router on the same network. It is never routed beyond that link, so seeing only fe80 means you have no global IPv6 address yet.
No. 2001:DB8::A and 2001:db8::a are the same address, because hex digits mean the same value in either case. RFC 5952 recommends writing them in lowercase so addresses look the same everywhere, which makes searching logs and comparing configs easier. Most tools print lowercase by default.
Put the address in square brackets, then add the port after a colon: http://[2001:db8::1]:8080/. The brackets are needed because the address itself is full of colons, so without them a browser could not tell where the address ends and the port begins. Without a port, keep the brackets: http://[2001:db8::1]/.