Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoAccess for DNS query logs (Bind9) #2346

Closed
kpgreene opened this issue Jul 1, 2022 · 7 comments
Closed

GoAccess for DNS query logs (Bind9) #2346

kpgreene opened this issue Jul 1, 2022 · 7 comments

Comments

@kpgreene
Copy link

kpgreene commented Jul 1, 2022

Hello Group:
Has anyone considered the use of GoAccess to study DNS queries?
I get a reasonable amount of queries (~50/second) on my public DNS server and while it is simple to create logs, the ability to display in some sort of usable fashion is a challenge. I was thinking that GoAccess would be a good tool as it is fast and the ability to customize the log format is very useful. That said, I have tried for several hours to create the script to do it and I keep getting a fatal error in the startup process.

Any ideas where I am going wrong? Perhaps it is right in front of me and I do not really understand the file parsing. One line of a DNS query is shown.

This is my simple script with all my notes on it (useful when on a single screen). The spacing of the fields is OK when used on a bigger monitor.

Thank you.

Kevin



# Creates a view of traffic

# Fields needed                                         1       2               3       4       5       6       7       8     910      11      12      13
goaccess -f /var/log/named/queries      log-format      %d      [%* %H:%M:%S]   %^      %^      %^      %^      %h      %r    %^       %^      %^      %^      %^      -o      /var/www/html/ns1-web-report.html

# We want to know the following:
#       Date (1)
#       Time (2)
#       Source IP (7)
#       query (9)
#

#       -f      What log file to use
#       -o      Where to send the output report

# Sample log entry
# 1             2               3               4       5       6               7                                             89                                       10      11      12      13
# 25-Jun-2022   23:41:19.258    queries:        info:   client  @0x7f31eca19ed8 208.69.34.83#56547 (251.128-25.111.140.207.in-a
ddr.arpa):      query:  251.128-25.111.140.207.in-addr.arpa     IN      PTR     -E(0)DC (199.4.110.11)


@kpgreene
Copy link
Author

kpgreene commented Jul 1, 2022

Hello:
It seems my script when pasted turned into something nearly unreadable. I am very sorry it has happen. It seems the GitHub system bit like the pound sign used to comment a line.

I am trying to send it a different way.
I am also showing the error message.

Thank you
Kevin

[root@ns1 scripts]# ./go-dns-access.sh
 [PARSING %^] {0} @ {0/s}
Cleaning up resources...
==74189== GoAccess - Copyright (C) 2009-2020 by Gerardo Orellana
==74189== https://goaccess.io - <hello@goaccess.io>
==74189== Released under the MIT License.
==74189==
==74189== FILE: /var/log/named/queries
==74189== Parsed 10 lines producing the following errors:
==74189==
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189== IPv4/6 is required.
==74189==
==74189== Format Errors - Verify your log/date/time format

@allinurl
Copy link
Owner

allinurl commented Jul 1, 2022

It may be able to extract data from it. Could you please attach a file with some DNS entries on it? Thanks

@kpgreene
Copy link
Author

kpgreene commented Jul 3, 2022 via email

@allinurl
Copy link
Owner

allinurl commented Jul 3, 2022

It looks like the attachment was not posted. You may need to post it via github (attach files by dragging)... Thanks

@allinurl
Copy link
Owner

allinurl commented Jul 6, 2022

Anyways, this should work for bind9 query log (assuming the following format):

06-Jul-2022 15:57:29.353 queries: info: client @0x7fbff80430c0 146.112.174.76#2297 (mail.yahoo.com): query: mail.yahoo.com IN A -E(0)DC (101.170.136.1)

run goaccess as:

goaccess dns.log --log-format='%d %t.%^ %^: %^ %^ %^ %h#%^ (%v) %^ %^ %^ %U %^' --date-format=%d-%b-%Y --time-format=%T --ignore-panel=BROWSERS --ignore-panel=OS --ignore-panel=REQUESTS_STATIC --ignore-panel=NOT_FOUND --ignore-panel=REFERRING_SITES --ignore-panel=STATUS_CODES --http-protocol=no --http-method=no

2022-07-06-160110_474x789_scrot

@kpgreene
Copy link
Author

kpgreene commented Jul 6, 2022

Hello:

The results from your answer were very IMPRESSIVE! I used the first example that was provided.

I found that the biggest abusive group that was hitting my DNS server was out of a middle eastern country (IL). It was roughly 2,000 hits an hour for one specific IP address. I need to now look at the various IP addresses shown as the top query sources to see where they are from.

I also need to get the script to present in a web format but I think I can solve that issue (it easier to print that way).

THANK YOU AGAIN !!!

Kevin

@allinurl
Copy link
Owner

allinurl commented Jul 6, 2022

Happy to hear that worked!

For the html report, you can always pass -o report.html and --real-time-html to make it real-time.

goaccess dns.log -o report.html --real-time-html --log-format='%d %t.%^ %^: %^ %^ %^ %h#%^ (%v) %^ %^ %^ %U %^' --date-format=%d-%b-%Y --time-format=%T --ignore-panel=BROWSERS --ignore-panel=OS --ignore-panel=REQUESTS_STATIC --ignore-panel=NOT_FOUND --ignore-panel=REFERRING_SITES --ignore-panel=STATUS_CODES --http-protocol=no --http-method=no

e.g.,

2022-07-06 17-20

Closing this, feel free to reopen it if needed.

@allinurl allinurl closed this as completed Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants