Any way to filter IP’s when logging queries? (BIND 9.3)

binddomain-name-systemfilteriplogging

I would like to record queries to my DNS from a particular ip. Is this possible?

Right now I have this:

channel query_log {
                file "/var/named/data/queries.log" versions 2 size 1G;
                severity debug 3;
                print-category yes;
                print-severity yes;
                print-time yes;
        };

category queries { query_log;};

As you may imagine, the file "queries.log" grows at an extremely fast rate on our busy network. I just would like to log the queries from a particular ip. Is there a way to do this using any channel option? I thought about creating a separate view (to match the host I want to record) but you can oly have one "logging" option in named.conf (not inside the views) 🙁

Thanks.

Best Answer

I do not think there is any way that you can configure bind to do the filtering you want.

I can think of two ways you could achieve the result I believe you want.

Setup bind query logging, keep only 1 versions, and reduce the size of the logs you are keeping.

Leave a command like below running to constantly monitor changes to the query log and store the information you want to save to a separate file.

tail --follow --retry /var/named/data/queries.log \
      | grep 'ip.ad.dd.res' > /var/named/data/queries_ip.ad.dd.res.log

The second method would be to just use tcpdump to capture all incoming requests from that host. You would use a command like this.

tcpdump -n dst port 53 and src host ip.ad.dd.res > /var/log/dns_ip.ad.dd.res.log