Configuring MAC Limiting
Configuring MAC Limiting (ELS)
This topic describes the different ways of configuring a limitation on MAC addresses in packets that are received and forwarded by the device.
The tasks presented in this section uses Junos OS for EX Series switches, QFX3500 and QFX3600 switches, and PTX Series routers that support the Enhanced Layer 2 Software (ELS) configuration style. See Using the Enhanced Layer 2 Software CLI for more information about ELS configurations.
-
For information on configuring an interface to automatically recover from a shutdown caused by MAC limiting, see Configuring Autorecovery for Port Security Events. If you do not configure the device for autorecovery from the disabled condition, you can bring up the disabled interfaces by running the
clear ethernet-switching recovery-timeout
command.
The different ways of setting a MAC limit are described in the following sections:
- Limiting the Number of MAC Addresses Learned by an Interface
- Limiting the Number of MAC Addresses Learned by a VLAN
- Limiting the Number of MAC Addresses Learned by an Interface in a VLAN
Limiting the Number of MAC Addresses Learned by an Interface
On PTX Series routers, you can limit the number of MAC addresses learned by an interface only.
To secure a port, you can set the maximum number of MAC addresses that can be learned by an interface.
[edit switch-options] user@switch# set interface interface-name interface-mac-limit limit packet-action action
[edit routing-instances] user@switch# set routing-instance-name switch-options interface interface-name interface-mac-limit limit
[edit switch-options] user@switch# set interface-mac-limit limit
[edit routing-instances] user@switch# set routing-instance-name switch-options interface-mac-limit limit
After you set a new MAC limit for the interface, the system clears existing entries in the MAC address forwarding table associated with the interface.
Limiting the Number of MAC Addresses Learned by a VLAN
To limit the number of MAC addresses learned by a VLAN, perform the following steps:
[edit vlans] user@switch# set vlan-name switch-options mac-table-size limit packet-action action
Limiting the Number of MAC Addresses Learned by an Interface in a VLAN
To limit the number of MAC addresses learned by an interface in a VLAN, perform the following steps:
Configuring MAC Limiting (non-ELS)
This task uses Junos OS for EX Series switches and QFX3500 and QFX3600 switches that does not support the Enhanced Layer 2 Software (ELS) configuration style.
This topic describes various ways of configuring a limitation on MAC addresses in packets that are received and forwarded by the switch.
Before you can change a MAC limit that was previously set for an interface or a VLAN, you must first clear existing entries in the MAC address forwarding table that correspond to the change you want to make. Thus, to change the limit on an interface, first clear the MAC address forwarding table entries for that interface. To change the limit on all interfaces and VLANs, clear all MAC address forwarding table entries. To change the limit on a VLAN, clear the MAC address forwarding table entries for that VLAN.
To clear MAC addresses from the forwarding table:
Clear MAC address entries from a specific interface (here, the interface is ge-0/0/1) in the forwarding table:
user@switch> clear ethernet-switching-table interface ge-0/0/1
Clear all MAC address entries in the forwarding table:
user@switch>clear ethernet-switching-table
Clear MAC address entries from a specific VLAN (here, the VLAN is vlan-abc):
user@switch> clear ethernet-switching-table vlan vlan-abc
The different ways of setting a MAC limit are described in the following sections:
- Limiting the Number of MAC Addresses That Can be Learned on Interfaces
- Specifying MAC Addresses That Are Allowed
- Configuring MAC Limiting for VLANs
Limiting the Number of MAC Addresses That Can be Learned on Interfaces
To configure MAC limiting for port security by setting a maximum number of MAC addresses that can be learned on interfaces.
Specifying MAC Addresses That Are Allowed
You must clear existing entries in the MAC address forwarding table prior to changing the MAC address limit.
To configure MAC limiting for port security by specifying allowed MAC addresses:
Configuring MAC Limiting for VLANs
You must clear existing entries in the MAC address forwarding table before you can change the MAC address limit.
MAC limiting for a VLAN restricts the MAC addresses that can be learned for that VLAN, but does not drop the packet. Therefore, setting the MAC limit on a VLAN is not considered a port-security feature.
The configuration of specific allowed MAC addresses does not apply to VLANs.
To configure MAC limiting for a VLAN using the CLI:
If the MAC limit on a specific VLAN is exceeded, the device logs the MAC addresses of packets that cause the limit to be exceeded. No other action is possible.
[edit vlans] user@switch# set vlan-abc mac-limit 20
When you are applying a MAC limit on a VLAN, do not set mac-limit
to 1 for a
VLAN composed of Routed VLAN Interfaces (RVIs) or
a VLAN composed of aggregated Ethernet bundles
using LACP. In these cases, setting the
mac-limit
to 1 prevents the
device from learning MAC addresses other than the
automatic addresses:
For RVIs, the first MAC address inserted into the forwarding database is the MAC address of the RVI.
For aggregated Ethernet bundles using LACP, the first MAC address inserted into the forwarding database in the forwarding table is the source address of the protocol packet.
If the VLAN is composed of regular access or trunk interfaces, you can set the mac-limit
to 1 if you choose to do so.
Configuring MAC Limiting on MX Series Routers
This topic describes the different ways of configuring a limitation on MAC addresses in packets that are received and forwarded by MX Series routers.
- Limiting the Number of MAC Addresses Learned by an Interface
- Limiting the Number of MAC Addresses Learned by a Bridge Domain
- Limiting the Number of MAC Addresses Learned by an Interface in a Bridge Domain
Limiting the Number of MAC Addresses Learned by an Interface
To secure a port, you can set the maximum number of MAC addresses that can be learned by an interface.
MX Series routers support only the drop action. If the action is not specified, the router performs the default action drop if the limit is exceeded.
[edit switch-options] user@switch# set interface interface-name interface-mac-limit limit packet-action action
[edit routing-instances] user@switch# set routing-instance-name switch-options interface interface-name interface-mac-limit limit
[edit switch-options] user@switch# set interface-mac-limit limit
[edit routing-instances] user@switch# set routing-instance-name switch-options interface-mac-limit limit
After you set a new MAC limit for the interface, the system clears existing entries in the MAC address forwarding table associated with the interface.
Limiting the Number of MAC Addresses Learned by a Bridge Domain
To limit the number of MAC addresses learned by a bridge domain, perform the following steps:
[edit bridge-domains] user@switch# set bridge-domain-name bridge-options mac-table-size limit packet-action action
Limiting the Number of MAC Addresses Learned by an Interface in a Bridge Domain
To limit the number of MAC addresses learned by an interface in a bridge domain, perform the following steps:
Configuring MAC Limiting (J-Web Procedure)
MAC limiting protects against flooding of the Ethernet switching table on an EX Series switch. MAC limiting sets a limit on the number of MAC addresses that can be learned on a single Layer 2 access interface (port).
Junos OS provides two MAC limiting methods:
Maximum number of dynamic MAC addresses allowed per interface—If the limit is exceeded, incoming packets with new MAC addresses are dropped.
Specific “allowed” MAC addresses for the access interface—Any MAC address that is not in the list of configured addresses is not learned.
You configure MAC limiting for each interface, not for each VLAN. You can specify the maximum number of dynamic MAC addresses that can be learned on a single Layer 2 access interface or on all Layer 2 access interfaces. The default action that the switch will take if that maximum number is exceeded is drop—drop the packet and generate an alarm, an SNMP trap, or a system log entry.
To enable MAC limiting on one or more interfaces using the J-Web interface:
You can enable or disable port security on the switch at any time by clicking the Activate or Deactivate button on the Port Security Configuration page. If security status is shown as Disabled when you try to edit settings for any VLANs or interfaces (ports), a message asking whether you want to enable port security appears.