Do not use in production Server or if you don't know what iptables do
Add this to torrc ( located on /etc/tor/torrc):
VirtualAddrNetwork 10.192.0.0/10 AutomapHostsOnResolve 1 TransPort 9051 DNSPort 9053
Run the attached script as root so all traffic will route from Tor. you can also use attached torrc as a sample.
For the DNS Leakage take a look at this link and also this.
This project may help you. Check it out and make sure it works for you. Pay attention to possible data leakage. Protecting your privacy is much more important than anything else.