Noob question, I use static DHCP and I have set “human-friendly” comments to help me identify known devices e.g. “Bob’s computer”. I was wondering if there’s any way to copy these comments to the ARP list, or to add comments to entries in the ARP list. In the ARP list, if I make an entry static then it allows me to add a comment, but that’d be a manual process , besides, I’m not sure whether using static ARP assignments has other undesired side effects. Maybe this is feature request material? Essentially what I would like is a database that links a Name Alias text string to a MAC ID, then the Name Alias can be displayed elsewhere (DHCP leases, ARP list, etc).
#arp-with-dhcp-comments
#store as a script then run from cli with somehting like: "sys script run arp-with-dhcp-comments"
#Works through arp list printing entries with DHCP sourced comments
#Builds a comment string allowing for multiple comments, though it seems quite unlikley this is needed.
:local arp [ip arp print as-value]
:local leases [ip dhcp-server lease print as-value]
:local comments
:foreach arpLine in=$arp do={
:if ([:len [:tostr ($arpLine->"mac-address")]]>0) do={
:foreach leasesLine in=$leases do={
:if ( ([:len ($leasesLine->"comment")]>0) and (($leasesLine->"mac-address")=($arpLine->"mac-address")) ) do={
:set comments ($comments.", ".($leasesLine->"comment"))
}
}
#trim first 2 char
:set comments [:pick $comments 2 ([:len $comments])]
#output
:put [(($arpLine->"mac-address")." - ".($arpLine->"interface")." - ".($arpLine->"address")." - ".$comments)]
:set comments ""
}
}