Configuring MAC Address Table

Configuring the MAC Address Table

The MAC address table contains address information that the device uses to forward traffic between ports. The address table lists the destination MAC address, the associated VLAN ID, and port number associated with the address and the type (static or dynamic). When a packet enters the device the device looks up the MAC address table for the destination MAC address and the VLAN ID of the packet. If the address is found the device forwards the packet to the specified ports. If the address is not found the device boradcasts the packet in the VLAN.

The system is able to learn MAC addresses. If the MAC address of a received packet does not exist in the MAC address table, the system will add the source MAC address, VLAN ID, and port number of the received packet as a new entry to the MAC address table.

You can also manually configure the MAC address entris. You can configure the MAC address table based on the actual network condition, that is, the administrator can add or modify static entries, permanent entries, blackhole entries, dynamic entries.

You can configure the MAC address aging function to remove the MAC address after a specified time. If a device does not send any packets for a certain period of time, the system deletes the MAC address entries associated with the device. MAC address aging can be used only on learned MAC addresses or dynamic MAC addresses.

How to Configure MAC Address Table

Configuring Aging Time for MAC Address Table

To configure the Aging Time for MAC Address Table, perform this procedure:

Procedure

  Command or Action Purpose
Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode. Enter your password if prompted.

Step 2

configure terminal

Example:

Device#configure terminal 

Enters global configuration mode.

Step 3

mac-address-table age-time { seconds| disable}

Example:

Device#mac-address-table age-time 120 

Assigns an aging time to the MAC address table, in seconds. The disbale keyword implies that the MAC address will not be aged.

Step 4

show mac-address-table age-time

Example:

Device#show mac-address-table age-time

Displays the Aging Time of the MAC address.

Adding MAC addresses manually to the MAC address table

The MAC address table is dynamically populated, but you can also add MAC addresses to the table manually. To add a MAC address to the MAC table manually, perform this procedure:

Procedure

  Command or Action Purpose
Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode. Enter your password if prompted.

Step 2

configure terminal

Example:

Device# configure terminal 

Enters global configuration mode.

Step 3

mac-address-table { static| permanent| dynamic} mac-address interface ethernet interface-number vlan vlan-id

Example:

Device(config)# mac address-table static 0050.3e8d.6400 vlan 3 interface ethernet 1/4

Adds a MAC address manually to the MAC address table.

Step 4

end

Example:

Device(config-if)# end

Returns to privileged EXEC mode.

Step 5

show mac-address-table { static| permanent| dynamic} blackhole vlan vlan-id interface ethernet port-number

Example:

Device# show mac address-table static 0050.3e8d.6400 vlan 3 interface ethernet 1/4

Displays the MAC address table.

Note 

Static MAC addresses are not aged. Permanent MAC addresses are aged, if the configuration is saved the entries will exist even after the device is powered down. Dynamic MAC addresses are aged.

Adding a Blackhole MAC Address

To prevent an untrusted user from using a MAC address to attack a device or a network, you can configure the MAC address of the untrusted user as a Blackhole MAC address. Any packets with the source or destination being the Blackhole MAC address are then dropped by the device. To configure a MAC address as a Blackhome MAC address, perform this procedure:

Procedure

  Command or Action Purpose
Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode. Enter your password if prompted.

Step 2

configure terminal

Example:

Device# configure terminal 

Enters global configuration mode.

Step 3

mac-address-table blackhole mac-address vlan vlan-id

Example:

Device(config)# mac-address-table blackhole 0005-0005-0005 vlan 1
Adds the MAC address as a blackhole MAC address.

Disabling MAC Address Learning

You can enable or diable dynamic MAC Address Learning. Dynamic MAC address learning is enabled by default. To disable dynamic MAC Address Learning, perform this procedure:


Note

When MAC Address Learning is disabled under global configuration mode, all the ports cannot learn MAC addresses dynamically. If you wish to disable MAC Address Learning only on some ports, enable MAC address learning under global configuration mode and disable MAC address learning on the specific ports.


Procedure

  Command or Action Purpose
Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode. Enter your password if prompted.

Step 2

configure terminal

Example:

Device# configure terminal 

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet 1/4

Enters interface configuration mode.

Step 4

no mac-address-table learning

Example:

Device(config-if)# no mac-address-learning

Disables dynamic MAC Address Learning.

Step 5

end

Example:

Device(config-if)# end

Returns to privileged EXEC mode.

Step 6

show mac-address learning interface interface-number

Example:

Device# show mac-address learning interface ethernet 1/4

Quantity Limitation on MAC Address Table

You can configure the maximum number of MAC addresses that will be learnt by the MAC Address Table on a port. By default, the number of MAC addresses that are dynamically learnt by the MAC Address Table are unlimited. To configure a maximum number for the dynamic MAC addresses learnt by the table, perform this procedure:

Procedure

  Command or Action Purpose
Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode. Enter your password if prompted.

Step 2

configure terminal

Example:

Device# configure terminal 

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet 1/4

Enters interface configuration mode.

Step 4

mac-address-table max-mac-count integer

Example:

Device(config)# mac-address-table max-mac-count 500

Enables a limit on the number of dynamically learnt MAC addresses added to the table. It is effective on the specified port.

Step 5

end

Example:

Device(config)# end

Returns to privileged EXEC mode.

Step 6

show mac-address max-mac-count interface interface-number

Example:

Device# show mac-address max-mac-count interface ethernet 1/4