01-04-2017 10:02 AM - edited 03-08-2019 08:47 AM
Does anyone know of a way to dump all connected mac addresses connected to every port on a Cisco switch(3850s)?
What would be ideal would be something like the 'show mac address-table interface' command, but for an interface range rather than a specific interface:
This is the type of output I'm looking for, with each mac address listed for the port in question:
switchxxx#show mac address-table interface g3/0/11
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
xx2 28f1.xxxx.xxxx DYNAMIC Gi3/0/11
xx2 e089.xxxx.xxxx DYNAMIC Gi3/0/11
xx3 e089.xxxx.xxxx DYNAMIC Gi3/0/11
Total Mac Addresses for this criterion: 3
switchxxx#
I'm thinking I could script it, but curious if there's an easier way.
Thanks,
Jon
Solved! Go to Solution.
01-04-2017 12:17 PM
If you are good at regular expression you probably could figure something out. I'm not, but played with it a bit and if you use the pipe and designate the proper output modifiers you can get some range functionality:
Provides the output for ports G1/0/10 thru 19:
sh mac address-table | include Gi1/0/([1][0-9])
Provides the outputs for G1/0/20 thru 39:
sh mac address-table | include Gi1/0/([2-3][0-9])
Hope this helpful.
01-04-2017 12:17 PM
If you are good at regular expression you probably could figure something out. I'm not, but played with it a bit and if you use the pipe and designate the proper output modifiers you can get some range functionality:
Provides the output for ports G1/0/10 thru 19:
sh mac address-table | include Gi1/0/([1][0-9])
Provides the outputs for G1/0/20 thru 39:
sh mac address-table | include Gi1/0/([2-3][0-9])
Hope this helpful.
05-21-2019 06:31 AM
I would like to find the correct syntax for all ports on switch 1-48...Tried several different ways but always seem to start at 1/0/10...Please help...
05-21-2019 06:39 AM
Hello Zig,
for first 9 ports you need a modified version
sh mac address-table | include Gi1/0/([1][0-9])
becomes
sh mac address-table | include Gi1/0/([1-9])
Hope to help
Giuseppe
05-21-2019 11:52 AM
Great, exactly what I needed, thanks...
07-20-2020 01:21 PM
@Giuseppe Larosa wrote:Hello Zig,
for first 9 ports you need a modified version
sh mac address-table | include Gi1/0/([1][0-9])
becomes
sh mac address-table | include Gi1/0/([1-9])
Hope to help
Giuseppe
When I run this specific command exactly as you have typed it Giuseppe, I get the MAC associated with every port in the stack.
The switches I am running this on are chassis, so if the supervisory module is included then I get every MAC the switch can see!
On the chassis here the supervisory modules are blades 3 and 4; so if I alter your command to this:
sh mac address-table | inc ([1-2])/0/[(1-9]) and then run the same command but with ([5-9)]/0/([1-9]), I get everything I need.
Thank you very much for the information!
01-04-2017 12:55 PM
Oh that's cool! I did not know you could do that.
Very helpful, thanks!
01-04-2017 04:19 PM
That's great. Glad it helped and thanks for the rating.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide