Configure ISC DHCP Logging

Let’s be honest, fishing through /var/log/messages becomes difficult on a big network where 100’s or 1000’s of DHCP exchanges happen. There are some cases where it’s better to be in a separate log file all together. ISC dhcpd can send its messages to a syslog facility you choose; rsyslog (or syslog-ng) then writes that facility to /var/log/dhcpd.log.

Prerequisites

  • Root on the DHCP server.
  • ISC dhcpd already installed and working (dhcp / dhcp-server package).
  • rsyslog as the system logger (default on CentOS/RHEL 6 and later).

1. Tell dhcpd to use local7

Edit dhcpd.conf and add this line (usually near the top with the other global options):

log-facility local7;

Use any free local facility (local0–local7) if local7 is already taken on your host — just keep the facility matched in rsyslog.

2. Map local7 to a dedicated log file

Edit /etc/rsyslog.conf and append:

local7.* /var/log/dhcpd.log

On CentOS/RHEL 7 and later you can instead drop a file such as /etc/rsyslog.d/dhcpd.conf with that same line so package updates do not touch your change.

Optional but useful: rotate the file with a small logrotate snippet for /var/log/dhcpd.log, and add $FileCreateMode 0640 if you want tighter permissions on new log files.

3. Restart DHCP and rsyslog

Restart DHCP/rsyslogd:

service dhcpd restart
service rsyslogd restart

On CentOS 7+ the rsyslog service name is rsyslog (no trailing d):

systemctl restart dhcpd
systemctl restart rsyslog

That’s it!

Verify

tail -f /var/log/dhcpd.log

Force a client renew (or watch for the next lease) and you should see DHCPDISCOVER/DHCPOFFER/DHCPREQUEST/DHCPACK lines in that file instead of only in /var/log/messages. Confirm dhcpd is still serving with systemctl status dhcpd (or service dhcpd status).

Troubleshooting

  • Nothing appears in dhcpd.log: the facility in dhcpd.conf does not match rsyslog, rsyslog was not restarted, or SELinux is denying the write. Check /var/log/messages for rsyslog errors and confirm the line with grep local7 /etc/rsyslog.conf /etc/rsyslog.d/*.
  • dhcpd fails to start after the edit: a syntax error in dhcpd.conf. Test with dhcpd -t -cf /etc/dhcp/dhcpd.conf (path may be /etc/dhcpd.conf on older releases).
  • Messages still flood /var/log/messages: some rsyslog configs also catch local7 via a catch-all rule. Add a stop marker after your dhcpd rule if needed (& stop in rsyslog v7+), or exclude local7 from the messages rule.

AlmaLinux, Rocky Linux and RHEL 9–10

The same log-facility directive works. Package names are dhcp-server and rsyslog, config is usually /etc/dhcp/dhcpd.conf, and you manage services with systemctl as above. After creating /var/log/dhcpd.log rules, run systemctl restart rsyslog dhcpd and follow the file with journalctl -u dhcpd -f as a second check.

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: Configure DHCP Server CentOS 6 | Configure DHCP Reservation CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *