LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-11-2020, 09:22 AM   #1
CyberIT
Member
 
Registered: Jun 2017
Posts: 56

Rep: Reputation: Disabled
BIND Queries log to Remote Syslog Server


Hello,

I would like to send BIND query logs to a remote syslog server. Logs are currently stored in a log file on the BIND server.

Code:
logging {
...
    channel default_file {
        file "/var/log/named/default.log";
        severity warning;
        print-severity yes;
        print-category yes;
        print-time yes;
    };
    channel queries_file {
        file "/var/log/named/queries.log";
        severity dynamic;
        print-severity yes;
        print-category yes;
        print-time yes;
    };
...

    category default { default_file; };
    category queries { queries_file; };
...

};
I believe I need to change the "channel queries_file" to something like below but Im not sure how to get my syslog server (rsyslog.conf) to recognize it instead of the local BIND server??

Code:
channel queries_file {
        syslog daemon;
        severity warning;
        print-severity yes;
        print-category yes;
        print-time yes;
    };
For my BIND servers, Im using Rhel 7.7; BIND 9.11.4-P2-RedHat-9.11.4-9.P2.el7

For my Syslog servers, Im using Rhel 7.7.


I appreciate all help provided. Thanks!

Last edited by CyberIT; 02-11-2020 at 09:25 AM.
 
Old 02-11-2020, 02:16 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi CyberIT,

You may add the following code in the respective files:

