LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-16-2022, 11:27 PM   #1
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
Perl - OpenBSD : what module would be best for logging DNS requests?


hello guys / gals.

i would like to log my networks dns requests, just to compare those to bad_hosts and malware_domains lists.

i dont need written script, just friendly nudge towards right (module) direction :P
 
Old 01-17-2022, 10:59 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,617

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Quote:
Originally Posted by ////// View Post
hello guys / gals.

i would like to log my networks dns requests, just to compare those to bad_hosts and malware_domains lists.

i dont need written script, just friendly nudge towards right (module) direction :P
1. Are you using your own nameserver, or trying to do this at the client side?
2. What are you running, and a bit about the hardware and network please?
 
Old 01-17-2022, 11:18 AM   #3
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Original Poster
Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
Quote:
Originally Posted by wpeckham View Post
1. Are you using your own nameserver, or trying to do this at the client side?
2. What are you running, and a bit about the hardware and network please?
thanks bud for the reply

client side, basically i need just packet sniffer which listens to tcp/udp 53 and writes em to dns_log.txt
i think some dns traffic uses https, am i right ? if thats the case i cant sniff it.

i use 8.8.8.8 and 8.8.4.4 nameservers. <- googles nameservers.

using OpenBSD , at Linux there is program called "passivedns" i have tried to compile it with BSD but couldnt do it.
https://github.com/gamelinux/passivedns

at my linux box i use ^that program to log dns traffic, i need to do that now at OpenBSD. and with perl.
 
Old 01-17-2022, 12:03 PM   #4
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,617

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
I have run my own DNS server (Caching and forwarding) in my home network, and could set it's logs to provide information that would serve this purpose. That would be easy.

To do this on the client side, and where some or all requests may use encrypted DNS, might take some research into the network and require a special kernel module. That sounds like a fun project, but I have no resources to spend on that right now.

It might be somewhat workable to track just traditional resolution calls going out to your nemeserver. Perhaps a better option would by to install and use something like DNSMASQ and cache name service directly on your client. This has the advantage of reducing DNS calls going outside your box, speeding up some kinds of network activity (in some cases a lot), and providing you something that can LOG all of that traffic. That is the solution I would check out before setting out to reinvent the horse.

Keep in mind that you are creating a log that can, unless managed, grow without bound. You must consider and manage your log size and storage space. Logrotate can be your friend here, but make sure that it can only run after you have parsed the data you need out of the logs.

All of this, of course, assumes that the logging is your goal. If your real goal is to write a PERL script then we need a different solution path.

Last edited by wpeckham; 01-17-2022 at 12:04 PM.
 
1 members found this post helpful.
Old 01-17-2022, 12:51 PM   #5
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Original Poster
Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
yeah, i think i could set up my own DNS server, i like to practice new things.
my box has 100G var partition and 1.3T home partition so dns logs can be as big as they get.

now i have to read about dns servers.

thanks.
 
Old 01-18-2022, 10:18 AM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,617

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
For this purpose BIND would be overkill. you only need a caching DNS server that can log activity. There are smaller and faster options than BIND for that, and generally easier to understand and manage.
 
1 members found this post helpful.
Old 01-18-2022, 02:05 PM   #7
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Original Poster
Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
would Unbound be good ? i think it is part of OpenBSD install if i remember correctly.
 
Old 01-18-2022, 04:44 PM   #8
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,617

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Quote:
Originally Posted by ////// View Post
would Unbound be good ? i think it is part of OpenBSD install if i remember correctly.
I have never used unbound. It does DNS over TLS, so it should be secure, but requires you to manage your keys. Are you comfortable with that?

It may also be overkill for what you need, but I have nothing negative to say about it. I would hope someone with experience with it might weigh in.
 
Old 02-03-2022, 12:44 PM   #9
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Original Poster
Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
i found a solution, it is program called zeek.
https://docs.zeek.org/en/master/quickstart.html

it logs all dns traffic to text.logs
and it is full of different usage modes, not just logging of dns traffic.
https://docs.zeek.org/en/master/log-formats.html

screeny here :

https://i.imgur.com/zpI0d0E.png

Last edited by //////; 02-03-2022 at 12:55 PM.
 
1 members found this post helpful.
  


Reply

Tags
zeek



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 2.4 requests to non-SSL site with "Upgrade-Insecure-Requests: 1" and no trailing / get redirected to default site owendelong Linux - Server 2 06-22-2021 02:08 PM
Help in stopping DNS requests (DNS Amplification) accessthecloud Linux - Server 2 02-18-2013 03:43 PM
can a local DNS Server be used to handle dns requests going out to the internet baronobeefdip Linux - Server 1 07-03-2012 03:19 AM
list perl module & install perl module DBD::mysql linson_85 Linux - Newbie 4 06-22-2009 10:42 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration