Static MAC Address Table Configuration on Cisco Switches

Aisyah Aldina

Cartoon padlock attached to a network cable plug for a Cisco static MAC address table guide

In this lab we build a static MAC address table on Cisco switches in Cisco Packet Tracer. A MAC address is the hardware address of a network card, written as 12 hex digits such as 0001.42d6.d6ed. A switch keeps a list of which MAC lives on which port, called the MAC address table, so it can send each frame only where it needs to go.

Normally the switch fills that table by itself (dynamic entries). The catch is that dynamic entries disappear when a device stays quiet, and another device can claim the same MAC on a different port. A static entry lets us pin a server’s MAC to one port ourselves. Most tutorials show one switch and two PCs. Here I use three switches, two VLANs, and trunk links, then test three cases: pinning a server, moving that server to another port, and locking out a guest laptop. Everything was done in Cisco Packet Tracer 8.2.1.

Download the Packet Tracer lab file
Opens in Cisco Packet Tracer 8.2.1 or newer · 3 switches 2960, 1 server, 1 printer, 3 PCs, 1 laptop · VLAN 10/20, trunks, and static MAC entries already set
Download .pkt

Lab Topology and Devices

The lab models a two-floor office. The CORE switch sits in the server room and connects to the LANTAI1 and LANTAI2 switches over trunk links (lantai is Indonesian for floor). A trunk is a switch-to-switch link that carries more than one VLAN at the same time.

There are two VLANs. VLAN 10 STAFF holds the server, the printer, PC1, and the guest laptop. VLAN 20 FINANCE holds PC0 and PC2. I used two VLANs on purpose, because a static MAC entry always belongs to a single VLAN and people forget that.

CORE on top, LANTAI1 on the left, LANTAI2 on the right

Three 2960 switch topology CORE, LANTAI1, LANTAI2 with a server, printer, PCs, and a laptop in Cisco Packet Tracer

Dashed lines are trunk cables and solid lines go to end devices.

Device            Switch / Port        VLAN   IP               MAC
Server0           LANTAI1 Fa0/1        10     192.168.10.10    0001.42d6.d6ed
Printer0          LANTAI1 Fa0/2        10     192.168.10.20    0090.0c07.a398
PC0               LANTAI1 Fa0/3        20     192.168.20.11    -
PC1               LANTAI2 Fa0/1        10     192.168.10.12    -
Laptop0 (guest)   LANTAI2 Fa0/2        10     192.168.10.50    0090.2b5d.d3c3
PC2               LANTAI2 Fa0/3        20     192.168.20.12    -

Trunks
CORE (Switch0) Gig0/1  <->  LANTAI1 (Switch1) Gig0/1
CORE (Switch0) Gig0/2  <->  LANTAI2 (Switch2) Gig0/1
All IPs use mask 255.255.255.0 with no gateway (there is no router).

Your MAC addresses will be different, because Packet Tracer generates a random MAC for every new device. If you open the .pkt file from this article, the MACs match the table.

Crossover cable for the switch-to-switch trunks

Zoomed crossover trunk cable between CORE Gig0/1 and LANTAI1 Gig0/1 marked with a red box

The switches are linked with Copper Cross-Over on their GigabitEthernet ports. The server, printer, PCs, and laptop use Copper Straight-Through to FastEthernet ports. A 2960 can adapt to the wrong cable type on its own, but using the right one is a good habit for real hardware.

Setting IP Addresses on the Server, Printer, PCs, and Laptop

Every device sits on a local network with no router, so an IP and subnet mask are enough. The gateway can stay empty.

The server, PCs, and laptop are set from the Desktop tab. The printer is different because it has no Desktop tab, so its IP goes in the Config tab.

Open Server0

Server0 in the static MAC topology circled in red

Click Server0 at the bottom left.

Server0 IP

Server0 IP Configuration static 192.168.10.10 mask 255.255.255.0

