3

I have what I thought would be a quick question, but it seems harder to do than I originally thought.

Let's say I'm connected to a Cisco device (switch or a router). How would I list interface names and the associated MAC addresses for the interfaces? Like, I don't want any more information than that. (I can handle a tiny bit of extra stuff, but nothing too crazy. Ideally, I'd like name/MAC address on one line, but I can deal with 2 lines if that's easier to do.)

NOTE: I do not mean the ARP cache. I just want the MAC address that is assigned to that interface, as well as the interface name.

3 Answers 3

5

You can roughly accomplish this by regex'ing the show interfaces command:

show interfaces | i (.* line protocol is )|(.* address is)

This will produce fairly concise output with the interface on one line, and the MAC indented below it. E.g. from my 7200 in GNS3:

FastEthernet0/0 is administratively down, line protocol is down
     Hardware is DEC21140, address is ca01.3cd1.0000 (bia ca01.3cd1.0000)

You can find further regex documentation on Cisco's website: http://www.cisco.com/c/en/us/td/docs/ios/termserv/configuration/guide/15-mt/tsv-15-MT-book/tsv_reg_express.html

Keep in mind the example I provided is dependent on the format of show interface's output. You'll need to adjust "line protocol is" and/or "address is" appropriately to make the regex match the appropriate lines. ("bia" is probably a good alternative, for example.)

3
  • I reckon this is the closest I'll get. Thanks. I'm not at home, so I can't test the solution yet, but I was using this technique earlier when I asked. Giving you the answer because I think yours helped the most.
    – Dalton
    Jul 5, 2017 at 23:04
  • No problem. Curious, what are you trying to accomplish? I assumed this might be for some programmatic interaction, but then I'd probably handle filtering in-code rather than by using regex on a show command.
    – boomi
    Jul 6, 2017 at 2:40
  • I'm analyzing packet captures and trying to find a quick way to associate a MAC address with a specific interface on a specific device. I know there's gotta be way better ways of doing it, and I know I'm doing the "I want Y, but let me ask about X" thing. I just wanted to try and find my own solution, but I suck at cisco administration. Thanks again buddy.
    – Dalton
    Jul 6, 2017 at 13:20
0

It is pretty simple to get the information you want. You can use the show interfaces command to find what you are looking for, but you are going to get a lot more information, too. You simply ignore the unnecessary information. You are not going to get it in the format you want, but you can copy it from your terminal and massage it.

This will also show you the currently configured MAC address and the BIA.

0

Show mac-address table or show mac-address-table will give you the interface (the given name, not the name you assign it) and MAC Addresses. Some switches/ios versions have a slight variation of the command. That's why I showed it two different ways. It will show multiple MAC addresses on the uplink port that connects to other switches.

EDIT-adding content**

The column title in the command is a destination address. It identifies the mac address that is on that port. The MAC table or CAM table only records source addresses. I'm not sure why it's labeled Destination Address. I know you don't want to know about the ARP command but this command and the ARP command together you can find devices on your switches.

Here is a quote from www.packet6.com...

"The CAM table, or content addressable memory table, is present in all Cisco Catalysts for layer 2 switching. It is used to record a stations mac address and it’s corresponding switch port location."

Example: Port 17 has a device plugged in with this mac address. If you were looking for a device you could ping it, look at the arp table to get the mac then use the mac command to find the port.

Destination Address  Address Type  VLAN  Destination Port
-------------------  ------------  ----  --------------------
0000.856b.a529       Dynamic          1  FastEthernet0/17
2
  • Those are the MAC addresses of the devices connected through the interface. The question is asking about the MAC addresses of the interfaces themselves. Your answer gives the destination MAC addresses, but the question wants the source MAC addresses.
    – Ron Maupin
    Jul 6, 2017 at 15:50
  • I re-read your response and understand now. I appologize
    – Fixitrod
    Jul 7, 2017 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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