How can you check the Mac Address of an IP for MikroTik VPS by CL and with Winbox?

How can you check the Mac Address of an IP for MikroTik VPS by CL and with Winbox?

How to get IP, MAC, and EtherPort for all currently active EtherPorts?
I.e., for ports of router/switch that have active/alive devices attached? We, of course, mean the IP and MAC of the attached device and the EtherPort of the router/switch.

The commands show the mac-address-table on a MikroTik Router. In addition to using the command line to show the mac address table, in this tutorial, I will also show you how to search for a specific MAC address and filter the table to show mac addresses learned through a specific port. You should know several commands, depending on how your router is configured.

The two types of configuration are software switching (using bridge interfaces) and hardware switching. You can have a valid configuration that uses both. And in this scenario, separate mac address tables are maintained.

Code:
{
:local ethlist {"ether1-WAN1";"ether2-WAN2";"ether3-LAN1";"ether4-LAN2"};
:local buffer;
:local fileName "address-list";

:foreach a in=$ethlist do={
	:if ([/interface ethernet print as-value where name=$a && running=yes]) do={
		:foreach i in=[/ip arp print as-value where interface=$a] do={
			:set $buffer ($buffer." address=".$i->"address"." - mac-address=".$i->"mac-address"." - ETH=".$a."\n");
		}
	}
}

/file print file=$fileName where name="";
delay 1s;
/file set $fileName contents=$buffer;
}

You need to set your values for variable enlist (this is an example), adding all of your ETH interfaces; the script will list only addresses from those running.

You can try this script, which lists all needed data in a file.

Code:

{
:local ethlist {"ether1-WAN1";"ether2-WAN2";"ether3-LAN1";"ether4-LAN2"};
:local buffer;
:local fileName "address-list";

:foreach a in=$ethlist do={
:if ([/interface ethernet print asvalue where name=$a && running=yes]) do={
:foreach i in=[/ip arp print asvalue where interface=$a] do={

 

I hope you have enjoyed this tutorial about querying the mac address-table from the RouterOS command line.

Also, we have been provided a good Video for checking the Mac Address of an IP for MikroTik VPS by CL and with Winbox.