Turn on DNS Query Log on Bind

You are running a recursive DNS server and would like to find out the statistic of your user browser behavior (Whether they browse Facebook or Google?). Turn on DNS query logs will allow you to find out the statistic. To turn on DNS query log in Bind, configure lines below on named.conf


logging{
        channel query_logging {
                file "/var/log/query.log" versions 3 size 10m;
                severity debug 3;
                print-time yes;
                print-severity yes;
                print-category yes;
        };

        category queries {
                query_logging;
        };
};

To turn on query logging while DNS service is running; you need to to rndc querylog and check the status with rndc status


shell> rndc querylog
shell> rndc status 
version: 9.x.x
number of zones: 1200
debug level: 3
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is ON
recursive clients: 0/0/1000
tcp clients: 0/100
server is up and running

query logging is ON indicates that DNS query logging is activated.