Desktop tab, IP Configuration, Static, then type 192.168.10.10. Click the Subnet Mask box and 255.255.255.0 fills in by itself.

Open Printer0

Printer0 under LANTAI1 circled in red

Click Printer0 under the LANTAI1 switch.

Printer0 IP from the Config tab

Printer0 Config tab FastEthernet0 with MAC 0090.0C07.A398 and IP 192.168.10.20

Open the Config tab and click FastEthernet0 under INTERFACE. Enter IPv4 Address 192.168.10.20 and Subnet Mask 255.255.255.0. The printer’s MAC Address is shown on this page too.

Open PC1

PC1 under LANTAI2 circled in red

Click PC1 under the LANTAI2 switch.

PC1 IP

PC1 IP Configuration static 192.168.10.12

Same as the server, enter 192.168.10.12. Repeat for PC0 (192.168.20.11), PC2 (192.168.20.12), and Laptop0 (192.168.10.50).

Creating the VLANs and Trunks on All Three Switches

A static MAC entry needs a VLAN number, so the VLANs must exist on every switch first. I gave them the same names on all three switches to keep the output easy to read.

Every switch-to-switch cable becomes a trunk. Without trunks, VLAN 10 on the first floor and VLAN 10 on the second floor would never meet.

Open the CORE switch

CORE switch at the top of the topology circled in red

Click Switch0 at the top, then the CLI tab. Answer no if the initial configuration dialog appears.

enable
configure terminal
hostname CORE
vlan 10
 name STAFF
vlan 20
 name FINANCE
exit
interface range g0/1 - 2
 switchport mode trunk
end
write memory
show interfaces trunk

Trunks up on Gig0/1 and Gig0/2

show interfaces trunk on CORE with Gig0/1 and Gig0/2 trunking 802.1q

show interfaces trunk lists Gig0/1 and Gig0/2 as trunking with 802.1q encapsulation, and VLANs 1, 10, and 20 active on both.

Open the LANTAI1 switch

LANTAI1 switch on the left circled in red

Click Switch1 on the left, then the CLI tab.

enable
configure terminal
hostname LANTAI1
vlan 10
 name STAFF
vlan 20
 name FINANCE
exit
interface range fa0/1 - 2
 switchport mode access
 switchport access vlan 10
interface fa0/3
 switchport mode access
 switchport access vlan 20
interface fa0/4
 switchport mode access
 switchport access vlan 10
interface g0/1
 switchport mode trunk
end
write memory
show vlan brief

Fa0/4 goes into VLAN 10 even though nothing is plugged in yet. We use it later when the server moves.

VLANs on LANTAI1

show vlan brief on LANTAI1 with VLAN 10 STAFF on Fa0/1 Fa0/2 and VLAN 20 FINANCE on Fa0/3

Fa0/1 and Fa0/2 are in VLAN 10 STAFF, and Fa0/3 is in VLAN 20 FINANCE.

Open the LANTAI2 switch

LANTAI2 switch on the right circled in red

Click Switch2 on the right, then the CLI tab. The commands are the same as LANTAI1, except the hostname is LANTAI2 and there is no Fa0/4 section.

VLANs on LANTAI2

show vlan brief on LANTAI2 with VLAN 10 and VLAN 20

show vlan brief on LANTAI2 matches: Fa0/1 and Fa0/2 in VLAN 10, Fa0/3 in VLAN 20.

Looking at the Dynamic MAC Address Table

Before adding static entries, it helps to see how the switch learns on its own. Every time a frame comes in on a port, the switch writes down the sender’s MAC and that port.

To create some traffic, PC1 on the second floor pings the server on the first floor. The frames travel through LANTAI2, CORE, and then LANTAI1.

PC1 pings the server across two trunks

PC1 pinging 192.168.10.10 across two trunks with 0% loss

From PC1’s Command Prompt:

ping 192.168.10.10

Four replies, 0% loss. The trunks and VLAN 10 work across both floors.

The table a little later

