Change dnsmasq's cache

0

I would like to alter my dnsmasq's cache so when I look for certain domains it'll give me the IP address I want it to serve (not necessarily the actual IP of that domain). It's basically like poisoning my own DNS server but not remotely.

Where is dnsmasq's cache saved? How can I alter it?

Zach P

Posted 2016-12-01T08:07:23.753

Reputation: 131

I think you'd just add them to /etc/hosts however I'm not putting this as an answer as I'm not 100% sure. – djsmiley2k TMW – 2016-12-01T08:08:17.297

Answers

1

The cache is in the memory, not saved to the filesystem. From man dnsmasq:

   The  cache  statistics  are  also  available  in  the DNS as answers to
   queries of class CHAOS and type TXT in domain bind.  The  domain  names
   are   cachesize.bind,   insertions.bind,  evictions.bind,  misses.bind,
   hits.bind, auth.bind and servers.bind.  An  example  command  to  query
   this, using the dig utility would be

   dig +short chaos txt cachesize.bind

Ipor Sircer

Posted 2016-12-01T08:07:23.753

Reputation: 3 578

Are you implying one cannot alter the cache in any way? – Zach P – 2016-12-01T09:14:50.050

1

You can put those domain names in /etc/hosts. Don't forget to restart dnsmasq, since otherwise it won't reload it.

Dnsmasq reads and uses the data from /etc/hosts, which is one of the reasons I use it. I'm not sure whether it always does that, or it is configurable.

Roel Schroeven

Posted 2016-12-01T08:07:23.753

Reputation: 119

0

You don't change the dnsmasq's cache content, but prefil it --

Create a .conf file under /etc/dnsmasq.d/, e.g., /etc/dnsmasq.d/dbab.adblock.conf, with the format of

address=/101com.com/192.168.2.101
address=/101order.com/192.168.2.101
...

For details refer to
https://sfxpt.wordpress.com/2015/11/22/dbab-from-start-to-finish/

In the section "Faq: How to blacklist those bad sites".

xpt

Posted 2016-12-01T08:07:23.753

Reputation: 5 548