Cisco Commands – Listing Interface Names and MAC Addresses on Cisco Device

ciscocisco-commandscisco-ios

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.

Best Answer

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

Related Topic