wangyu- / udp2raw

A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket,helps you Bypass UDP FireWalls(or Unstable UDP Environment)
MIT License
7.16k stars 1.16k forks source link

How to setup it to proxy DNS query? #536

Closed adrianzhang closed 1 month ago

adrianzhang commented 1 month ago

English Only.

I'v already created tunnel for some udp and tcp applications successfully. But I am stuck at making DNS query through tunnel, eg. query google.com from 8.8.8.8. Would you please give me an example to set it up? Any help is appreciated.

adrianzhang commented 1 month ago

BTW, what i am trying to setup is an Unbound recursive DNS server, it query records from many upstream DNS servers (not only 8.8.8.8).

pereiravagner96 commented 1 month ago

Udp2raw is a transparent transmission tool. It should not matter at all the type of content on its payload. If you are encountering issues with DNS or any other applications it might be due to MTU issues. So perhaps you need to add MTU clamping rules to adjust the MTU. DNS uses both UDP and TCP protocol. Some large queries will surpass the 512 Byte maximum size determined by the protocol. From this point and beyond the DNS protocol will use TCP to fragment the query in multiple packets. Please test and come back with the results so we can learn more.

wangyu- commented 1 month ago

if you are using only udp2raw, you need to setup a separate tunnel forwarding DNS. You cannot use the same tunnel for your application and remote DNS.

Other possible easier way:

1 use udp2raw+VPN, query dns over VPN

2 user udp2raw+shadowsocks (turn udp2raw into socks5), then query via socks5. Also, many ss clients have a feature named "remote DNS", it can do remote DNS automatically for you.

adrianzhang commented 1 month ago

Udp2raw is a transparent transmission tool. It should not matter at all the type of content on its payload. If you are encountering issues with DNS or any other applications it might be due to MTU issues. So perhaps you need to add MTU clamping rules to adjust the MTU. DNS uses both UDP and TCP protocol. Some large queries will surpass the 512 Byte maximum size determined by the protocol. From this point and beyond the DNS protocol will use TCP to fragment the query in multiple packets. Please test and come back with the results so we can learn

Thanks. What I suppose is, an Unbound recursive DNS server will request records to Root DNS servers/TLD DNS servers/Domain authoritative DNS servers, and requests go through udp2raw tunnel if upstream servers located outside China. However, I don't know how to setup udp2raw because I only learned redirect ports of VPS applications from udp2raw docs.

adrianzhang commented 1 month ago

if you are using only udp2raw, you need to setup a separate tunnel forwarding DNS. You cannot use the same tunnel for your application and remote DNS.

Other possible easier way:

1 use udp2raw+VPN, query dns over VPN1

2 user udp2raw+shadowsocks (turn udp2raw into socks5), then query via socks5. Also, many ss clients have a feature named "remote DNS", it can do remote DNS automatically for you.

Thank you! That makes sense. Your reply remind me to use SS-libev. Cool!