banner
herman

herman

哈哈哈哈哈哈哈哈哈哈哈哈哈哈

Tips for accessing devices that only have V6 with devices that only have V4

As we all know, if the client is only enabled with IPV4 for special reasons, and the server is only enabled with IPV6 for special reasons, then they cannot access each other.

For example, I cannot access my home NAS (which only has IPV6 on mobile broadband) using my work computer (which only has IPV4 on the company network).

Solution: Use a proxy.#

The prerequisite is that your proxy server needs to be dual-stack (usually dual-stack). You can check by opening https://ip.zxinc.org/ipquery/.

Fun fact: (provided by the great master Tian Di Ji Xian)

In a dual-stack environment, whether a program chooses to use the IPv4 or IPv6 protocol is determined by the program itself, and the DNS server does not have the ability to control which protocol is prioritized by the program.

Because DNS requests need to specify the type of query, IPv4 addresses are of type A, and IPv6 addresses are of type AAAA. There is no type that can query both IPv4 and IPv6 addresses at the same time.

Therefore, the program can only query both types of addresses and then choose which one to use based on its own logic. For most programs that use the BSD socket API, they will use getaddrinfo to resolve domain names and then try to connect in order. At this time, which protocol is prioritized is controlled by the system. Whichever protocol getaddrinfo puts first, the program will connect to it first.

There are also some programs with special designs, such as curl and various browsers, which have other logic. For example, they will first check the IPv6 address of the local machine. If it is a private network address, they will not use IPv6. If it is a public network address, they will simultaneously resolve both IPv4 and IPv6 addresses, and then prioritize connecting to IPv6. If it fails to connect successfully within a short period of time (such as 1 second), it will continue to try to connect to IPv4, and finally use the connection that was established first.

1702363756657.gif

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.