Sub topic 15
Static entries and port security
This chapter assumes you know how a switch learns source addresses, ages entries, and floods unknown destinations. It also assumes you know that the MAC address table has a finite size. Here you will see how to take control of the table with static entries and how port security limits what a port may learn.
Dynamic and static entries
Every entry you have seen so far is dynamic. The switch learns it from a source address and removes it after the aging time. A static entry is one you configure by hand. It has these properties:
- It never ages out.
- It is not overwritten when the same MAC address appears on another port.
- It is lost on reload unless you save the configuration.
Static entries suit devices that must always be reached on a known port, such as a server or a router interface. They also stop a host on another port from taking over that address by spoofing it. The cost is upkeep. If you move the device and forget to update the entry, frames for it keep going to the old port.
Switch(config)# mac address-table static 0011.2233.4455 vlan 1 interface Gi0/1
Switch# show mac address-table staticOn a Linux bridge, a static entry is a permanent forwarding database entry:
bridge fdb add 00:11:22:33:44:55 dev eth1 master staticPort security
Port security limits which source MAC addresses a switch accepts on an access port. It protects against MAC flooding, where an attacker sends frames with many fake source addresses to fill the table. Once the table is full, the switch cannot learn new addresses, and unknown destinations are flooded out of every port. That lets the attacker see traffic meant for others.
Port security enforces a maximum number of addresses per port. Those addresses can be:
- Static: you configure them.
- Dynamic: the switch learns them, up to the maximum, and forgets them on reload.
- Sticky: the switch learns them and writes them into the running configuration, so they survive a save and reload.
Switch(config)# interface Gi0/2
Switch(config-if)# switchport mode access
Switch(config-if)# switchport port-security
Switch(config-if)# switchport port-security maximum 2
Switch(config-if)# switchport port-security mac-address sticky
Switch(config-if)# switchport port-security violation restrictA violation happens when a new address appears after the maximum is reached, or when an address secured on one port shows up on another. The violation mode decides the response.
| Mode | Drops violating frames | Logs the event | Port state |
|---|---|---|---|
| protect | Yes | No | Stays up |
| restrict | Yes | Yes | Stays up |
| shutdown | Yes | Yes | Goes to err-disabled |
Shutdown is the usual default. An err-disabled port stays down until an administrator recovers it, either by hand or through an automatic recovery timer.
Common errors
- Setting the maximum to 1 on a port that connects an IP phone and a PC. Both send frames, so the second device causes a violation.
- Using port security on a trunk or uplink. Many addresses sit behind those ports, so the limit is quickly exceeded.
- Moving a PC to another secured port with sticky addresses still configured. The address is secured on the old port, so a violation occurs.
- Forgetting to save the configuration, so sticky addresses are lost on reload.
Exercise
A port has port security enabled with a maximum of 1, sticky learning, and violation mode shutdown. A user unplugs their laptop and plugs in a different one. What happens, and what must the administrator do?
Show answer
The new laptop's source MAC address differs from the sticky address and the maximum is already reached, so a violation occurs. In shutdown mode the port goes to err-disabled and stops forwarding. The administrator must remove or clear the old sticky entry if the change is legitimate, then bring the port back up, either manually by shutting and re-enabling it or through error-disable recovery.