Searching dhcp.leases for an IP (by MAC)

Chris Carey chris.carey at gmail.com
Tue Dec 12 09:20:37 MST 2006


I need to write a function to search dhcpd.leases file to find IP
addresses (I have the corresponding MAC address). This would be easy
for me if the file had each lease on one line. In that case I could
just grep for the MAC address , then parse out the IP address.
However, the IP address is 5 lines above the said MAC address:

lease 10.10.32.209 {
  starts 1 2006/12/11 19:04:32;
  ends 2 2006/12/12 19:04:32;
  binding state active;
  next binding state free;
  hardware ethernet 00:02:a1:1a:9c:94;
  uid "\001\000\002\241\032\234\221";
}

I have some (pretty nasty) ideas of how to go about this but none of
them are going to be very efficient.

Ideas?



More information about the PLUG mailing list