How to use IPv6 to connect externally with a server or client running on OpenWrt?

On Linux systems, you can modify the /etc/gai.conf file precedence ::ffff:0:0/96 100 similar parameters, or on Windows systems, you can use netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 60 4 A command like this is used to modify the priority of IPv4 or IPv6 when connecting to the outside world. Is there a similar method for the server or client running on OpenWRT to adjust the priority of IPv4 or IPv6?

This doesn't seem to be implemented by musl/getaddrinfo.
So the final result depends on the client and its software options.
IPv6 is typically preferable when provided with GUA connectivity.
However some tools require to specify the IP version explicitly.

1 Like

Usually this priority should be configured in the software, but the software that is encountering problems now configures the server address through the domain name. The domain name has both IPv4 and IPv6 resolution. The software connection options only have Only IPv4 / Only IPv6 / Any ( IPv4 and IPv6) The default of the three options is Any, which uses both IPv4 and IPv6, and there is no IPv6 priority option, so I wonder if it can be achieved through system configuration

For better fault tolerance, it's recommended to select the protocol automatically.
You can check which protocol is used with tcpdump.
The decision still depends on the software implementation.
If you believe it's incorrect/suboptimal, report the issue to the software bug tracker.