Table of Contents

Logging DNS Queries

ClearOS, by default, sends a log of all the DNS queries that hit the local caching server to the system log service. However, there is not log file set up for these messages. A simple change can register these queries to a log file but caution should be used as this log can grow very big on an active network. That being said, this can be a very, VERY effective tool for monitoring traffic for two reasons.

Setup

You will need to modify the /etc/rsyslog.conf file and add the following line near the bottom of the file:

daemon.debug /var/log/daemon.log
This logging facility is for more than just dnsmasq, simple filtration through will show only the DNS queries. This will be discusses later
This method is very chatty and produces large log files. Be sure you have sufficient space for the task if you use this method for more than just casual monitoring. I've also not tested log rotations yet so be careful.

Once you have made the change, restart the rsyslog service. A simple 'reload' of the service will NOT work.

service rsyslog restart

Viewing the data

Now you will see the DNS queries flow into this file. To make sense of it, you will likely want to view it with search tools. You can also view it live. Here are some examples:

tail -f /var/log/daemon.log
tail -f /var/log/daemon.log | grep dnsmasq
tail -f /var/log/daemon.log | grep dnsmasq | grep "query\[A\]"
tail -f /var/log/daemon.log | grep dnsmasq | grep "query\[A\]" | grep 192.168.1.101

Removal

Since this file is chatty, you may want to remove the logging of this data. To do this merely remove the line in /etc/rsyslog.conf which was added at the start or comment it so that you can refer to it later:

#daemon.debug /var/log/daemon.log

Be sure to restart the rsyslog service:

service rsyslog restart

search?q=clearos%2C%20clearos%20content%2C%20kb%2C%20howtos%2C%20maintainer_dloper%2C%20maintainerreview_x%2C%20keywordfix&btnI=lucky