Author Topic: Changing log file location of dhcp  (Read 1990 times)

nbhanji

  • Zen Apprentice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Changing log file location of dhcp
« on: September 15, 2020, 03:45:19 pm »
Hi,

Apologies, if this is discussed before, but cannot find it.
I have the DHCP logs being recorded in /var/log/dhcp/dhcp.log.  I cannot find how to disable DHCP from writing to Syslog.

Can someone point me where I can find the info to disable ISC-DHCP-server from writing to Syslog file?

Thanks in advance.

doncamilo

  • Zen Samurai
  • ****
  • Posts: 478
  • Karma: +165/-1
    • View Profile
Re: Changing log file location of dhcp
« Reply #1 on: September 17, 2020, 06:04:12 pm »
 :)

You need modify your zentyal dhcp.conf template and the rsyslog config.

Code: [Select]
sudo su -
mkdir -p /etc/zentyal/stubs/dhcp
cp /usr/share/zentyal/stubs/dhcp/dhcpd.conf.mas /etc/zentyal/stubs/dhcp/

Edit the /etc/zentyal/stubs/dhcp/dhcpd.conf.mas adding:

Code: [Select]
log-facility local7;

Your file has to have this aspect after editing:

Code: [Select]
etc...
# Cisco IP phones
option voip-tftp-servers code 150 = array of ip-address;
option shoretel-director-server code 155 = ip-address;

log-facility local7;

pid-file-name "<% $pidFile %>";
etc...
[code]

Open the */etc/rsyslog.d/50-default.conf* file and add this line:

[code]
local7.*                        -/var/log/dhcp.log

The file after editing should have this aspect:

Code: [Select]
... etc
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                         /var/log/cron.log
#daemon.*                       -/var/log/daemon.log
kern.*                          -/var/log/kern.log
#lpr.*                          -/var/log/lpr.log
mail.*                          -/var/log/mail.log
#user.*                         -/var/log/user.log
local7.*                        -/var/log/dhcp.log
#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
etc...
[code]

Create the defined log file:

[code]
sudo touch /var/log/dhcp.log
sudo chown syslog:adm /var/log/dhcp.log
[code]

Restart rsyslog and dhcp:

[code]
systemctl restart rsyslog
zs dhcp restart

Check /var/log/dhcp.log

Code: [Select]
less /var/log/dhcp.log

You'll have the dhcp logs into the syslog file too if you maintain this line in  */etc/rsyslog.d/50-default.conf*

Code: [Select]
*.*;auth,authpriv.none          -/var/log/syslog

You'll have to remove the wildcard selector *.* and to use the explicit list of services that you want to store on syslog. Be cautious!

Cheers!



« Last Edit: September 17, 2020, 06:25:47 pm by doncamilo »
- Do my pigeons bother you passing over your land?
- They block the sun!

G. Guareschi., Don Camillo.,