端口如何与 IPv6 配合使用?

发布于 2024-07-07 04:37:14 字数 223 浏览 13 评论 0原文

传统的 IPv4 点分四元表示法用冒号将地址与端口分隔开,如环回接口上的 Web 服务器的示例所示:

127.0.0.1:80

但使用 IPv6 表示法,地址本身可以包含冒号。 例如,这是环回地址的缩写形式:

::1

端口(或其功能等效项)如何以 IPv6 地址/端口端点的文本表示形式表示?

Conventional IPv4 dotted quad notation separates the address from the port with a colon, as in this example of a webserver on the loopback interface:

127.0.0.1:80

but with IPv6 notation the address itself can contain colons. For example, this is the short form of the loopback address:

::1

How are ports (or their functional equivalent) expressed in a textual representation of an IPv6 address/port endpoint?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

心在旅行 2024-07-14 04:37:14

他们的工作方式几乎和今天一样。 但是,请确保在您的 IP 周围包含 []

例如:http://[1fff:0:a88:85a3::ac1f]: 8001/index.html

维基百科有一篇关于 IPv6 的非常好的文章:http ://en.wikipedia.org/wiki/IPv6#Addressing

They work almost the same as today. However, be sure you include [] around your IP.

For example : http://[1fff:0:a88:85a3::ac1f]:8001/index.html

Wikipedia has a pretty good article about IPv6: http://en.wikipedia.org/wiki/IPv6#Addressing

小嗲 2024-07-14 04:37:14

IPv6 中使用的协议与 IPv4 中的协议相同。 两个版本之间唯一变化的是寻址方案、DHCP [DHCPv6] 和 ICMP [ICMPv6]。 因此基本上,任何与 TCP/UDP 相关的内容,包括端口范围 (0-65535) 都保持不变。

编辑:端口0是TCP中的保留端口,但它确实存在。 请参阅 RFC793

The protocols used in IPv6 are the same as the protocols in IPv4. The only thing that changed between the two versions is the addressing scheme, DHCP [DHCPv6] and ICMP [ICMPv6]. So basically, anything TCP/UDP related, including the port range (0-65535) remains unchanged.

Edit: Port 0 is a reserved port in TCP but it does exist. See RFC793

不弃不离 2024-07-14 04:37:14

维基百科 指出 IPv6 地址的语法包含冒号,并且具有简短形式,防止固定-length 解析,因此必须用 [] 分隔地址部分。 这完全避免了奇怪的解析错误。

(摘自编辑 Peter Wone 回答了原来的问题。)

Wikipedia points out that the syntax of an IPv6 address includes colons and has a short form preventing fixed-length parsing, and therefore you have to delimit the address portion with []. This completely avoids the odd parsing errors.

(Taken from an edit Peter Wone made to the original question.)

知你几分 2024-07-14 04:37:14

我非常确定端口只在 tcp 和 udp 中起作用。 所以即使使用新的IP协议也是完全一样的

I'm pretty certain that ports only have a part in tcp and udp. So it's exactly the same even if you use a new IP protocol

绅士风度i 2024-07-14 04:37:14

它们是一样的,不是吗? 现在我对自己失去了信心,但我真的认为 IPv6 只是一个寻址变化。 TCP 和 UDP 仍按照 IPv4 下的方式进行寻址。

They're the same, aren't they? Now I'm losing confidence in myself but I really thought IPv6 was just an addressing change. TCP and UDP are still addressed as they are under IPv4.

意中人 2024-07-14 04:37:14

我想说最好的参考是 URL 中文字 IPv6 地址的格式,其中使用 []被定义为。

另外,如果是用于编程和代码,特别是 Java,我建议阅读Inet6Address 类 java /net/URL定义,其中详细介绍了Inet4地址在Inet6内涵中的使用以及其他情况。 就我而言,IPv4映射地址的形式为::ffff:wxyz,用于IPv6地址,用于表示IPv4地址也解决了我的问题。 它允许本机程序在与 IPv4 和 IPv6 节点通信时使用相同的地址数据结构和相同的套接字。 这是亚马逊云 Linux 盒子默认设置的情况。

I would say the best reference is Format for Literal IPv6 Addresses in URL's where usage of [] is defined.

Also, if it is for programming and code, specifically Java, I would suggest this readsClass for Inet6Address java/net/URL definition where usage of Inet4 address in Inet6 connotation and other cases are presented in details. For my case, IPv4-mapped address Of the form::ffff:w.x.y.z, for IPv6 address is used to represent an IPv4 address also solved my problem. It allows the native program to use the same address data structure and also the same socket when communicating with both IPv4 and IPv6 nodes. This is the case on Amazon cloud Linux boxes default setup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文