Some time back I needed something similar. I used a package called
DNS-TCP-SOCK-PROXY, which you can find on this github page. It is described as follows:
A simple dns proxy to tunnel DNS requests over a socks proxy (for example, over ssh or Tor). This can come in handy when setting up transparent proxies.
Usage: ./dns-proxy [options]
The configuration file should contain any of the following options (and ignores lines that begin with '#'):
socks_addr -- socks listener address
socks_port -- socks listener port
listen_addr -- address for the dns proxy to listen on
listen_port -- port for the dns proxy to listen on (most cases 53)
set_user -- username to drop to after binding
set_group -- group to drop to after binding
resolv_conf -- location of resolv.conf file to read from
log_file -- location to log to (should be /dev/null unless debugging).