MC-LAG and STP Configuration on Enterprise SONiC Switch
1. Background
MC-LAG inherently provides loop avoidance mechanisms. In normal operation, MC-LAG-based networks do not generate Layer 2 loops. However, in multi-tier MC-LAG deployments, loops may still occur due to incorrect network design, incomplete initial configuration, or device reboot with empty configuration. In such cases, STP can be deployed as a safeguard to prevent loop formation.
2. Topology Requirements
Switches adopt cross-device link aggregation (MC-LAG) to ensure high service reliability at the device level. Under normal conditions, traffic is load-balanced across all active links. With STP enabled, the network is still able to successfully break potential loops, while ensuring that data forwarding is not impacted.
3. Configuration Steps
3.1 Create the aggregate interface, and add the physical interfaces connected to each switch into the corresponding Link Aggregation Group (LAG).
sonic(config)# interface link-aggregation 1
sonic(config)# interface ethernet 20
sonic(config-if-20)# link-aggregation-group 1
sonic(config-if-20)# exit
sonic(config)# interface ethernet 35
sonic(config-if-35)# link-aggregation-group 1
sonic(config-if-35)# exit
sonic(config)# interface link-aggregation 1
sonic(config)# interface link-aggregation 2
sonic(config)# interface link-aggregation 3
sonic(config)# interface ethernet 14
sonic(config-if-14)# link-aggregation-group 1
sonic(config-if-14)# exit
sonic(config)# interface ethernet 11
sonic(config-if-11)# link-aggregation-group 2
sonic(config-if-11)# exit
sonic(config)# interface ethernet 12
sonic(config-if-12)# link-aggregation-group 3
sonic(config-if-12)# exit
sonic(config)# interface link-aggregation 1
sonic(config)# interface link-aggregation 2
sonic(config)# interface link-aggregation 3
sonic(config)# interface ethernet 35
sonic(config-if-35)# link-aggregation-group 1
sonic(config-if-35)# exit
sonic(config)# interface ethernet 21
sonic(config-if-21)# link-aggregation-group 2
sonic(config-if-21)# exit
sonic(config)# interface ethernet 49
sonic(config-if-49)# link-aggregation-group 3
sonic(config-if-49)# exit
sonic(config)# interface link-aggregation 3
sonic(config)# interface ethernet 12
sonic(config-if-12)# link-aggregation-group 3
sonic(config-if-12)# exit
sonic(config)# interface ethernet 49
sonic(config-if-49)# link-aggregation-group 3
sonic(config-if-49)# exit
3.2 Create the VLAN interface, and assign both the physical interfaces and the Link Aggregation Group (LAG) to the corresponding VLAN.
sonic(config)# vlan 10
sonic(config)# interface link-aggregation 1
sonic(config-lagif-1)# switchport trunk vlan 10
sonic(config-lagif-1)# exit
sonic(config)# interface ethernet 37
sonic(config-if-37)# switchport trunk vlan 10
sonic(config-if-37)# exit
sonic(config)# interface ethernet 10
sonic(config-if-10)# switchport trunk vlan 10
sonic(config-if-10)# exit
sonic(config)# vlan 10
sonic(config)# vlan 400
sonic(config)# interface link-aggregation 1
sonic(config-lagif-1)# switchport trunk vlan 10
sonic(config-lagif-1)# exit
sonic(config)# interface link-aggregation 2
sonic(config-lagif-2)# switchport trunk vlan 400
sonic(config-lagif-2)# switchport trunk vlan 10
sonic(config-lagif-2)# stp bpdu-filter enable
sonic(config-lagif-2)# exit
sonic(config)# interface link-aggregation 3
sonic(config-lagif-3)# switchport trunk vlan 10
sonic(config-lagif-3)# exit
sonic(config)# vlan 10
sonic(config)# vlan 400
sonic(config)# interface link-aggregation 1
sonic(config-lagif-1)# switchport trunk vlan 10
sonic(config-lagif-1)# exit
sonic(config)# interface link-aggregation 2
sonic(config-lagif-2)# switchport trunk vlan 400
sonic(config-lagif-2)# switchport trunk vlan 10
sonic(config-lagif-2)# stp bpdu-filter enable
sonic(config-lagif-2)# exit
sonic(config)# interface link-aggregation 3
sonic(config-lagif-3)# switchport trunk vlan 10
sonic(config-lagif-3)# exit
sonic(config)# vlan 10
sonic(config)# interface link-aggregation 3
sonic(config-lagif-3)# switchport trunk vlan 10
sonic(config-lagif-3)# exit
sonic(config)# interface ethernet 38
sonic(config-if-38)# switchport trunk vlan 10
sonic(config-if-38)# exit
sonic(config)# interface ethernet 3
sonic(config-if-3)# switchport trunk vlan 10
sonic(config-if-3)# exit
3.3 Configure MC-LAG and set a consistent Bridge MAC address across both peer devices.
sonic(config)# bridge mac 00:00:04:12:05:01
sonic(config)# interface vlan 400
sonic(config-vlanif-400)# ip address 50.1.1.2/24
sonic(config-vlanif-400)# exit
sonic(config)# mclag domain 1
sonic(mclag-domain)# peer-address 50.1.1.1
sonic(mclag-domain)# local-address 50.1.1.2
sonic(mclag-domain)# peer-link link-aggregation 2
sonic(mclag-domain)# member lag 1
sonic(mclag-domain)# member lag 3
sonic(mclag-domain)# commit
sonic(mclag-domain)# exit
sonic(config)# bridge mac 00:00:04:12:05:01
sonic(config)# interface vlan 400
sonic(config-vlanif-400)# ip address 50.1.1.1/24
sonic(config-vlanif-400)# exit
sonic(config)# mclag domain 1
sonic(mclag-domain)# peer-address 50.1.1.2
sonic(mclag-domain)# local-address 50.1.1.1
sonic(mclag-domain)# peer-link link-aggregation 2
sonic(mclag-domain)# member lag 1
sonic(mclag-domain)# member lag 3
sonic(mclag-domain)# commit
sonic(mclag-domain)# exit
3.4 Enable MSTP on the switch, and verify the STP loop-prevention status across the entire device.
sonic(config)# stp enable mstp
sonic(config)# stp instance 1
sonic(config-stp-1)# exit
sonic(config)# stp bind vlan 10 1
sonic(config)# stp name test
sonic(config)# stp enable mstp
sonic(config)# stp instance 1
sonic(config-stp-1)# exit
sonic(config)# stp bind vlan 10 1
sonic(config)# stp name test
sonic(config)# stp enable mstp
sonic(config)# stp instance 1
sonic(config-stp-1)# exit
sonic(config)# stp bind vlan 10 1
sonic(config)# stp name test
sonic(config)# stp enable mstp
sonic(config)# stp instance 1
sonic(config-stp-1)# exit
sonic(config)# stp bind vlan 10 1
sonic(config)# stp name test
4. Verification
1. Check MC-LAG status
sonic# show mclag state
The MCLAG’s keepalive is: OK
MCLAG info sync is: completed
Domain id: 1
MCLAG session Channel: Primary channel
VRF Name: default
consistency Check Action: idle
Local Ip: 50.1.1.1
Peer Ip: 50.1.1.2
Peer Link Interface: PortChannel0002
Keepalive time: 1
sesssion Timeout : 15
Peer Link Mac: 00:11:24:1a:1b:61
Admin Role: None
Role: Standby
MCLAG Interface: PortChannel0001, PortChannel0003
Loglevel: DEBUG
2. Check the STP status on Switch D
sonic# show stp status
role Flags: Root - Root, Desg - Designated, Altn - Alternate, Back - Backup, Mstr - Master, Disa - Disabled
state Flags: disc - Discard/Blocking/Listening, lear - Learning, forw - Forwarding
Spanning-tree Mode: mstp
mst_instance port port_role stp_state
-------------- --------------- ----------- -----------
1 Ethernet3 Desg forw
1 PortChannel0003 Root forw
1 Ethernet38 Altn disc