Sub topic 11
Reading the table on a Cisco-style switch and a Linux bridge
What you need to know first
This chapter assumes you already know three things:
- A MAC address identifies a network interface at layer 2, and an IP address identifies a host at layer 3.
- An Ethernet frame carries a destination MAC, a source MAC and an EtherType.
- A switch learns source addresses on the ingress port, then forwards, floods or filters based on the destination address.
The earlier chapters explained how the table is built. This chapter shows how to read it on two real systems, so you can check what a switch has learned and why it forwarded a frame the way it did.
What every table entry contains
Every platform shows the same core facts about each entry:
| Field | Meaning |
|---|---|
| MAC address | The source address that was learned |
| VLAN | The VLAN in which the address was learned (the table is per VLAN) |
| Port | The port on which the address was last seen |
| Type | Dynamic (learned, subject to aging) or static (configured, never aged) |
| Age | Time since the entry was last refreshed (not always displayed) |
The exact column names and the address format differ between vendors. The meaning is the same.
Reading the table on a Cisco-style switch
On Cisco IOS-style switches, the command is show mac address-table. Older software releases used show mac-address-table. The output looks like this:
Switch# show mac address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0011.2233.4455 DYNAMIC Gi0/1
1 0011.2233.4466 DYNAMIC Gi0/2
Total Mac Addresses for this criterion: 2
Switch# show mac address-table aging-timeRead each row from left to right:
- Vlan is the VLAN in which the address was learned. The same MAC address can appear in two VLANs, with a different row for each.
- Mac Address uses Cisco's dotted format: three groups of four hex digits. The address
0011.2233.4455is the same as00:11:22:33:44:55. - Type is
DYNAMICfor an address learned from traffic andSTATICfor one that was configured by hand. Dynamic entries age out. Static entries do not. - Ports is the port out of which frames for this address are sent. For a host-facing port this is a single access port. For an uplink it is a trunk or port-channel.
The second command in the example, show mac address-table aging-time, reports how long an idle dynamic entry is kept. The usual default is 300 seconds. The switch prints this value per VLAN.
Useful filters
You rarely want the full table. IOS-style switches let you narrow it:
show mac address-table address 0011.2233.4455finds one host and tells you which port it is behind.show mac address-table interface Gi0/1lists everything learned on one port.show mac address-table vlan 10lists one VLAN.show mac address-table dynamicorstaticfilters by type.show mac address-table countshows how many entries are in use against the platform's capacity.
The count command connects to the table-capacity chapter. A count close to the maximum, or a sudden jump, suggests a loop or a MAC flooding attack.
Reading the table on a Linux bridge
A Linux bridge is a software switch. It keeps the same kind of table and calls it the forwarding database, or FDB. You read it with the bridge command from the iproute2 package:
bridge fdb show br br0A typical output looks like this:
33:33:00:00:00:01 dev eth1 self permanent
52:54:00:aa:bb:01 dev eth1 master br0
52:54:00:aa:bb:02 dev eth2 master br0
02:42:ac:11:00:02 dev veth3 vlan 1 master br0 permanentThe addresses and device names above are illustrative. Your output will differ. Each line gives a MAC address, the port in dev, and flags after it.
devnames the bridge port where the address was learned, such aseth1orveth3.vlanappears when VLAN filtering is enabled on the bridge.master br0means the entry belongs to the bridgebr0.selfmeans the entry is stored on the port device itself, not in the bridge. You see this for addresses that the device uses for its own filtering.permanentmarks a static entry. The kernel never ages it.staticandextern_learnare other flags you may meet. An entry markedextern_learnwas added by an outside program, such as a routing daemon, and not by the bridge's own learning.
If an entry has no permanent or static flag, it was learned dynamically and will age out. Newer versions of bridge can show how recently an entry was used if you add the -s option, which prints used and updated times.
Useful filters on Linux
# Only entries for one bridge port
bridge fdb show br br0 dev eth1
# Only entries in one VLAN (needs VLAN filtering enabled)
bridge fdb show br br0 vlan 10
# Entries with statistics
bridge -s fdb show br br0You can also find the bridge's aging time. It is stored in centiseconds in sysfs, so the default of 300 seconds appears as 30000:
cat /sys/class/net/br0/bridge/ageing_timeNotice the spelling. Linux uses "ageing" in these file names, and Cisco uses "aging".
Comparing the two outputs
| Question | Cisco-style switch | Linux bridge |
|---|---|---|
| Show the whole table | `show mac address-table` | `bridge fdb show br br0` |
| MAC format | `0011.2233.4455` | `00:11:22:33:44:55` |
| Port column | `Ports` | `dev` |
| Static entry marker | `STATIC` | `permanent` or `static` |
| Dynamic entry marker | `DYNAMIC` | no flag |
| Aging time | `show mac address-table aging-time` | `/sys/class/net/br0/bridge/ageing_time` |
| VLAN | `Vlan` column | `vlan` field, if filtering is on |
Using the table to answer real questions
The table is most useful when you have a concrete question. Here are the common ones.
Where is this host plugged in?
Find the host's MAC address, for example from ip link on the host or from an ARP entry. Then look it up in the switch table. The port shown is the port where the switch last saw frames from that address. If the port is a trunk or an uplink, the host is behind another switch. Log in to that switch and repeat the lookup until you reach an access port.
Why did a frame get flooded?
If a destination MAC is missing from the table, the switch floods frames to it. Check whether the address is present in the right VLAN. Common reasons for a missing entry:
- The destination has never sent a frame, so it was never learned.
- The entry aged out because the host was idle for longer than the aging time.
- The traffic is asymmetric. The reply path goes through a different switch, so this switch never sees the destination as a source.
- The VLAN differs. The address is learned in VLAN 20, but the frame is in VLAN 10.
Is a host moving between ports?
Run the table command twice, a few seconds apart, and compare the port for one address. If the port keeps changing, you have a host move or a layer 2 loop. Cisco-style switches also log MACFLAP messages when an address moves between ports repeatedly. The Linux bridge does not log flaps by default, so you compare outputs yourself.
Is the table growing out of control?
On a Cisco-style switch, use show mac address-table count. On Linux, count the lines:
bridge fdb show br br0 | wc -lA very large table on an access switch is unusual and deserves investigation.
Common mistakes when reading the table
- Expecting the table to be a full list of hosts. It only holds hosts that sent frames recently. An idle host that is plugged in and healthy may not appear.
- Forgetting the VLAN. You can see the right MAC address on the right port and still miss that it belongs to a different VLAN than the traffic you are debugging.
- Mixing up address formats.
0011.2233.4455and00:11:22:33:44:55match. Searching for the wrong format finds nothing. - Treating a trunk port as the host's location. Many MAC addresses can sit behind one uplink. The port tells you the direction to the host, not its final port.
- Reading
selfandpermanententries as learned hosts. On Linux, these are addresses of the bridge and its ports. They are not other machines.
Exercises
Exercise
On a Cisco-style switch, the output of show mac address-table contains the row 10 0011.2233.4455 DYNAMIC Gi0/24. Gi0/24 is a trunk to another switch. Where is the host with that address, and what should you do next to find its physical port?
Show answer
The host is not on Gi0/24 itself. The row means the switch last saw frames from that address arriving on the trunk, so the host is somewhere behind the neighbouring switch, in VLAN 10. Log in to the neighbouring switch and look up the same MAC address in VLAN 10. Repeat on each switch until the port shown is an access port, which is where the host is plugged in.
Exercise
A Linux bridge shows 52:54:00:aa:bb:01 dev eth1 master br0 permanent and 52:54:00:aa:bb:02 dev eth2 master br0. Which entry will disappear if the host stays silent for longer than the aging time, and why?
Show answer
The second entry, for 52:54:00:aa:bb:02 on eth2. It has no permanent flag, so it was learned dynamically and is subject to aging. The first entry is marked permanent, so the kernel never ages it out.
Exercise
You run show mac address-table address 0011.2233.4455 and get no output, although you know the host is online and the cable is connected. Give two possible reasons.
Show answer
Any two of the following. The host has not sent a frame since the entry aged out, so the switch has nothing to show. The host is quiet because it is only receiving traffic. You are looking at a switch that is not on the path of the host's outgoing frames. The address was learned under a different VLAN than the one you filtered on. Sending a ping from the host usually makes the entry appear again.