[Dnsmasq-discuss] 'dnsmasq_client_id' not always present on dhcp-scripts

Simon Kelley simon at thekelleys.org.uk
Tue Sep 6 21:23:03 UTC 2022



On 06/09/2022 17:23, Taylor Fox wrote:
> Hello,
>       I am trying to write a script for logging & notification whenever 
> a new DHCP lease is issued, and I currently have a script that uses the 
> `dnsmasq_client_id` environment variable to get the MAC address of the 
> device that the lease was issued, but I have had an issue where on some 
> device that variable is not present and causes the script to fail. Could 
> anyone shed a light on why this is not working? Otherwise, any better 
> way of finding the MAC address other than diffing /etc/dhcp.leases.
> 
> 

Some DHCP clients don't provide a client-id. If the client doesn't 
provide a client-id, the variable will not be set. If you look in 
/etc/dhcp.leases, if the fifth and final field on a line is "*" then no 
client-id was provided.

extracting the MAC address from a client-id is risky: client-ids may be 
constructed in other ways.

The MAC address is always provided (at least for DHCPv4) as the second 
argument of the script, does that solve the problem?


Simon.



> Thanks in advance.
> 
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss



More information about the Dnsmasq-discuss mailing list