11

I have to make a DNS request using python 3 over a SOCKS 5 proxy. (consequently NO DNS requests are made from my ip address, the socks5 proxy does it for me and should respond with the according A/AAA records or nothing/something else if it can not resolve it)

I found the following github projects:

rthalley/dnspython: no proxy/socks support

Anorov/PySocks: no ipv6, no possiblity to receive the remote DNS response

I found the following stackoverflow thread: Python - Using socket.gethostbyname through proxy -> It uses pysocks, which has no ipv6 support -> not useable for me

Do you have any idea how to accomplish my task?

2
  • Poor man solution: ssh port redirection with Socks support (see -D option) Commented Jul 9, 2018 at 17:12
  • Also, why specifically Socks? Nowadays you have DNS over HTTPS and DNS over TLS, services also provided by some big public resolvers, so that may be easier options. Commented Jul 9, 2018 at 17:13

2 Answers 2

9

It's surprisingly easy. It works the same way as in curl:

If you need DNS to be resolved client side, use socks5://host:port syntax

If you need DNS to be resolved on the proxy side, use socks5h://host:port syntax

0

in the lin 45 of query.py

# Function used to create a socket.  Can be overridden if needed in special
# situations.
socket_factory = socket.socket

you can reset the socket_factory value(use PySocks)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.