What's new

grep: /opt/var/log/dnsmasq.log: binary file matches

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!


Occasional Visitor
Hi, I am trying to use the autoscan.sh script that comes x3mrouting and am getting an error. This is the command I am running but it doesn't work (It doesn't work when I search for anything).

./autoscan.sh autoscan=netflix

I do have these lines in the dnsmasq.conf.add file and the dnsmasq.log file does exists and it contains data


If I run
cat /opt/var/log/dnsmasq.log |grep netflix --binary-files=text
I get lots of results back.

This used to work previously but recently started throwing up the error and was wondering if anybody had any ideas.

grep: /opt/var/log/dnsmasq.log: binary file matches

IPSET Format

grep: /opt/var/log/dnsmasq.log: binary file matches

FQDN Format

Thank you in advance.
Either clear the log file or search for binary character(s) in the file and remove it/them.
I posted as I didn't know how to clear the log file without deleting it and unfortunately I don’t know how to search for binary characters or even know what they are.

thanks for you help though. I resolved by stoping the service, deleting file and starting service again
Next time it happens, try this to keep the existing dnsmasq log file.
You'll need Entware grep installed which Diversion and maybe other scripts install by default.
If /opt/bin/grep is missing install it with
opkg install grep

Check if the log file contains NULL characters:
/opt/bin/grep -Pa '\x00' /opt/var/log/dnsmasq.log
If any are found, then you may remove them using:
tr < /opt/var/log/dnsmasq.log -d '\x00' > /opt/var/log/dnsmasq_cleared.log
Check if those pesky characters are gone in the temp file:
/opt/bin/grep -Pa '\x00' /opt/var/log/dnsmasq_cleared.log
If so, move it and restart Dnsmasq:
mv -f /opt/var/log/dnsmasq_cleared.log /opt/var/log/dnsmasq.log
service restart_dnsmasq

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!