Return MAC address given the IP address

Hi All

Could any script guru advise on the right syntax for using the find command to return a MAC address from the /IP ARP list given the ip address?

many thanks.

/ip arp get [/ip arp find address=$ip] mac-address

(assuming $ip is a local or global variable with the IP address)

You Star!

Thankyou

That didn’t work for me, i found that the below did.

:global macaddy [get [find address=172.16.1.11] mac-address]]
:put $macaddy

Script for Dynamic/Static arp

Testet with RouterOS v6.37rc27

from BrasDeutscher,Para,Brazil

{

Set here yes for dynamic or no for static arp's

:global state yes

!!-- Do not change any below, this can breake the Script --!!

:global int
:global ip
:global mac
:foreach a in=[/ip arp find where dynamic=$state ] do={
:set int [/ip arp get $a interface ];
:set ip [/ip arp get $a address ];
:set mac [/ip arp get $a mac-address ];
:log warning ("IP - $ip on Interface - $int with Mac - $mac");
}}

Script v2 for Dynamic/Static arp

Testet with RouterOS v6.37rc27

from BrasDeutscher,Para,Brazil

{

Set here yes for dynamic or no for static arp's and desired IP address

:global state yes
:global ip 10.0.0.2

!!-- Do not change any below, this can breake the Script --!!

:global mac
:foreach a in=[/ip arp find where address=$ip dynamic=$state ] do={
:set mac [/ip arp get $a mac-address ];
:log warning ("IP - $ip to Mac - $mac");
}}