-
-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement remote DNS #374
base: main
Are you sure you want to change the base?
Implement remote DNS #374
Conversation
427e949
to
1c2355c
Compare
Hi there, first of all, thanks for your PR (again)! Right, the remote DNS feature has been requested many times, and I actually had a draft proposal code for it somewhere in my git stash months ago. ;-) My proposal design for it was mostly similar, but with some differences:
Anyway, it would be nice if we could finally get it to work. Let me know if you have any other opinions before proceeding to the next step. |
6a0dc7e
to
4e5d962
Compare
Hi, thanks again for your feedback.
|
Thanks for the quick update.
So ideally the |
90e1c72
to
14eaa35
Compare
Thanks for your suggestions.
Regarding a), you are right that changes in gVisor could impact this implementation. Concerning b), I think the performance impact is negligble given the amount of requests that one would expect under normal operation. However, I have implemented it that way now. By default, a listener is started on 127.0.0.1:53. A drawback of this implementation is that the OS actually needs an interface with the listener address. Further, it may interfere with software that is already occupying port 53. I am thinking of
I have copied the
1s is now the default (and there is no option to change it).
This is the case now. The Could you review the latest changes and provide feedback on whether the latest changes are going into the right direction? Thanks a lot for your work. |
This commit implements fake DNS. Fake DNS implements a UDP listener DNS A record queries on port 53. It replies with an unused IP address from an address pool, 198.18.0.0/15 by default. When obtaining a new address from the pool, tun2socks needs to memorize which name the address belongs to, so that when a client connects to the address, it can instruct the proxy to connect to the FQDN. To implement this IP to name mapping, the FakeIP module from clash is used.
Thank you so much for your incredible work, and I think it's overall on the right track!
Right, I understand your concern. But I think for most users who would like to enable this fake dns service, they should be able to take care of services like And I was thinking that maybe we can add an option sometime, for example
Yep, I agree that clash's
Thanks. It should be fine then. 👍 |
FYI, I may need some time to review and test all the features, and I apologize in advance if it takes a little longer as I am currently busy with my personal errands ;-) In the meantime, please feel free to update or provide any suggestions that might be helpful. Thanks again. |
Hi,
since this feature has been requested multiple times, I am making another attempt to implement the remote DNS feature.
Remote DNS intercepts UDP DNS queries for A records on port 53. It replies with an unused IP address from an address pool, 198.18.0.0/15 by default. When obtaining a new address from the pool, tun2socks needs to memorize which name the address belongs to, so that when a client connects to the address, it can instruct the proxy to connect to the FQDN. To implement this IP to name mapping, ttlcache is used. To prevent using multiple addresses for the same name, ttlcache is also used to implement a name to IP mapping. If an IP address is already cached for a name, that address is returned instread. When building a connection, the connection metadata is inspected and if the destination address is associated with a DNS name, the proxy is instructed to use this name instead of the IP address.