TuxInvader / nginx-dns

Sample Configuration for DNS over HTTPS (DoH/DoT gateway) and GSLB with NGINX
BSD 2-Clause "Simplified" License
194 stars 47 forks source link

Log the answers and post-processing #16

Open skon77 opened 1 year ago

skon77 commented 1 year ago

Hi,

Thank you so much for such a great library.

In DNS.J library comments there is this setting (2): 0: No decoding, minimal processing required to strip packet from HTTP wrapper (fastest) 1: Parse DNS Header and Question. We can log the Question, Class, Type, and Result Code 2: As 1, but also parse answers. We can log the answers, and also cache responses in HTTP Content-Cache 3: Very Verbose, log everything as above, but also write packet data to error log (slowest)

Can you give me an example of getting a this answer? To write in _accesslog not only _$dnsqname but also the answer. Something like this: www.baidu.com IN A DNS Answer: www.baidu.com 782 IN CNAME www.a.shifen.com; www.a.shifen.com 103 IN A 61.135.169.125; www.a.shifen.com 103 IN A 61.135.169.121;

And second question about nginx javascript. Is there any way to make a shell command call from the nginx.conf file? There is a need to transfer DNS answer IP to my router via SSH channel. The script itself is there and it works. Selected IP addresses are immediately added to the corresponding Address Lists of my Mikrotik with control commands. The only question is how to pass IP itself from nginx.conf and make SSH call. On the forums mostly suggest Lua for this purpose.

At the moment I can selectively log the domains I want. In the Address Lists of my Mikrotik, I can either forward IPs or domains. But IP is more preferable for me.

log_format dns '$dns_qname'; access_log /var/log/nginx/dns-access.log dns if=$logme;

map $dns_qname $logme { hostnames; *.cdninstagram.com 1; default 0; }

And I can create some daemon to track changes in the log file with further SSH call. But I want a more elegant solution.

Thanx!