Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

freedom.domainStrategy=AsIs ignore /etc/gai.conf

Open dimzon opened this issue 2 years ago • 2 comments

I configure my Ubuntu to prefer IPv4 over IPv6 via /etc/gai.conf direct curl my.ip.fi execute IPv4 request but curl over xray execute IPv6 request

example configuration:

{
        "inbounds": [
                {
                        "tag": "socks",
                        "port": 10808,
                        "listen": "127.0.0.1",
                        "protocol": "socks",
                        "settings": {
                                "auth": "noauth",
                                "udp": true,
                                "allowTransparent": false
                        }
                }
        ],
        "outbounds": [
                {
                        "tag": "direct",
                        "protocol": "freedom",
                        "settings": {
                                "domainStrategy": "AsIs"
                        }
                }
        ]
}

CURL output:

root@v2136098:/opt/real# curl --socks5-hostname 127.0.0.1:10808 my.ip.fi
2a0d:8480:********
root@v2136098:/opt/real# curl  my.ip.fi
77.105.*********

dimzon avatar Feb 24 '24 14:02 dimzon

  • To configure your system to prefer IPv4 addresses but fall back to IPv6 when necessary, you can use the "UseIPv4v6" domain strategy in your Xray-core Freedom outbound.
{
  "log": {
    "loglevel": "warning"
  },
  "routing": {
    "domainStrategy": "UseIPv4v6",
    "rules": [
      // Your routing rules here
    ]
  },
  "inbounds": [
    // Your inbounds configuration here
  ],
  "outbounds": [
    {
      "tag": "IPv4v6_out",
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "UseIPv4v6"
      }
    },
    // Other outbounds configuration here
  ]
}
  • The domainStrategy is set to "UseIPv4v6" at the routing level, which means that for any domain names that need to be resolved, the system will attempt to get an IPv4 address first. If an IPv4 address is not available, then it will use an IPv6 address.

  • The outbound with the tag "IPv4v6_out" is set up to use this strategy for its connections.

us254 avatar Feb 24 '24 18:02 us254

Name Resolution

iainlau avatar Feb 25 '24 07:02 iainlau

Answered

yuhan6665 avatar Mar 07 '24 00:03 yuhan6665