I want Tor to just resolve a DNS and return the IP address before any connection to the destination server. I know that the Tor client sends a request to the exit node and the exit node does the DNS resolution and establishes a connection to that hostname. After establishing the connection to the server, the exit node returns the IP address to the client but this is not what I want. I want to resolve the DNS and get the IP without any connection to the sever. Is there any function in the source code to help me or which functions do I need to touch for this purpose.
If you're using Tor within GNU/Linux, you can use
> tor-resolve tor.stackexchange.com 220.127.116.11
The program sends a DNS request and shows you the answer. The option
-x also does a reverse lookup.