DNSMASQ Bad option at line 1

The issue I am facing: DNS fails to start after added .hosts files in /etc/dnsmasq.d

Details about my system: ODROID N2+ ARM

What I have changed since installing Pi-hole:
I am currently trying to add .hosts files to dnsmasq from GitHub - uklans/cache-domains: Domain Names required for LAN Content Cache DNS spoofing so that it will redirect certain dns requests to a local caching server. The script that is provided in the github link creates a number of .hosts files (for example blizzard.hosts) for use with dnsmasq. it also adds a lancache.conf file in /etc/dnsmasq.d/ with multiple entries of addn host to load the files for example: "addn-hosts=/etc/dnsmasq.d/blizzard.hosts"

The problem is that dnsmasq for some reason does not recognize them and complains that they are of the wrong format? Pihole -d shows "bad option at line 1 of /etc/dnsmasq.d/blizzard.hosts" and the dns server fails to start.

This is what the blizzard.hosts file contains:
192.168.100.12 dist(.)blizzard(.)com
192.168.100.12 dist.()blizzard(.)com(.)edgesuite(.)net
192.168.100.12 llnw(.)blizzard(.)com
192.168.100.12 edgecast(.)blizzard(.)com
192.168.100.12 blizzard(.)vo(.)llnwd(.)net

and so on. (URLS changed because new users can only post 5 links)

So my question is, what gives? I know this might be a dnsmasq issue or more likely my stupidity but im hopeful that someone can help me :slight_smile:

Format the text block as pre-formatted text using the </> icon and the links will not be generated.

Update: I fixed it by catting the hosts files together and throwing them into /etc/hosts. Not exactly a fix for the problem but if it works it works :slight_smile:

dnsmasq will read everything in /etc/dnsmasq.d/ as a configuration file. And host files are not a valid format for configurations. You need to place those files outside of /etc/dnsmasq.d/ and adjust the addn-hosts=<...> lines.

Edit: Apparently you can also exclude certain extension from being read at all as configs. Edit /etc/dnsmasq.conf and add either conf-dir=/etc/dnsmasq.d,*.conf to read .conf files only, or add conf-dir=/etc/dnsmasq.d,.hosts to read everything except .hosts files. That * is the key difference.

2 Likes

Ohh thanks for the tip, ill be sure to try it when/if i need to upgrade the hostnames from the uklans github page.

Its just weird that the uklans .sh script created a config file that specifically referenced the .hosts files being in /etc/dnsmasq.d/ with no mention of that exclusion trick.

Maybe im too much of a noob for them lol

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.