How to find the MAC address of the switch I am connected to?
On a linux server, I am trying to find the MAC addresses that my server is aware of. Specifically the MAC address of the switch port I am connected to.
Is this possible?
Update: The Below answers assisted me. My switch is a managed switch, however because the IP addresses on my host machines were set to static, the switch did not pick up the MAC Addresses for some reason. I changed the hosts to DCHP, which allowed my switch to properly pick up the MAC addresses on the connected ports after they sent DHCP requests. This allowed me to use the switches MAC-Address table to figure out which hosts were connected to which ports and I put the hosts back to static IPs.
If you're lucky, you're running a smart switch and it'll actually have a MAC address.
In that case you can probably use LLDP. Install lldpd
on Linux, then run:
michael:~$ lldpctl
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface: eth0, via: LLDP, RID: 1, Time: 5 days, 22:33:31
Chassis:
ChassisID: mac 28:a6:8e:03:57:9b
SysName: core-pri
SysDescr: Netgear Gigabit Smart Switch
MgmtIP: 10.0.0.38
Capability: Bridge, on
Port:
PortID: local g22
PortDescr: Not received
-------------------------------------------------------------------------------
Switches don't have MAC addresses generally; they work at a level below them (although they do know what the MAC addresses of the devices connected to them are).
It depends what kind of switch you are connected to.
A dumb switch (commonly called an unmanaged switch, which is effectively a network bridge) won't have a MAC address
A managed switch (sometimes called a smart switch) will have a MAC address
If the switch is a managed switch, and you know its IP address, run the following command in your terminal. It is then just match the IP with the MAC address.
arp -a
If you are dealing with a managed switch with a console port, connect with a console cable and enter this command (assuming it is a Cisco switch):
show mac address-table
http://www.techexams.net/forums/ccna-ccent/45578-mac-address-switch.html https://learningnetwork.cisco.com/thread/9625