DNS leaks are a major problem for Tor.
Tor doesn’t provide a direct solution to that but there are still some ways to
solve this problem.
One of the solutions is dns-proxy-tor which is a DNS server that constructs
Tor to map a domain to a virtual IP address and
subsequently Tor will treat the virtual IP address
as an alias for the original domain name.

The other solution is a patch written by Total Information Security which
modifies tsocks . With this patch tsocks uses SOCKS for name resolution
which both prevents DNS leaks and enables direct access to .onion addresses
for torified programmes.
Without the patch one has to add mapaddress lines to his/her torrc to map domains to virtual IP addresses.

Yesterday I wrote a bug report about this to Gentoo Bugzilla to add a tordns
USE flag to tsocks and developers have added it to portage. This is what I love
about Gentoo. You request a feature and if it’s acceptable it’ll be added
before you wake up next day :)