ASCII hardware address
Martin Jackson
mhjacks at swbell.net
Wed May 31 23:00:21 UTC 2006
Robin Breathe wrote:
> Hello,
>
> I have problems obtaining a nice ASCII representation of the client
> hardware address within "on ..." clauses.
> Using the following syntax:
> binary-to-ascii(16, 16, ".", suffix(hardware,6))
> I get things like "d.38b.cde8" when I expect "000d.038b.cde8".
> Is there any way to get dhcp-eval to output the complete format without
> dropping leading zeros or must this be "cleaned up" in post processing?
> If there's a quicker way to fish out the full address, I'm all ears.
>
> Regards,
> Robin
>
This should be a FAQ...I remember asking it a while ago. :) Here is
what's running on my dhcpd server pair:
set macaddr = concat (
suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 1, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 2, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 3, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 4, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 5, 1))),2),
suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 6, 1))),2)
);
The result is guaranteed to be 12 digits. You can then do things with
macaddr - I use it to construct ddns-hostnames for clients that don't
supply them.
Thanks,
Marty
More information about the dhcp-hackers
mailing list