Community discussions

MikroTik App
 
tandrot8
just joined
Topic Author
Posts: 17
Joined: Thu Feb 23, 2017 10:33 am

How can I see the mac address connected directly to switch port

Thu Feb 23, 2017 6:09 pm

Hi to all!

My question is this:
How can I see what MAC address is connected to a port on CRS226-24G-25+RM as a switch with no bridge and no routing functionality
(e.g.: on port ether8 is directly connected a workstation with some MAC address. The master-port for ether8 is port ether2.)?

After running Tools>IP Scan I can see IP addresses and MAC addresses and immediately in IP>ARP I see IP addresses, MAC addresses and interface ether2 but
no other ethernet ports even if the workstations are connected to the other ports.

Thank you.
 
arnoldmikro
newbie
Posts: 27
Joined: Sun Apr 14, 2013 5:12 pm
Location: miami fl usa

Re: How can I see the mac address connected directly to switch port

Fri Feb 24, 2017 12:41 am

Look at switch - FDBs
 
User avatar
docmarius
Forum Guru
Forum Guru
Posts: 1222
Joined: Sat Nov 06, 2010 12:04 pm
Location: Timisoara, Romania
Contact:

Re: How can I see the mac address connected directly to switch port

Fri Feb 24, 2017 9:07 am

Torch can also be your friend here...
 
tandrot8
just joined
Topic Author
Posts: 17
Joined: Thu Feb 23, 2017 10:33 am

Re: How can I see the mac address connected directly to switch port

Tue Feb 28, 2017 9:23 am

@docmarius: from what I see, Torch can't tell me on what switch port is connected a particular MAC address.
@arnoldmikro: I did, but didn't help me too much.
Thank you for your answers.
 
tandrot8
just joined
Topic Author
Posts: 17
Joined: Thu Feb 23, 2017 10:33 am

Re: How can I see the mac address connected directly to switch port

Mon Mar 13, 2017 2:32 pm

Hi!

The following script is used to associate IP address of directly connected stations to physical port of the switch.
Warning: Running this script will make the CPU go to 100% for about 30-40 seconds, so please run the script when needed or by using scheduler.
##Script to associate IP address of directly connected stations to physical port of the switch#
##Tested with RouterOS v6.38.1 on CRS226-24G-2S+(mipsbe)##
##Authors: Xantos and tandrot8.

## Based on:##
## Script for Dynamic/Static arp ##
## Tested with RouterOS v6.37rc27 ##
## from BrasDeutscher,Para,Brazil ##
##!!!!Steps:##
## 1. Run: /tool ip-scan duration=10 ##or time value as needed ##
## 2. Run: /ip arp print ##to confirm dynamic values in table ##
## 3. Run script from above:
##

{

## Set here yes for dynamic or no for static arp's ##
:global state yes

## defined variables
:global int
:global ip
:global mac
:global port
:global macs

## ether2 in this case is switch master port##

:foreach b in=[/interface ethernet switch unicast-fdb find where dynamic=$state  and  port!="ether2"] do={
:set port [/interface ethernet switch unicast-fdb get $b port ];
:set macs [/interface ethernet switch unicast-fdb get $b mac-address ];
    {
    :foreach a in=[/ip arp find where dynamic=$state and mac-address!=00:00:00:00:00:00 ] do={
        :set mac [/ip arp get $a mac-address ];
        :if ( $mac = $macs) do={    
            :set int [/ip arp get $a interface ];
            :set ip [/ip arp get $a address ];
            :log warning ("IP - $ip  with Mac - $mac on Ethernet Port - $port")
            }
        }
    }
    }
:log warning ("End of script")
}
Hope this script will help!

Who is online

Users browsing this forum: diasdm, Google [Bot] and 169 guests