Can local-dns be bound on the local-tun interface address?
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"?
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.
Thanks, been busy with other projects & it took me awhile to figure out how best to implement this. I've created a working prototype which intercepts the DNS queries bound to the TUN address itself:
https://github.com/mklnz/shadowsocks-rust/tree/tundns%2Bios
It uses the existing DnsClient from service/local/dns, so it integrates with the existing ServiceContext so it can update proxy/bypass lists.
I'm not sure if this the best way to integrate it into the project, as well as enabling/disabling this feature. TODOs for possible PR:
- Implement TCP handling, or port config (though this might not be necessary as this is meant for OS resolution which does not support TCP nor adjustment of port.
- How best to enable/disable this feature, right now it's enabled when the local tun config has DNS configs like:
{
"protocol": "tun",
"tun_interface_address": "10.255.0.1/24",
"local_dns_address": "114.114.114.114",
"local_dns_port": 53,
"remote_dns_address": "1.1.1.1",
"remote_dns_port": 53,
}
Sounds awesome.