Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Ethernet Switching User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

MAC Learning

date_range 20-Dec-24

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.

Note:

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:

    content_copy zoom_out_map
    [edit vlans vlan-name switch-options interface interface-name]
    user@switch# set no-mac-learning
  • To enable MAC learning:

    content_copy zoom_out_map
    [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.

    content_copy zoom_out_map
    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.

Note:

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:

    content_copy zoom_out_map
    [edit ethernet-switching-options interfaces interface]
    user@switch# set no-mac-learning
  • To enable MAC learning on the QFX Series:

    content_copy zoom_out_map
    [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.

    content_copy zoom_out_map
    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:

    content_copy zoom_out_map
    [edit vlans vlan-name]
    user@switch# set no-mac-learning
  • To reenable MAC learning in a VLAN, use either of the following two commands:

    content_copy zoom_out_map
    [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:

    content_copy zoom_out_map
    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:

content_copy zoom_out_map
[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.

content_copy zoom_out_map
[edit]
vlans {
    vlan-name {
        domain-type bridge;
        interface interface-name;
        switch-options {
            interface interface-name {
                no-mac-learning;
            }
        }
    }
}
Note:

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.

Note:

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.

Note:

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:

content_copy zoom_out_map
[edit switch-options]
no-mac-learning;
footer-navigation