show mac address-table on LANTAI1 with only the CORE MAC as DYNAMIC on Gig0/1

A short while after the ping I opened LANTAI1 and ran show mac address-table. The server and PC1 were already gone. The only entry left was the CORE switch’s MAC on Gig0/1, type DYNAMIC.

That is how dynamic entries behave. When a device goes quiet, its entry is aged out. On real switches the default is 300 seconds. show mac address-table aging-time is not available in Packet Tracer, so I could not display the timer here.

Finding the Server and Laptop MAC Addresses

The static command needs the full MAC. The safest way to get it is from the device itself, not from a switch table that may already be empty.

Cisco writes MAC addresses as three groups of four hex digits separated by dots, for example 0001.42d6.d6ed. Upper or lower case does not matter.

Server0 MAC in the Config tab

Server0 Config tab FastEthernet0 with MAC Address 0001.42D6.D6ED marked

Open Server0, go to the Config tab, and click FastEthernet0. The MAC Address is 0001.42D6.D6ED.

Laptop0 MAC

Laptop0 Config tab FastEthernet0 with MAC Address 0090.2B5D.D3C3 marked

Same steps on Laptop0 show 0090.2B5D.D3C3. We treat this laptop as a guest device that should not get onto the network.

Static MAC for the Server on Three Switches

The command format is mac address-table static MAC vlan NUMBER interface PORT. In plain words: in this VLAN, this MAC is always on this port.

The entry goes on all three switches, and each one points toward the server from where it stands. LANTAI1 points at Fa0/1 because the server is plugged in there. CORE points at Gig0/1 because the server is somewhere behind LANTAI1. LANTAI2 points at Gig0/1 because every path to the server goes through CORE.

LANTAI1: the server is on Fa0/1

mac address-table static 0001.42d6.d6ed vlan 10 interface fa0/1 and the STATIC Fa0/1 result
configure terminal
mac address-table static 0001.42d6.d6ed vlan 10 interface fa0/1
end
write memory
show mac address-table static

The new entry shows up as type STATIC on Fa0/1. It stays there even if the server says nothing for days.

CORE: the server is toward Gig0/1

show mac address-table static on CORE with the server MAC on Gig0/1
configure terminal
mac address-table static 0001.42d6.d6ed vlan 10 interface g0/1
end
write memory

LANTAI2: the server is toward trunk Gig0/1

LANTAI2 with two static entries: server on Gig0/1 and guest laptop on Fa0/24
configure terminal
mac address-table static 0001.42d6.d6ed vlan 10 interface g0/1
end
write memory

This screenshot already includes the guest laptop entry covered in the next section.

PC1 pings the server after the static entries

PC1 pinging the server with 0% loss after the static MAC entries

PC1 pings the server again and still gets 0% loss. A static entry changes nothing while the server stays on the right port.

Locking Out the Guest Laptop with a Static MAC

Real Catalyst IOS has mac address-table static MAC vlan NUMBER drop. Every frame to or from that MAC is thrown away, so the device cannot talk to anyone.

I tried drop in Packet Tracer and it was rejected. So I used a workaround that you can still practise: pin the laptop’s MAC to an empty port.

drop is not supported in Packet Tracer

mac address-table static drop rejected with Invalid input in Packet Tracer
mac address-table static 0090.2b5d.d3c3 vlan 10 drop

Packet Tracer answers % Invalid input detected right at the word drop. The same command works on a real Catalyst switch.

My experience: Workaround for drop: point the laptop’s MAC at a port nobody uses. I picked Fa0/24 on LANTAI2. The switch then sends every reply meant for the laptop out of the empty Fa0/24, so the laptop never hears back from anyone.

configure terminal
mac address-table static 0090.2b5d.d3c3 vlan 10 interface fa0/24
end
write memory
show mac address-table static

LANTAI2 now has two static entries: the server on Gig0/1 and the laptop on Fa0/24.

Open Laptop0

Guest Laptop0 under LANTAI2 circled in red

