shadowsocks / shadowsocks-rust

A Rust port of shadowsocks
https://shadowsocks.org/
MIT License
8.41k stars 1.15k forks source link

Can local-dns be bound on the local-tun interface address? #1674

Open mklnz opened 1 day ago

mklnz commented 1 day ago

Can local-dns be bound on the local-tun interface address?

I've tried:

    {
      "protocol": "tun",
      "tun_interface_address": "10.255.0.1/24",
    },
    {
      "protocol": "dns",
      "local_address": "10.255.0.1",
      "local_port": 53,
      "local_dns_address": "114.114.114.114",
      "local_dns_port": 53,
      "remote_dns_address": "1.1.1.1",
      "remote_dns_port": 53,
      "client_cache_size": 1024,
      "mode": "udp_only",
    }

But it does not seem to respond to DNS requests. Is there any other way to transparently handle DNS requests according to whether it is "local" or "remote"?

zonyitoo commented 1 day ago

It won’t work currently, because in your route table, all packets sent to 10.255.0.1 are routed to the tun interface.

There should be a way to create DNS servers behind the tun interface, which handles TCP UDP packets and bypasses them to the DNS service. If anyone interested, please submit a PR.