/etc/named.conf:
Code:
channel queries_file {
        syslog local0;
        severity info;
        print-severity yes;
        print-category yes;
        print-time yes;
/etc/rsyslog.conf:
Code:
local0.* @@x.x.x.x:514
Of course you need to configure the remote rsyslog server accordingly and also keep in mind that logging queries produces a great amount of data and thus traffic to the remote logging server.

Regards
 
Old 02-11-2020, 03:20 PM   #3
CyberIT
Member
 
Registered: Jun 2017
Posts: 56

Original Poster
Rep: Reputation: Disabled
Thank you for replying back. I believe I have the BIND servers configured properly with the additional code you mentioned above.
Where am Im getting mixed up is on the actual syslog server configs.


Code:
#### MODULES ####

# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514



#### RULES ####

$template RemoteLogs, "/var/log/client_logs/${HOST}/queries.log"

...
...

# The authpriv file has restricted access.
$FileCreateMode 0600
authpriv.*                       /var/log/secure

I believe the IP within the rsyslog.conf on the BIND server would be of the syslog server, correct? Im getting mixed up on how/where to configure the code to point to the location of the logs to go to.

Question: the IP within rsyslog.conf, does it need to be an IP or can it be a name? syslog.domain,lan? Id like to have multiple syslog servers within a WIP.


Thanks!
 
Old 02-12-2020, 02:03 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Thank you for replying back. I believe I have the BIND servers configured properly with the additional code you mentioned above.
Where am Im getting mixed up is on the actual syslog server configs.
If you used my example above, i.e. use local0 facility to log queries, then you need to use the same in the remote rsyslog server:
Code:
local0.* @@x.x.x.x:514

Quote:
I believe the IP within the rsyslog.conf on the BIND server would be of the syslog server, correct? Im getting mixed up on how/where to configure the code to point to the location of the logs to go to.
Yes, the IP in the local bind server's rsyslog.conf should be that of the remote logging server running rsyslog.


Quote:
Question: the IP within rsyslog.conf, does it need to be an IP or can it be a name? syslog.domain,lan? Id like to have multiple syslog servers within a WIP.
Of course you can use a hostname instead of an IP. But it has to be resolvable by the bind server...
 
Old 02-12-2020, 01:35 PM   #5
CyberIT
Member
 
Registered: Jun 2017
Posts: 56

Original Poster
Rep: Reputation: Disabled
That is where Im getting hung up on. The configuration on the syslog server side to receive the queries logs only on a mount point on the syslog server.

Instead of the queries logs to reside on the DNS server, I would like the queries to reside on the syslog server and the dns server if possible.


syslog server: /etc/rsyslog.conf
Code:
# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514

#### RULES ####

$template Incoming-logs,"/var/log/client_logs/${HOST}/queries.log"
local0.*  ?Incoming-logs
& ~

dns server: /etc/rsyslog.conf
Code:
# ### begin forwarding rule ###
...

local0.* @xx.xx.xx.xx:514

...
# ### end of the forwarding rule ###
dns server: /etc/named.conf
Code:
channel queries_file {
        syslog local0;
        severity info;
        print-severity yes;
        print-category yes;
        print-time yes;
    };

Last edited by CyberIT; 02-12-2020 at 03:07 PM.
 
Old 02-13-2020, 04:02 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Instead of the queries logs to reside on the DNS server, I would like the queries to reside on the syslog server and the dns server if possible.
If you want to keep logs on both servers then you can USE the following in the local server's /etc/rsyslog.conf:
Code:
local0.* @@x.x.x.x:514
local0.* /var/log/query.log

Last edited by bathory; 02-13-2020 at 04:21 AM.
 
Old 02-13-2020, 08:40 AM   #7
CyberIT
Member
 
Registered: Jun 2017
Posts: 56

Original Poster
Rep: Reputation: Disabled
Thank you for that information.
I also figured out why the logs werent going to my syslog server too.


I had the following code...
Code:
$template Incoming-logs,"/var/log/client_logs/${HOST}/queries.log"
local0.* ?Incoming-logs

When it should have been...
Code:
$template Incoming-logs,"/var/log/client_logs/%HOSTNAME%/queries.log"
local0.* ?Incoming-logs

I appreciate the help here!
 
Old 02-25-2020, 02:11 PM   #8
CyberIT
Member
 
Registered: Jun 2017
Posts: 56

Original Poster
Rep: Reputation: Disabled
Hello
Interesting enough ... I find that logging stops each night and I need to restart rsyslog.service on each DNS server along with the Syslog servers to regain the collection of the queries.log

Would you know of what that could be happening? Thanks again!
 
Old 02-25-2020, 03:14 PM   #9
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by CyberIT View Post
Hello
Interesting enough ... I find that logging stops each night and I need to restart rsyslog.service on each DNS server along with the Syslog servers to regain the collection of the queries.log

Would you know of what that could be happening? Thanks again!
Most likely it's logrotate
 
Old 02-25-2020, 10:10 PM   #10
CyberIT
Member
 
Registered: Jun 2017
Posts: 56

Original Poster
Rep: Reputation: Disabled
Yeah it seemed to happen when I introduced log rotation for that file on the syslog servers. Am I missing something here?
Code:
/var/log/client_logs/*log
{
  compress
  create 0644 root root
  daily
  dateext
  missingok
  notifempty
  rotate 10
  sharedscripts
}
 
Old 02-26-2020, 03:00 AM   #11
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by CyberIT View Post
Yeah it seemed to happen when I introduced log rotation for that file on the syslog servers. Am I missing something here?
Code:
/var/log/client_logs/*log
{
  compress
  create 0644 root root
  daily
  dateext
  missingok
  notifempty
  rotate 10
  sharedscripts
}
You need to restart syslogd after rotating logs, so it continues logging.
I guess you can stick your query logfile(s) among the others in /etc/logrotate.d/syslog, so it's rotated by syslog's logrotate.
Or else you need to put a postrotate in your logrotate script above, in order to restart syslogd after rotating query logs
 
Old 02-26-2020, 06:50 AM   #12
CyberIT
Member
 
Registered: Jun 2017
Posts: 56

Original Poster
Rep: Reputation: Disabled
I originally had it in there but wasnt working as I thought.


Code:
  postrotate
    /bin/systemctl reload rsyslog.service > /dev/null 2>/dev/null || true
  endscript
Maybe this instead?
Code:
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
or this?

Code:
  postrotate
    /usr/sbin/rndc reconfig > /dev/null 2>/dev/null || true
  endscript

Last edited by CyberIT; 02-26-2020 at 06:55 AM.
 
Old 02-26-2020, 08:09 AM   #13
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by CyberIT View Post
I originally had it in there but wasnt working as I thought.


Code:
  postrotate
    /bin/systemctl reload rsyslog.service > /dev/null 2>/dev/null || true
  endscript
Maybe this instead?
Code:
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
or this?

Code:
  postrotate
    /usr/sbin/rndc reconfig > /dev/null 2>/dev/null || true
  endscript
I don't use RHEL, but if I had to choose, I'd go with the 2nd option as it's the same in my Slackware box.
Besides the 3rd one only refreshes bind, not syslogd.

Anyway, you should try it yourself, using the debug option in logrotate, so it will just print out what it would do without actually doing it:
Code:
logrotate -d /etc/logrotate.d/yourfile
 
  


Reply

Tags
bind, linux, logging, syslog



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
Why is syslog-ng not recording any log events in /var/log/syslog.log ToffeeYogurtPots Linux - Software 3 05-31-2018 02:15 PM
How to log some kind of queries with BIND 9 sjfdj Linux - Server 1 09-17-2008 04:33 AM
I need help getting syslog to log remotely, this is just the regular syslog. abefroman Linux - Software 2 06-05-2008 11:36 AM
syslog client to log to syslog-ng and itself noir911 Linux - Server 1 02-08-2008 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:20 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