OpenWrt/network - Configuring dnsmasq for ad-blocking fails with "bad address at"

7.4k Views Asked by At

Trying to get ad blocking working in OpenWrt router firmware 10.03.1

I've prepared a file /etc/hosts.ads contain harmless entries like

address=/eviladserver1.com/127.0.0.1
address=/eviladserver2.com/127.0.0.1

in /etc/dnsmasq.conf I added the following line:

 addn-hosts=/etc/hosts.ads

and restarted dnsmasq. Now on restart I see the log being filled with error messages:

Jun  3 22:52:33 OpenWrt daemon.err dnsmasq[13056]: bad address at /etc/hosts.ads line 1

about every single line in the hosts.ads I googled it but with no luck. Everything seems right syntax-wise, why the dnsmasq does not like it?

(all lines in hosts.ads end with [LF] only)

2

There are 2 best solutions below

0
On

Appropriate format for /etc/hosts.ads is a standard HOSTS format such as:

127.0.0.1 eviladserver1.com
127.0.0.1 eviladserver2.com

Look at my implementation of adblock for OpenWRT at http://jazz.tvtom.pl/adblock-w-openwrt/ (polish).

0
On

Per the dnsmasq documentation, addn-hosts= specifies additional addresses in /etc/hosts format. It looks like you're trying to add an additional dnsmasq configuration file instead. For that, you want conf-file= to specify the file directly, or you want to put the file in a directory specified by conf-dir=.