Click Laptop0 under LANTAI2, open Desktop, then Command Prompt.

The guest laptop cannot reach the server

Laptop0 pinging the server with 100% loss after its MAC was pointed at Fa0/24
ping 192.168.10.10

Four Request timed out, 100% loss. The laptop’s ping does reach the server, but the server’s reply is sent to Fa0/24. Compare that with PC1 on the same switch, which still pings fine.

The Hard Test: Moving the Server to Another Port

This happens in real offices all the time. Someone moves the server cable to a different port without knowing there is a static entry. A normal switch would relearn the MAC within seconds, but a static entry does not move by itself.

To try it, I deleted the Server0 cable from LANTAI1 Fa0/1 and plugged the server into Fa0/4 instead.

The server is now on Fa0/4

Server0 cable now on LANTAI1 Fa0/4 marked with a red box

Use the Delete tool (the X icon) on the toolbar, click the server cable, then draw a new straight-through cable from Server0 FastEthernet0 to LANTAI1 FastEthernet0/4. Wait until the port triangles turn green.

PC1 can no longer ping the server

PC1 pinging the server with 100% loss because the static entry is still on Fa0/1
ping 192.168.10.10

100% loss, even though the server is powered on and cabled. LANTAI1 still believes the server lives on Fa0/1, so every frame for the server goes out of a port that is now empty.

Move the static entry to Fa0/4

Server static entry moved to Fa0/4 while the no command answers Address not found
configure terminal
no mac address-table static 0001.42d6.d6ed vlan 10 interface fa0/1
mac address-table static 0001.42d6.d6ed vlan 10 interface fa0/4
end
write memory
show mac address-table static

In Packet Tracer the no command replied Address not found, but the new Fa0/4 entry replaced the old one right away. In the end there is only one static entry for the server, on Fa0/4.

Proof in the running-config

show running-config include mac with mac-address-table static on FastEthernet0/4
show running-config | include mac

There is a single line for the server, now on FastEthernet0/4. Packet Tracer stores it in the older mac-address-table form with a hyphen. Both spellings mean the same thing.

The ping is back

PC1 pinging the server with 0% loss again after the entry was fixed

PC1 pings the server again and gets 0% loss. The lesson: whenever you move a device that has a static MAC entry, the entry on the switch has to move too.

When to Use a Static MAC and When Not To

A static MAC suits devices that rarely move but matter a lot, such as servers, network printers, CCTV recorders, or the gateway router. The switch never has to relearn them, and no other device can claim that MAC on another port.

For staff PCs and laptops it is more trouble than it is worth, because people change desks. For those, port security is a better fit since it can learn MACs automatically with sticky.

Need                                         Choice
Server, printer, NVR that never moves        Static MAC
Limit the number of devices per port         Port security
Block one MAC (real switch)                  static ... drop
Block one MAC in Packet Tracer               static to an empty port

Common Problems and Fixes

Mistakes with static MAC entries usually produce no error message. The switch accepts the command, and then traffic simply stops.

So make a habit of running show mac address-table static after every change and checking each port against the topology.

A device becomes unreachable after its cable is moved

The static entry still points at the old port. Remove the old entry and create a new one on the correct port.

The command fails with Invalid input

The MAC is in the wrong format (colons or hyphens), or you used the drop option in Packet Tracer. Use the 0001.42d6.d6ed format.

The static entry has no effect

The VLAN number does not match the device’s port VLAN. An entry for vlan 20 does nothing for a device in VLAN 10.

Devices on the other floor cannot ping

The entry on CORE or on the other floor switch points at the wrong port. Each switch points toward the device from its own position.

The server MAC is now pinned on three switches, the guest laptop is locked out, and we have seen what happens when a server moves without updating the entry. If you want a refresher on VLANs and trunks, see VLAN trunk between two switches. A three switch topology like this is also a good place to try EtherChannel mode on and PAgP, so the links between switches have a backup. If something breaks while you follow along, leave a comment below.

Leave a Comment