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.

  • 7
    Why would a switch port have a MAC address? It's not a communications endpoint -- it is neither the source nor the destination of any Ethernet traffic. – David Schwartz Jun 12 '13 at 5:23
  • 2
    Some managed switches have a per-port or per-VLAN MAC address. The Cisco command in spuder's answer will show this. – Paul Gear Jun 18 '13 at 22:37
  • 1
    Damianman, it's very unlikely that DHCP vs. static IPs is the cause of your switch not seeing the client MACs. In fact, if your switch is not seeing the MACs at layer 2, then it's not working at all, because that's what a switch does. Pinging your switch's management IP from a client PC (as long as they're in the same VLAN) should be all that's necessary for the switch to see the PC's MAC in the ARP table. – Paul Gear Jun 18 '13 at 22:48
  • 1
    @PaulGear Thank for for the extra input. My host machine had 3 interfaces with each one in a different subnet than my switches managed IP. Not really sure why my switch was not picking up mac-addresses until I set them to DHCP though. If I figure the exact answer, I will edit the above. – Damainman Jun 19 '13 at 0:03

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
    ChassisID:    mac 28:a6:8e:03:57:9b
    SysName:      core-pri
    SysDescr:     Netgear Gigabit Smart Switch
    Capability:   Bridge, on
    PortID:       local g22
    PortDescr:    Not received
  • 2
    And again, if you're lucky the switch will actually be running lldp. – bahamat Jun 24 '13 at 23:12
  • 1
    Fortunately, the lldpd package also supports CDP and a few others. W00t! – MikeyB Jun 26 '13 at 4:38

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).

  • 6
    All managed switches have MAC addresses, sometimes one per VLAN or one per port; might be a good idea to clarify that you mean unmanaged switches. – Paul Gear Jun 18 '13 at 21:49

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

  • 4
    A couple of issues: dumb switches are very rarely called network bridges (even though that is what they do); I would suggest just calling them unmanaged switches. The arp command will only work if 1. its management IP is on the same VLAN, and 2. the PC has contacted it recently. – Paul Gear Jun 18 '13 at 21:54
  • Good point, I modified my answer to make the distinction of managed/unmanaged clearer. And you are correct about the arp command. – spuder Jun 18 '13 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.