Logging mac address

Jerimiah Cole jcole at tbtc.net
Fri Jan 8 23:22:48 UTC 2010


Ben Wiechman wrote:
> I'm sure this is dead simple but I haven't been able to track down the
> solution. 
> 
> Is the client's mac address accessible in any of the available options?

Yeah, it's called 'hardware'.

> I am trying to log the pertinent option 82 sub-options along with the
> assigned IP and requesting client's mac address on one line.

My config does that (along with the UID):

if binary-to-ascii(10,8,".",substring(option agent.remote-id,4,4)) = 
"192.168.238.192" {
   log(
     info,
     concat(
       "PVC for ",
       binary-to-ascii(10,8,".",leased-address),
       " (",
       concat (  # MAC
        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)
       ),        # End MAC
       ") (gw.tul) is:  ",
       binary-to-ascii(10,8,"",substring(option agent.remote-id,9,1)),
       "/",
       binary-to-ascii(10,16,"",suffix(option agent.remote-id,2)),
       " uid:",
       pick-first-value(binary-to-ascii(16,8,":",option 
dhcp-client-identifier),"UNSPECIFIED")
     )
   );
}

Comes out something like:

Jan  8 16:12:48 2010 dhcpd: PVC for 10.3.3.150 (00:ff:ff:44:69:1a) 
(gw.tul) is:  1/160 uid:1:0:ff:ff:44:69:1a



IIRC, that concat(suffix,suffix) stuff is to get the individual octets 
zero-padded correctly.  If you simply specify 'hardware', they aren't 
zero-padded (like the UID portion of the output).

Jerimiah



More information about the dhcp-users mailing list