注:机翻,未校。
IPv6 for the remotely interested
Sedat Kapanoglu
Apr 16, 2024
I’ve known about IPv6 for the last two decades or so, but I’ve never gone beyond “an overengineered solution to the IPv4 address space problem”. IPv6 was even presented as “every atom could get its own IP address, no IP address shortages anymore”, but I didn’t know how true that was either. I occasionally saw an IPv6 address here and there because almost every device supports IPv6 today. I believe cellular network operators even default to it, so you’re probably reading this on a device that uses IPv6.
在过去的二十年左右的时间里,我一直了解 IPv6,但我从未超越过“IPv4 地址空间问题的过度设计解决方案”。IPv6 甚至被描述为“每个原子都可以获得自己的 IP 地址,不再有 IP 地址短缺”,但我也不知道这有多真实。我偶尔会在这里和那里看到 IPv6 地址,因为现在几乎每个设备都支持 IPv6。我相信蜂窝网络运营商甚至默认使用它,因此您可能正在使用 IPv6 的设备上阅读本文。
Last week, I decided to learn about how IPv6 works under the hood, and I’ve learned quite a few interesting facts about it.
上周,我决定了解 IPv6 在后台是如何工作的,并且我了解到了很多关于它的有趣事实。
Disclaimer: I’m not an expert on IPv6 or network engineering in general. This is the outcome of my personal reading journey over the last few weeks, and I’d love to be corrected if I made any mistakes. Read on 😃
免责声明:我不是 IPv6 或一般网络工程方面的专家。这是我过去几周个人阅读之旅的结果,如果我犯了任何错误,我很乐意得到纠正。继续阅读 😃
IPv6 vs IPv4
IPv6 与 IPv4
The name IPv6 used to confuse me because I thought IPv4 took its name from the four octets it used to represent 32-bits, so, IPv6 should have been called IP16. But I learned that it was really the version of the protocol. There were apparently IPv1, IPv2, and IPv3 before IPv4 came out. They were used to research the IP protocol internally, and later got replaced with IPv4 we use today. There was even a proposal for IPv5 in the 80’s that was intended to optimize realtime communications, but got discarded in favor of IPv6 which additionally solved the address space problem. That’s why IPv6 is called IPv6. It’s literally IP Version 6. There have even been attempts at creating IPv7, IPv8 and more, but all have been either obsoleted or shelved.
IPv6 这个名字曾经让我感到困惑,因为我认为 IPv4 的名字来源于它用来表示 32 位的四个八位字节,所以,IPv6 应该被称为 IP16。但我了解到,这确实是协议的版本。在 IPv4 出现之前,显然有 IPv1、IPv2 和 IPv3。它们用于内部研究 IP 协议,后来被我们今天使用的 IPv4 所取代。甚至在 80 年代也提出了一个 IPv5 提案,旨在优化实时通信,但被放弃了,转而使用 IPv6,后者还解决了地址空间问题。这就是 IPv6 被称为 IPv6 的原因。它实际上是 IP 版本 6。甚至有人尝试创建 IPv7、IPv8 等,但都已过时或搁置。
Like IPv4, IPv6 protocol has an addressing scheme. IPv6 uses 128-bits for addresses instead of 32-bit IPv4 addresses. But, the difference in protocols are greater than address space sizes. Actually, IPv6 feels like an alien tech if you’ve only worked with IPv4 so far when you look at its quirky features such as:
与 IPv4 一样,IPv6 协议也有一个寻址方案。IPv6 使用 128 位地址,而不是 32 位 IPv4 地址。但是,协议的差异大于地址空间大小。实际上,如果您到目前为止只使用 IPv4,那么当您查看其古怪的功能时,IPv6 感觉就像一项外来技术,例如:
IPv6 has no subnet masks IPv6
没有子网掩码
IPv6 supports CIDR addressing like IPv4, but from a user’s perspective, IPv6 addresses are way simpler: first half is Internet (global), the second half is local. That’s the suggested way to use IPv6 addresses anyway. So, when you visit a whatismyipwhatever web site, it shows your IP address like this:
IPv6 像 IPv4 一样支持 CIDR 寻址,但从用户的角度来看,IPv6 地址要简单得多:前半部分是 Internet(全球),后半部分是本地地址。无论如何,这是使用 IPv6 地址的建议方法。因此,当您访问 whatismyipwhatever 网站时,它会显示您的 IP 地址,如下所示:
1111:2222:3333:4444:5555:6666:7777:8888
But, your ISP only knows you as 1111:2222:3333:4444
and assigns that portion (/64
) to you. The remaining half of the address is unique for every device on your network. ISP just forwards any packet that starts with 1111:2222:3333:4444
to your router, and your router transfers the packet to the device. So, the second half of the address, 5555:6666:7777:8888
, let’s call that part INTERFACE_ID
from now on, is unique to your device. That means, every device you have has a unique IPv6 address, and can be accessed individually from anywhere in the world, because:
但是,您的 ISP 只知道您是 1111:2222:3333:4444
,并将该部分 (/64
) 分配给您。地址的剩余一半对于网络上的每台设备都是唯一的。ISP 只是将任何以 1111:2222:3333:4444
开头的数据包转发到您的路由器,您的路由器将数据包传输到设备。所以,地址的后半部分 5555:6666:7777:8888
,从现在开始我们称之为 INTERFACE_ID
部分,对于你的设备来说是唯一的。这意味着,您拥有的每台设备都有一个唯一的 IPv6 地址,并且可以从世界任何地方单独访问,因为:
IPv6 has no NAT
IPv6 没有 NAT
I used to think that you could do NAT with IPv6, but nobody did it because of potential backlash from HackerNews community. Apparently, that’s not the case. There’s apparently no published standard for NAT for IPv6. There is a draft proposal called NAT66, but it hasn’t materialized.
我曾经认为你可以用 IPv6 做 NAT,但由于 HackerNews 社区可能会强烈反对,所以没有人这样做。显然,情况并非如此。显然,没有针对 IPv6 的 NAT 的已发布标准。有一个名为 NAT66 的提案草案,但尚未实现。
NAT isn’t needed with IPv6 because it’s possible to have a separate globally accessible address for every device on Earth. That felt weird to me because NAT, despite how much you hate it when you want to play games online, gives you that warm feeling that your local devices are never accessible from outside unless you explicitly allow it using UPnP or port forwarding. It has that false sense of security which is really hard to shake off.
IPv6 不需要 NAT,因为地球上的每台设备都可以有一个单独的全局可访问地址。这对我来说感觉很奇怪,因为尽管当您想在线玩游戏时,您非常讨厌 NAT,但它会给您一种温暖的感觉,即除非您使用 UPnP 或端口转发明确允许它,否则您的本地设备永远无法从外部访问。它有一种真的很难摆脱的虚假安全感。
The bitter truth is, NAT isn’t a security barrier. It’s just an alternative packet forwarding mechanism. Your IPv6 router should never forward connection attempts from outside to your local devices by default anyway. So, you get the same security without having NAT at all. As a matter of fact, it’s fascinating that you’re able to access every device on your local network with their IPv6 address without having to go through your router, or a separate VPN configuration if you wish to do so: just authenticate, that’s it. Hypothetically, a smart toothbrush in Istanbul, Turkey can connect directly to a temperature sensor in Ontario, Canada, and create one of the most diverse botnets on the planet.
残酷的事实是,NAT 并不是安全屏障。它只是一种替代的数据包转发机制。默认情况下,您的 IPv6 路由器绝不应将连接尝试从外部转发到您的本地设备。因此,您无需 NAT 即可获得相同的安全性。事实上,令人着迷的是,您可以使用其 IPv6 地址访问本地网络上的每台设备,而无需通过路由器,或者如果您愿意,也可以使用单独的 VPN 配置:只需进行身份验证,就是这样。假设土耳其伊斯坦布尔的智能牙刷可以直接连接到加拿大安大略省的温度传感器,并创建地球上最多样化的僵尸网络之一。
There is a security related catch with IPv6 though that comes with the luxury of having a separate IPv6 address per device: your devices can be fingerprinted and tracked individually. That’s bad for privacy. So, modern OS’s invented the concept of temporary IPv6 addresses that change INTERFACE_ID
periodically. You can use your permanent IPv6 address for listening to connections from outside, but when establishing connections, your IPv6 address is shown with that secondary temporary address that changes frequently.
IPv6 存在一个与安全相关的问题,但前提是每台设备都有一个单独的 IPv6 地址:您的设备可以被单独采集指纹和跟踪。这对隐私不利。因此,现代操作系统发明了定期更改 INTERFACE_ID
的临时 IPv6 地址的概念。您可以使用永久 IPv6 地址来侦听来自外部的连接,但在建立连接时,您的 IPv6 地址将与经常更改的辅助临时地址一起显示。
Now, having mentioned not needing to go through hoops for access, another interesting feature of IPv6 is:
现在,在提到不需要费尽心思进行访问之后,IPv6 的另一个有趣特性是:
IPv6 addresses are self-configured
IPv6 地址是自配置的
IPv6 protocol doesn’t need a DHCP server, or manual network configuration to determine IP address, subnet mask, and gateway address. A device can get an IP address without asking a centralized server. That is accomplished by a protocol called SLAAC. It gradually builds a device’s IPv6 address by following these steps:
IPv6 协议不需要 DHCP 服务器或手动网络配置来确定 IP 地址、子网掩码和网关地址。设备无需请求集中式服务器即可获取 IP 地址。这是通过一种称为 SLAAC 的协议实现的。它按照以下步骤逐步构建设备的 IPv6 地址:
- The operating system (specifically, the IPv6 stack of the OS) generates a 64-bit device identifier, usually random, let’s say
5555:6666:7777:8888
(chosen by a fair dice roll), and that makes up theINTERFACE_ID
portion of your IPv6 address.
操作系统(特别是操作系统的 IPv6 堆栈)会生成一个 64 位设备标识符,通常是随机的,比如5555:6666:7777:8888
(由公平的掷骰子选择),它构成了 IPv6 地址的INTERFACE_ID
部分。 - The OS prefixes the
INTERFACE_ID
withfe80
, the local only IPv6 network prefix. So, your IPv6 address is now:fe80::5555:6666:7777:8888
. (Notice the “*a::b*
” syntax; it means “there are all zero valued segments between ‘a’ and ‘b’”. More on that later)
操作系统在INTERFACE_ID
前面加上fe80
,这是仅限本地的 IPv6 网络前缀。所以,您的 IPv6 地址现在是:fe80::5555:6666:7777:8888
。(请注意 “*a::b*
” 语法;它的意思是 “‘a’ 和 ‘b’ 之间都有所有零值的段”。稍后会详细介绍) - Your device now sends a packet to its designated neighbor multicast group on the local network to make sure that nobody else is using the same IPv6 address. That’s called Duplicate Address Detection (DAD). The chances of a duplicate address getting assigned is less than universe suddenly imploding due to a cataclysmic event, but that’s exactly when you don’t want to deal with duplicate IPv6 addresses and miss all the fun.
您的设备现在将数据包发送到本地网络上的指定邻居多播组,以确保没有其他人使用相同的 IPv6 地址。这称为重复地址检测 (DAD)。分配重复地址的几率比宇宙因灾难性事件而突然内爆的几率要小,但这正是您不想处理重复的 IPv6 地址而错过所有乐趣的时候。 - Finally, the device sends the router (which, unlike IPv4, can always be reached with the multicast group address on IPv6
ff02::2
) its acquired local address and asks for the actual prefix the router uses by sending a RS (Router Solicitation) ICMPv6 packet. After router responds with an RA (Router Advertisement) packet, it replacesfe80
with the actual prefix the router replies with, and starts using that as its permanent address. That’s now your IPv6 internet address.
最后,设备向路由器发送其获取的本地地址(与 IPv4 不同,它始终可以通过 IPv6ff02::2
上的组播组地址到达),并通过发送 RS(路由器请求)ICMPv6 数据包来请求路由器使用的实际前缀。在路由器使用 RA(路由器通告)数据包响应后,它会将fe80
替换为路由器回复的实际前缀,并开始将其用作其永久地址。现在,这就是您的 IPv6 Internet 地址。
The advantage of stateless configuration is the reduced overhead on your router: it doesn’t have to maintain the IP configuration of every device on the network individually. That means better performance, especially in larger networks.
无状态配置的优点是减少了路由器的开销:它不必单独维护网络上每个设备的 IP 配置。这意味着更好的性能,尤其是在大型网络中。
This just happened. Explain this coincidence, atheists!
IPv6 myths
IPv6 神话
IPv6 comes with bold claims too. Let’s debunk them:
IPv6 也带有大胆的主张。让我们揭穿它们:
Your device has one IPv6 address for every purpose
您的设备有一个 IPv6 地址,可用于各种用途
I mean, yes, you use the same IPv6 address for both local and remote connections. But no, the “one IP address to rule them all, one IP address to find them” claim isn’t true. As I mentioned before, your device claims the ownership of multiple IPv6 addresses for different scopes like link-local (Remember fe80::
) and Internet. Additionally, your device might acquire two different Internet IPv6 addresses too: permanent and temporary. Temporary IPv6 addresses are intended to preserve your privacy as they are rotated periodically. Permanent IPv6 addresses are primarily for servers which must have static IPv6 addresses.
我的意思是,是的,您对本地和远程连接使用相同的 IPv6 地址。但是不,“一个 IP 地址统治所有,一个 IP 地址找到他们”的说法是不正确的。正如我之前提到的,您的设备为不同的范围(如本地链接(记住 fe80::
)和 Internet )声明多个 IPv6 地址的所有权。此外,您的设备也可能获得两个不同的 Internet IPv6 地址:永久和临时。临时 IPv6 地址旨在保护您的隐私,因为它们会定期轮换。永久 IPv6 地址主要用于必须具有静态 IPv6 地址的服务器。
An IP address for every atom in the universe
宇宙中每个原子的 IP 地址
Not even close. There are about 2²⁷² atoms in the universe. Even Earth has 2¹⁶⁶ atoms, so we need at least 168-bits (octet-aligned) address space for them. The actual IPv6 address space is slightly smaller than 128-bits too: the first 16-bits are IANA reserved. You only have the remaining 112-bits to identify devices. That’s still a lot, way more than probably all devices we can produce on Earth in the next millenia, but no, we can’t give every atom its own IP address. But, we can give IPv6 addresses to every grain of sand on Earth. We can even fit them all inside a single /64 prefix.
甚至没有接近。宇宙中大约有 2²⁷² 个原子。即使地球也有 2¹⁶⁶ 个原子,因此我们至少需要 168 位(八位字节对齐)的地址空间。实际的 IPv6 地址空间也略小于 128 位:前 16 位是 IANA 保留的。您只有剩余的 112 位来标识设备。这仍然很多,可能比我们在未来几千年里在地球上生产的所有设备都多,但不,我们不能给每个原子自己的 IP 地址。但是,我们可以为地球上的每一粒沙子提供 IPv6 地址。我们甚至可以将它们全部放在一个 /64 前缀中。
All in all, yes, IPv6 address space is vast regardless of how many arbitrary particles we can address with it.
总而言之,是的,无论我们可以用 IPv6 地址处理多少个任意粒子,IPv6 地址空间都是巨大的。
Universal connectivity of every device
每台设备的通用连接
Yes, IPv6 has no NAT. So, that means no more port forwarding or address space to maintain. But, you still have to have a mechanism to open your device to connections from a remote host if you want to establish a direct connection. Remember, your router/firewall by default will prevent any connection attempt. What are you going to do?
是的,IPv6 没有 NAT。因此,这意味着无需维护更多的端口转发或地址空间。但是,如果您想建立直接连接,您仍然必须有一种机制来向来自远程主机的连接开放您的设备。请记住,默认情况下,您的路由器/防火墙将阻止任何连接尝试。你打算做什么?
As with UPnP/IGD days, apps today still need to work with a protocol like PCP (Port Control Protocol) in order to open access to a port programmatically. So, it’s not like you suddenly have universal connectivity with global+local IPv6 addresses. You don’t have to set up manual port forwarding, but apps still need to work with the router in order to make themselves accessible.
与 UPnP/IGD 时代一样,今天的应用程序仍然需要使用 PCP(端口控制协议)等协议,以便以编程方式打开对端口的访问。因此,您不会突然拥有与全局 + 本地 IPv6 地址的通用连接。您不必设置手动端口转发,但应用程序仍然需要与路由器配合使用才能使其可访问。
It’s not just the benefits of IPv6 being exaggerated, but there are cases where IPv6 turns out worse than IPv4 too:
这不仅仅是夸大了 IPv6 的好处,而且在某些情况下,IPv6 也比 IPv4 差:
Downsides of IPv6
IPv6 的缺点
There are several things that we take for granted in IPv4 world that IPv6 might make you nostalgic about, such as:
在 IPv4 世界中,我们认为理所当然的几件事可能会让您怀念 IPv6,例如:
You are at the mercy of your ISP to have subnets
您拥有的子网受 ISP 影响
Since IPv6 has no NAT, many ISPs in United States default to forwarding only a single 64-bit prefix (usually called a “/64
”) to your router. That means your router has no space left to put the subnet information into an IPv6 address. Remember: IPv6 addresses are auto-configured by devices, so, there is no way for a router to dictate those devices to use less than 64-bit local addresses. That means, your router would have no way to know which subnet to forward a packet to.
由于 IPv6 没有 NAT,因此美国的许多 ISP 默认只转发一个 64 位前缀(通常称为“/64
”)到您的路由器。这意味着您的路由器没有剩余空间将子网信息放入 IPv6 地址。请记住:IPv6 地址由设备自动配置,因此,路由器无法指示这些设备使用小于 64 位的本地地址。这意味着,您的路由器无法知道将数据包转发到哪个子网。
Essentially, you’re in the mercy of ISPs to receive prefixes shorter than 64-bit so that your router can use the remaining bits to identify which subnet they need to go to. ISPs can actually afford giving home users at least 16 subnets by simply assigning 60-bit prefixes, but ISPs don’t do that for reasons unknown to me. Maybe the PTSD they had from IPv4 address space shortage made them greedy bastards? Or, they just want to make money by extorting customers. “Hey, if you want a shorter prefix, pay us more”. As far as I know, both Comcast Xfinity and AT&T give their home users a mere /64
prefix: one subnet.
从本质上讲,您受 ISP 的摆布,可以接收短于 64 位的前缀,以便您的路由器可以使用剩余的位来识别他们需要转到的子网。实际上,通过简单地分配 60 位前缀,ISP 可以负担得起为家庭用户提供至少 16 个子网的费用,但 ISP 没有这样做,原因我不知道。也许他们因 IPv4 地址空间短缺而患上的 PTSD 使他们成为贪婪的混蛋?或者,他们只是想通过勒索客户来赚钱。“嘿,如果您想要更短的前缀,请向我们支付更多费用”。据我所知,Comcast Xfinity 和 AT&T 都只给他们的家庭用户一个 /64
前缀:一个子网。
You might say that a home user may not need subnets at all, but, with the prevalence of IoT devices and our greater reliance of the security of our networks, isolating your untrusted devices is getting more important. RIPE, the European authority on IP address assignments, recommends a 56-bit prefix for residential ISP customers. That gives every customer 256 subnets, and that’s the greediest, the most conservative option that Europeans could come up with which an American can only dream of.
您可能会说家庭用户可能根本不需要子网,但是,随着 IoT 设备的普及以及我们对网络安全的日益依赖,隔离不受信任的设备变得越来越重要。欧洲 IP 地址分配机构 RIPE 建议住宅 ISP 客户使用 56 位前缀。这为每个客户提供了 256 个子网,这是欧洲人能想到的最贪婪、最保守的选择,美国人只能梦想。
Of course, you can configure IPv6 address of every device manually, and give them subnet identifiers this way, but that would be a huge undertaking, especially considering the overhead of adding new devices. Do you want to spend your retirement as a human DHCP server?
当然,您可以手动配置每台设备的 IPv6 地址,并以这种方式为它们提供子网标识符,但这将是一项艰巨的任务,尤其是考虑到添加新设备的开销。您想作为人类 DHCP 服务器度过退休时光吗?
IPv6 addresses need extra encoding in URIs
IPv6 地址需要在 URI 中进行额外编码
Remember typing “http://192.168.0.1
” on your browser and accessing your router settings? I do. Because “:
” character is reserved for port numbers in the URI specification, it’s impossible to do the same using IPv6 addresses without additional encoding. In case you want to access a web page hosted on a device by its IPv6 address, you have to use the syntax: “http://[aaaa:bbbb:cccc:dddd:eeee:ffff:1111:2222]/path/?query
”, notice the brackets around the address. But, that’s not even the worst part because:
还记得在浏览器上键入 “http://192.168.0.1
” 并访问路由器设置吗?我愿意。由于 “:
” 字符在 URI 规范中是为端口号保留的,因此如果不进行其他编码,则无法使用 IPv6 地址执行相同的操作。如果您想通过设备的 IPv6 地址访问托管在设备上的网页,您必须使用语法:“http://[aaaa:bbbb:cccc:dddd:eeee:ffff:1111:2222]/path/?query
”,请注意地址周围的括号。但是,这还不是最糟糕的部分,因为:
It’s impossible to memorize IPv6 addresses
无法记住 IPv6 地址
We’ve never been supposed to memorize IP addresses, but the reality is different. I’m still not sure about which address I can use reliably and consistenly to access my router on IPv6. I can’t memorize its full IP address, that’s for sure. mDNS helps, but it doesn’t always reliably work either.
我们从来都不应该记住 IP 地址,但现实情况并非如此。我仍然不确定我可以可靠且一致地使用哪个地址来访问 IPv6 上的路由器。我记不住它的完整 IP 地址,这是肯定的。mDNS 有帮助,但它也并不总是可靠地工作。
Hexadecimal is harder than regular numbers too. It’s like trying to memorize a Windows XP product activation code. What was that famous one? FCKGW-RHQQ2-??
eh, whatever.
十六进制也比常规数字更难。这就像试图记住 Windows XP 产品激活码一样。那个著名的是什么?FCKGW-RHQQ2-??
呃,随便。
Memorizing an IPv4 address is a transferable skill; “cross-platform” if you will. It’s even universal due to pervasive NAT: 192.168.1.1 most of the time. I didn’t have to look that up. Figuring out the IPv6 address of your router on an arbitrary device you have requires different skills.
记住 IPv4 地址是一项可转移的技能;“跨平台”,如果你愿意的话。由于普遍的 NAT:192.168.1.1 大多数时候,它甚至是通用的。我不必查那个。在您拥有的任意设备上找出路由器的 IPv6 地址需要不同的技能。
On the bright side, you now know that the rightmost 64-bit portion of an IPv6 address is always random, so, you can at least avoid assuming that it’s going to stay forever or supposed to make sense. You can even call that part BLABLA
instead of INTERFACE_ID
. You can memorize your /64 prefix and at least find out your router address, which is usually something like 1111:2222:3333:4444::1
.
从好的方面来说,您现在知道 IPv6 地址最右边的 64 位部分始终是随机的,因此,您至少可以避免假设它会永远保留或应该有意义。您甚至可以将该部分称为 BLABLA
而不是 INTERFACE_ID
。你可以记住你的 /64 前缀,至少找到你的路由器地址,通常类似于 1111:2222:3333:4444::1
。
IPv6 addresses are complicated
IPv6 地址很复杂
Make no mistake, IPv4 addresses are complicated too. Did you know that 2130706433
is a valid IPv4 address? Or, 0x7F000001
, 0177.0000.0000.0001
and 127.1
for that matter? Try pinging them on a shell if you don’t believe me. It’s hard to believe but, they’re all equivalent to 127.0.0.1
.
毫无疑问,IPv4 地址也很复杂。您知道 2130706433
是有效的 IPv4 地址吗?或者,0x7F000001
、0177.0000.0000.0001
和 127.1
就此而言?如果你不相信我,试着在 shell 上 ping 他们。这很难相信,但是,它们都等同于 127.0.0.1
。
IPv6 addresses have a similar level of variety in representation. Here are some of their characteristics:
IPv6 地址在表示形式上具有类似程度的多样性。以下是它们的一些特点:
- The representation of an IPv6 address consists of 8 hextets: sixteen bit hexadecimal groups canonically called segments. (“Hextet” is a misnomer for hexadectet, but too late now). Anyway, now hex tricks like this are possible:
IPv6 地址的表示形式由 8 个十六进制组组成:16 位十六进制组,规范称为段。(“Hextet”是 hexadectet 的用词不当,但现在为时已晚)。无论如何,现在像这样的十六进制技巧是可能的:
“face:b00c” I see what you did there.
- Prefixing zeroes in hextets are not displayed. So,
2600:00ab
is actually shown as2600:ab
.
不显示十六进制中的前缀 0。因此,2600:00ab
实际上显示为2600:ab
。 - As I mentioned before, hextets with zero values can completely be removed from the address and replaced with double colons. So,
2600:ab:0:0:1234:5678:90ab:cdef
would be displayed as2600:ab**::**1234:5678:90ab:cdef
. See the double colons? That can only be done with the first batch of zero hextets though. So,2600:ab:0:0:1234:0:0:cdef
would still render like2600:ab**::**1234:**0:0**:cdef
. Also, you can’t compact just a single zero hextet. So, the zero in2600:**0**:1234:5678:abcd:ef01:2345:6789
remains as is.
正如我之前提到的,零值的十六进制可以完全从地址中删除并替换为双冒号。因此,2600:ab:0:0:1234:5678:90ab:cdef
将显示为2600:ab**::**1234:5678:90ab:cdef
。看到双冒号了吗?不过,这只能通过第一批零 hextet 来完成。因此,2600:ab:0:0:1234:0:0:cdef
仍会呈现为2600:ab**::**1234:**0:0**:cdef
。此外,您不能只压缩单个零 hextet。因此,2600:**0**:1234:5678:abcd:ef01:2345:6789
中的 0 保持原样。 - You can specifiy zone id: the network interface that you want to reach that address through with “
%
” suffix and a zone id. For example, you can be connected to a network over both WiFi and Ethernet, but may want to ping your router from LAN. In that case you append “%
” to the address and add your zone id (network adapter identifier). Such asfe80::1%eth0
orfe80::1%3
. The problem is, in addition to the brackets you need to use in IPv6 URIs, you must escape “%
” to “%25
” in your browser address bar or any other place where you need to use zone id in a URI.
您可以指定区域 ID:您希望通过其访问该地址的网络接口,带有 “%
” 后缀和区域 ID。例如,您可以通过 WiFi 和以太网连接到网络,但可能希望从 LAN ping 路由器。在这种情况下,您将 “%
” 附加到地址并添加您的区域 ID(网络适配器标识符)。例如fe80::1%eth0
或fe80::1%3
。问题是,除了需要在 IPv6 URI 中使用的括号之外,还必须在浏览器地址栏中或需要在 URI 中使用区域 ID 的任何其他位置将 “%
” 转为 “%25
”。 - IPv6 addresses can also be used to represent IPv4 addresses. So, you can ping
127.0.0.1
using IPv6 address syntax by prepending it with IPv4 translation prefix, and it’ll be regarded as an IPv4 address:::ffff:127.0.0.1
. But, that doesn’t mean your IPv4 requests will go through IPv6 network. That just tells the underlying networking stack to use an IPv4 connection instead. If you choose another prefix than::ffff
, the IPv4 portion will be made part of the last two hextets and you’ll connect that IP over IPv6 network. For example,2600:1000:2000:3000::192.168.1.1
will be treated as2600:1000:2000:3000::c0a8:101
, the last two hextets being the hexadecimal equivalent of192.168.1.1
.
IPv6 地址还可用于表示 IPv4 地址。因此,你可以使用 IPv6 地址语法 ping127.0.0.1
,只需在它前面加上 IPv4 转换前缀,它就会被视为一个 IPv4 地址:::ffff:127.0.0.1
。但是,这并不意味着你的 IPv4 请求将通过 IPv6 网络。这只是告诉底层网络堆栈改用 IPv4 连接。如果你选择除::ffff
以外的其他前缀,IPv4 部分将成为最后两个十六进制的一部分,你将通过 IPv6 网络连接该 IP。例如,2600:1000:2000:3000::192.168.1.1
将被视为2600:1000:2000:3000::c0a8:101
,最后两个十六进制是192.168.1.1
的十六进制等效值。
These are all valid IPv6 addresses:
这些都是有效的 IPv6 地址:
::
That’s all zeroes0:0:0:0:0:0:0:0
.
::
这都是零0:0:0:0:0:0:0:0
。2600::
That’s an equivalent to2600:0:0:0:0:0:0:0
.
2600::
这相当于2600:0:0:0:0:0:0:0
。::ffff:1.1.1.1
is an equivalent to1.1.1.1
IPv4 address.
::ffff:1.1.1.1
相当于1.1.1.1
IPv4 地址。2607:f8b0:4005:80f::200e
is the address I get when I ping google.com. You know the drill; it’s equivalent to2607:f8b0:4005:80f:0:0:0:200e
. As you can see, Like Facebook, Google also took the hard road and decided to assign manually designatedINTERFACE_ID
‘s to its IPv6 addresses. Godspeed.
2607:f8b0:4005:80f::200e
是我 ping google.com 时得到的地址。你知道演习;它相当于2607:f8b0:4005:80f:0:0:0:200e
。如您所见,与 Facebook 一样,Google 也走了一条艰难的道路,并决定将手动指定的INTERFACE_ID
分配给其 IPv6 地址。一路平安。
In the end, an IPv6 address you write on your address bar might look like this as a contrived example:
最后,您在地址栏上写入的 IPv6 地址可能看起来像这样,这是一个人为的示例:
https://[542b:b2ae:ed5c:cb5a:e38b:2c49:123:192.168.1.1%25eth3]
No way I’m memorizing that.
我不可能记住那个。
That all said, I loved learning about IPv6! The learning experience clarified a few things for me. For example, I didn’t know IPv6 addresses were self-configured with a stateless protocol. I didn’t know it had no NAT. I didn’t know the address space was just conveniently split in half.
综上所述,我喜欢学习 IPv6!这次学习经历为我澄清了一些事情。例如,我不知道 IPv6 地址是使用无状态协议自行配置的。我不知道它没有 NAT。我不知道地址空间只是方便地分成两半。
I wish we had a shortcut IPv6 address for our default gateway. I propose fe80::1
. IETF, take note! 😃
我希望我们的默认网关有一个快捷方式 IPv6 地址。我建议 fe80::1
。IETF,请注意!😃
I remember that IPv6 support in Windows 2000 was a big step when announced, and we all thought IPv6 would get adopted in a decade or so. Could we be more wrong? Yet, learning about it made me understood why it hasn’t caught on fast.
我记得 Windows 2000 中的 IPv6 支持在宣布时是一大步,我们都认为 IPv6 会在十年左右的时间里被采用。我们能错得更厉害吗?然而,了解它让我明白了为什么它没有迅速流行起来。
IPv6 provides no benefit to end-users
IPv6 不会给最终用户带来任何好处
Despite how technologically advanced IPv6 is, IPv4 just works. It works even behind NAT, even behind multiple layers of NATs, even with its extremely cramped address space, cumbersome DHCP, and port forwarding. It keeps working. When people find a way that it doesn’t work, and can never work, somebody comes up and makes that work too.
尽管 IPv6 的技术多么先进,但 IPv4 就是好用。它甚至可以在 NAT 之后工作,甚至在多层 NAT 之后工作,即使其地址空间极其狭窄、DHCP 繁琐和端口转发也是如此。它一直在工作。当人们找到一种方法,它不起作用,而且永远行不通时,有人就会出现并使其也起作用。
There’s probably a latency advantage of IPv6 not having NAT, but that’s not good enough to make a dent in user experience.
没有 NAT 的 IPv6 可能存在延迟优势,但这还不足以影响用户体验。
Because IPv6 doesn’t provide any tangible benefit, users will never demand it, and they’ll just be pushed to it without them even knowing, like how we almost always use IPv6 on cellular internet nowadays.
因为 IPv6 没有提供任何有形的好处,所以用户永远不会要求它,他们只会在不知情的情况下被推向它,就像我们现在几乎总是在蜂窝互联网上使用 IPv6 一样。
That means, when ISPs feel enough pressure from the limitations of IPv4, they’ll switch to IPv6 in an instant. No question about it.
这意味着,当 ISP 感受到 IPv4 限制带来的足够压力时,他们将立即切换到 IPv6。毫无疑问。
I wish IPv6 enabled some features that enabled a few distinct scenarios not possible with IPv4, so people could demand IPv6 to use them. Yet, I love the alienesque nature of IPv6 networks, and look forward to the time we fully abandon IPv4 and build everything around IPv6 instead.
我希望 IPv6 启用一些功能,这些功能支持 IPv4 无法实现的一些不同场景,以便人们可以要求 IPv6 使用它们。然而,我喜欢 IPv6 网络的异化性质,并期待我们完全放弃 IPv4 并围绕 IPv6 构建一切。
via:
-
IPv6 for the remotely interested. I’ve known about IPv6 for the last two… | by Sedat Kapanoglu | Medium
https://ssg.dev/ipv6-for-the-remotely-interested-af214dd06aa7