MAC Learning
Understanding MAC Learning
MAC learning is the process of obtaining the MAC addresses of all the nodes on a network.
When a node is first connected to an Ethernet LAN or VLAN, it has no information about the other nodes on the network. As data is sent through the network, data packets include a data frame listing their source and destination MAC addresses. The data frame is forwarded to a target port, which is connected to the second device. The MAC address is learned locally at the target port, which facilitates communications for frames that later enter the target port and contain addresses previously learned from a received frame.
By default, MAC learning is enabled on the QFX and NFX Series.
Disabling MAC Learning on Devices with ELS Support
By default, MAC learning is globally enabled on all nodes. This topic describes how to disable MAC learning, as well as how to reenable and verify that MAC learning has been enabled or disabled.
This task supports the Enhanced Layer 2 Software (ELS) configuration style. For ELS details, see Using the Enhanced Layer 2 Software CLI If your switch runs software that does not support ELS, see Disabling MAC Learning on QFX Switches.
Disabling dynamic MAC learning prevents a node from learning source and destination MAC addresses.
To disable MAC learning:
[edit vlans vlan-name switch-options interface interface-name] user@switch# set no-mac-learning
To enable MAC learning:
[edit vlans vlan-name switch-options interface interface-name] user@switch# delete no-mac-learning user@switch# deactivate no-mac-learning
To verify the status of MAC learning, view the Ethernet MAC learning statistics in operational mode.
user@switch> show ethernet-switching table Ethernet-switching table: 2 entries, 1 learned VLAN MAC address Type Age Interfaces default * Flood - All-members default 00:1f:12:39:90:80 Learn 29 xe-/0/0.0
Disabling MAC Learning on QFX Switches
By default, MAC learning is globally enabled on all nodes in a device. This topic describes how to disable MAC learning, as well as how to reenable and verify that MAC learning has been enabled or disabled.
Disabling dynamic MAC learning on the device prevents a node from learning source and destination MAC addresses.
This task uses Junos OS for QFX3500 and QFX3600 switches and does not support the Enhanced Layer 2 Software (ELS) configuration style. If your switch runs software that supports ELS, see Disabling MAC Learning on Devices with ELS Support.
To disable MAC learning on the QFX Series:
[edit ethernet-switching-options interfaces interface] user@switch# set no-mac-learning
To enable MAC learning on the QFX Series:
[edit ethernet-switching-options interfaces interface] user@switch# delete no-mac-learning user@switch# deactivate no-mac-learning
To verify the status of MAC learning on the QFX Series, view the Ethernet MAC learning statistics in operational mode.
user@switch> show ethernet-switching table Ethernet-switching table: 2 entries, 1 learned VLAN MAC address Type Age Interfaces default * Flood - All-members default 00:1f:12:39:90:80 Learn 29 xe-/0/0.0
Disabling MAC Learning in a VLAN on a QFX Switch
By default, MAC learning is enabled on a VLAN. This topic describes how to disable MAC learning in a VLAN, as well as how to reenable and verify that MAC learning has been enabled or disabled.
Disabling dynamic MAC learning in a VLAN on a QFX Series product prevents a node from learning source and destination MAC addresses.
To disable MAC learning in a VLAN:
[edit vlans vlan-name] user@switch# set no-mac-learning
To reenable MAC learning in a VLAN, use either of the following two commands:
[edit vlans vlan-name] user@switch# delete no-mac-learning user@switch# deactivate no-mac-learning
To verify the status of MAC learning on the QFX series:
user@switch> show ethernet-switching table
Disabling MAC Learning for a VLAN or Logical Interface
You can disable MAC learning for all logical interfaces in a specified VLAN, or for a specific logical interface in a VLAN. Disabling dynamic MAC learning prevents the specified interfaces from learning source MAC addresses.
To disable MAC learning for all logical interfaces in
a VLAN in a virtual switch, include the no-mac-learning
statement at the [edit vlans vlan-name switch-options]
hierarchy level:
[edit] vlans { vlan-name { domain-type bridge; interface interface-name; switch-options { no-mac-learning; } } }
To disable MAC learning for a specific logical interface
in a VLAN, include the no-mac-learning
statement at the [edit vlans vlan-name switch-options interface interface-name]
hierarchy level.
[edit] vlans { vlan-name { domain-type bridge; interface interface-name; switch-options { interface interface-name { no-mac-learning; } } } }
When you disable MAC learning, source MAC addresses are not dynamically learned, and any packets sent to these source addresses are flooded into the VLAN.
When you gather interfaces into a VLAN, the no-mac-learn-enable
statement at the [edit interfaces interface-name ether-options ethernet-switch-profile]
hierarchy level is
not supported. You must use the no-mac-learning
statement
at the [edit vlans vlan-name switch-options
interface interface-name]
hierarchy
level to disable MAC learning on an interface in a VLAN.
When MAC learning is disabled for a VPLS routing instance, traffic is not load balanced and only one of the equal-cost next hops is used.
Disabling MAC Learning for a Set of VLANs
You can disable MAC learning for a set of VLANs. Disabling dynamic MAC learning prevents the Layer 2 trunk port associated with the set of VLANs from learning source and destination MAC addresses. When you disable MAC learning, source MAC addresses are not dynamically learned, and any packets sent to these source addresses are flooded into the switch.
To disable MAC learning for a set of VLANs, include the no-mac-learning
statement at the [edit switch-options]
hierarchy level:
[edit switch-options] no-mac-learning;