Skip to main content
Jeremy5385
Visitor III
December 5, 2025
Question

Easily Identify FortiSwitch port searching by MAC (FortiLink CLI)

  • December 5, 2025
  • 4 replies
  • 958 views

I’m using Fortilink to manage switches from the Fortigate.  When searching to find the port for a device MAC I can dump the mac table using this command:

 

# diag switch-controller switch-info mac-table

 

This gives me pages and pages since I have 25 FortiSwitches on this system.  When I use grep and add the MAC, there can be one line for every switch that has this entry in its table.  I can tell from the output below that the device is on Port43 but no good way to tell which FortiSwitch in Foritlink.

 

# diag switch-controller switch-info mac-table | grep 23:27

MAC: fc:0f:e7:17:23:27  VLAN: 249 Trunk: _FlInK1_ICL0_(trunk-id 0)

MAC: fc:0f:e7:17:23:27  VLAN: 249 Trunk: 8EPTF24001548-0(trunk-id 11)

MAC: fc:0f:e7:17:23:27  VLAN: 249 Trunk: E24TF24002765-0(trunk-id 1)

MAC: fc:0f:e7:17:23:27  VLAN: 249 Trunk: E24TF24002765-0(trunk-id 1)

MAC: fc:0f:e7:17:23:27  VLAN: 249 Trunk: _FlInK1_MLAG0_(trunk-id 0)

MAC: fc:0f:e7:17:23:27  VLAN: 249 Port: port43(port-id 43)

MAC: fc:0f:e7:17:23:27  VLAN: 249 Trunk: 8EPTF24001548-0(trunk-id 0)

 

It would be nice if every line in the dump had the FortiSwitch name at the beginning, but it doesn’t.  Anyone found a good way to get this information in the CLI?  I’ve tried using the -f switch with grep but that doesn’t work.

4 replies

AEK
SuperUser
SuperUser
December 6, 2025

Since FOS' grep command is not as rich as Linux', as a workaround I'd copy the whole text to my text editor and search for the MAC.

A dumb workaround but is better than nothing.

AEK
ebilcari
Staff
Staff
December 8, 2025

You can use the FGT UI, it can be checked in Device inventory, filter by Address:

ports.png

 

or similar in FortiSwitch Clients output and filter by Device.

 

I tried from the CLI and ended up with a complex output that contains this information scattered throughout the lines. :)

# diagnose user-device-store device memory list | grep 80:5xxxx:6f:39 -A10

Emirjon
Jeremy5385
Visitor III
December 11, 2025

The "diag user-device-store ..." is really clunky and hard with having to vary the -A syntax depending on the device return.  The result is there none-the-less.

I'm guessing Device Inventory is now Assets & Identities > Assets in 7.6.  In there, I was able to add the FortiSwitch and Port columns to see the data.  This seems to be the easiest method.  Still wish the CLI had an easy one-liner return.  Thanks for the UI find.

 

 

AEK
SuperUser
SuperUser
December 11, 2025

I believe SNMP can help as well. There must be some OID to list the MAC addresses.

You can run snmpwalk from a Linux host and use grep, awk, and other cool text filtering commands.

AEK
Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Fortinet Flag the Hack. Wednesday, August 26, 9:00 AM - 5:00 PM ET, COSM, Atlanta, GA.