XTLS / libXray

MIT License
64 stars 57 forks source link

How to use custom DNS DOH for android vpn? #28

Closed musqdp closed 4 months ago

musqdp commented 4 months ago

I attempted to use an IP address that employs Xray to establish a SOCKS5 proxy, but it had no effect.

public class XrayVpnService extends VpnService {

private void setup() {
  ***
  Builder builder = new Builder();
  builder.addDnsServer("26.26.26.2");
  *** 
 }
}

Here's an example of the DNS config.json I utilized:

"dns" {
    "hosts": {
      "dns.nextdns.io": ["192.121.87.101","38.175.115.137"]
    },
    "servers": ["https://dns.nextdns.io/yourid"],
    "queryStrategy": "UseIPv4",
    "disableCache": true,
    "disableFallback": true,
    "disableFallbackIfMatch": true,
    "tag": "dns"
 }
 "routing": {
        "domainStrategy": "IPIfNonMatch",
        "rules": [ {
                "port": "53,18303,853",
                "outboundTag": "dns",
                "type": "field"
            }, {
                "inboundTag": ["dns"],
                "outboundTag": "proxy",
                "type": "field"
            }, {
                "type": "field",
                "ip": ["1.1.1.1", "10.0.2.3", "0.0.0.0"],
                "outboundTag": "blackhole"
            }
        ]
    }