DHCP Log Messages in Syslog or Systemd Journal

When administering a DHCP server, monitoring and analyzing log messages is crucial for troubleshooting and ensuring the server is functioning correctly. ISC DHCP server logs various events and messages to the syslog or the systemd journal, depending on your system's configuration.

Viewing DHCP Log Messages

Syslog

On systems using traditional syslog, DHCP messages are typically logged to specific log files, such as /var/log/syslog or /var/log/messages. These files can be accessed directly or filtered using tools like grep.

Example: Viewing DHCP messages in syslog

sudo grep dhcp /var/log/syslog

Systemd Journal

On systems using systemd, the journalctl command is used to view log messages. The DHCP server messages can be filtered by specifying the dhcpd service.

Example: Viewing DHCP messages using journalctl

sudo journalctl -u isc-dhcp-server

Common DHCP Log Messages

Here are some common log messages you may encounter:

Lease Assignments

When the DHCP server assigns an IP address to a client, you will see messages similar to:

DHCPDISCOVER from 00:11:22:33:44:55 via eth0
DHCPOFFER on 192.168.1.10 to 00:11:22:33:44:55 via eth0
DHCPREQUEST for 192.168.1.10 from 00:11:22:33:44:55 via eth0
DHCPACK on 192.168.1.10 to 00:11:22:33:44:55 via eth0
  • DHCPDISCOVER: The client is requesting an IP address.

  • DHCPOFFER: The server is offering an IP address to the client.

  • DHCPREQUEST: The client is requesting the offered IP address.

  • DHCPACK: The server is acknowledging the client's request and assigning the IP address.

Lease Expirations

When a lease expires, you might see messages like:

DHCPRELEASE of 192.168.1.10 from 00:11:22:33:44:55 via eth0 (expired)
  • DHCPRELEASE: The client is releasing the IP address.

  • expired: Indicates that the lease has expired.

Lease Renewals

When a client renews its lease, the following messages are typical:

DHCPREQUEST for 192.168.1.10 from 00:11:22:33:44:55 via eth0
DHCPACK on 192.168.1.10 to 00:11:22:33:44:55 via eth0

Declines and Errors

Errors or declined IP addresses are also logged:

DHCPDECLINE on 192.168.1.10 from 00:11:22:33:44:55 via eth0: address already in use
  • DHCPDECLINE: The client has declined the IP address.

  • address already in use: Indicates a conflict or error.

Log Configuration

Syslog Configuration

The dhcpd daemon can be configured to send its log messages to a specific facility and level in syslog. This can be set in the dhcpd.conf file or the syslog configuration.

Example: Configuring syslog for DHCP

  1. Edit syslog configuration (e.g., /etc/rsyslog.conf):

    local7.* /var/log/dhcpd.log
  2. Restart the syslog service:

    sudo systemctl restart rsyslog
  3. Configure DHCP to use the specified facility (in dhcpd.conf):

    log-facility local7;

Systemd Journal Configuration

For systems using systemd, the DHCP server logs are managed by journald. To ensure persistent logging, configure journald as follows:

  1. Edit the journald configuration (e.g., /etc/systemd/journald.conf):

    [Journal]
    Storage=persistent
  2. Restart the journald service:

    sudo systemctl restart systemd-journald

Analyzing Log Messages

Real-Time Monitoring

You can monitor DHCP logs in real-time using tail or journalctl:

Using tail for syslog:

sudo tail -f /var/log/syslog | grep dhcp

Using journalctl for systemd:

sudo journalctl -u isc-dhcp-server -f

Filtering and Searching

Use grep or journalctl to filter specific log messages:

Example: Searching for a specific MAC address:

sudo grep '00:11:22:33:44:55' /var/log/syslog

Using journalctl with grep:

sudo journalctl -u isc-dhcp-server | grep '00:11:22:33:44:55'

Conclusion

Monitoring and understanding DHCP log messages are crucial for maintaining a healthy network. Whether using syslog or the systemd journal, being able to view, filter, and analyze these logs allows you to troubleshoot issues, monitor lease assignments and expirations, and ensure efficient IP address management. Proper configuration of logging facilities ensures that you capture all necessary information and can retain it as long as needed for auditing and analysis.

Last updated