For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > Detect DHCP Servers With Systemd

Detect DHCP Servers With Systemd

Created by dave. Last edited by dave, 119 days ago. Viewed 211 times. #3
[diff] [history] [edit] [rdf]
labels
attachments
(2019-05-27)

Problem

Need to detect DHCP servers on the local network.

Pretty Crude Solution

/etc/systemd/system/dhcp-monitor.service:

[Unit]
Description=dhcp-monitor
After=network-online.target
Wants=network-online.target

[Service] Type=forking ExecStart=/usr/bin/flock /var/lock/dhcp-monitor /usr/local/sbin/start-dhcp-monitoring

[Install] WantedBy=multi-user.target

/usr/local/sbin/start-dhcp-monitoring:

#!/bin/bash

tcpdump -i ens192 -nev udp src port 67 | egrep 'Broadcast|bootps' | logger -t dhcp-monitor &

Alerting on rogue DHCP servers is left as an exercise for the reader.

Like I said, crude.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt