A PortChannel is SONiC's name for a link aggregation group (LAG), defined in IEEE 802.1AX. It combines several Ethernet links between two devices into one logical interface. Multiple traffic flows, such as separate TCP connections, can use the combined capacity. If one member link fails, traffic can continue over the remaining links.
Link Aggregation Control Protocol (LACP) decides which links join the bundle. Each switch normally sends a flow over one member link, so a single flow gets no more than that link's capacity.
The PortChannel can come up only when LACP has selected at least the configured minimum number of member links and both switches agree that those links can carry traffic. This lab uses the default --min-links value of 1.
About This Lab
This guide follows Humza Altaf's GNS3 lab using community SONiC 202205. The original PDF is revision 1.0, dated 15 October 2023. The outputs below are from that lab, which has not been re-run for this page.
The original switch commands are preserved. Step 2 adds an IPv6 check, an address re-check and a save at that point. Step 7 adds verification and save blocks after repeating the configuration on S2. Step 8 corrects a mistake in the PC1 address command and supplies the missing PC2 command. Summaries and excerpts are labelled where they appear.
Topology and Port Mapping
S1 and S2 connect through two member links in PortChannel0002. PC1 and PC2 connect to access ports in VLAN 10 and send untagged frames.
| Connection | GNS3 Ports | SONiC Interfaces |
|---|---|---|
| First PortChannel member | S1 e0 to S2 e0 | Ethernet0 to Ethernet0 |
| Second PortChannel member | S1 e1 to S2 e1 | Ethernet4 to Ethernet4 |
| PC1 access link | PC1 e0 to S1 e2 | S1 Ethernet8 |
| PC2 access link | PC2 e0 to S2 e2 | S2 Ethernet8 |
Use the original port mapping below. Ethernet12 is listed for reference but is not used in this topology.
| GNS3 Interface | SONiC Interface |
|---|---|
| Ethernet 0 | Ethernet 0 |
| Ethernet 1 | Ethernet 4 |
| Ethernet 2 | Ethernet 8 |
| Ethernet 3 | Ethernet 12 |
| Host | Address | Switch Access Port |
|---|---|---|
| PC1 | 192.168.11.2/24 | S1 Ethernet8, untagged in VLAN 10 |
| PC2 | 192.168.11.3/24 | S2 Ethernet8, untagged in VLAN 10 |
Use separate GNS3 consoles for S1, S2, PC1 and PC2. Connect the links as shown and make sure the lab interfaces are administratively enabled.
Step 1. Check the Interfaces on S1
Start by checking the physical interface names and their administrative and operational states. The lab uses Ethernet0 and Ethernet4 for the PortChannel and Ethernet8 for PC1.
show interfaces statusThe following historical output summary retains selected columns and rows from the 2023 screenshot. All three interfaces were administratively and operationally up.
| Interface | Speed | MTU | Vlan | Oper | Admin |
|---|---|---|---|---|---|
| Ethernet0 | 1G | 9100 | routed | up | up |
| Ethernet4 | 1G | 9100 | routed | up | up |
| Ethernet8 | 1G | 9100 | routed | up | up |
An interface can be administratively up while its link is down. Check the GNS3 connection and the interface at the other end before continuing.
Step 2. Remove the Routed Interface Addresses
The SONiC virtual switch first boots with the t1 sample configuration for its default Force10-S6000 hardware SKU, which gives each port a /31 address. SONiC 202205 will not add a port that still has an IP address to a PortChannel or a VLAN, so remove the addresses first.
show ip interfacesThis historical output summary retains the interface, address and state columns. The screenshot shows only the Ethernet0 and Ethernet4 rows.
| Interface | IPv4 address/mask | Admin/Oper |
|---|---|---|
| Ethernet0 | 10.0.0.0/31 | up/up |
| Ethernet4 | 10.0.0.2/31 | up/up |
The IPv6 check below is an addition to the PDF. If it lists configured IPv6 addresses on Ethernet0, Ethernet4 or Ethernet8, remove those too before continuing. An fe80:: link-local address that you did not configure can stay, because SONiC checks only configured addresses before adding a port to a PortChannel or VLAN.
show ipv6 interfacesRemove the recorded IPv4 addresses from Ethernet0, Ethernet4 and Ethernet8. Ethernet8's address is 10.0.0.4/31, as the third command below shows.
sudo config interface ip remove Ethernet0 10.0.0.0/31
sudo config interface ip remove Ethernet4 10.0.0.2/31
sudo config interface ip remove Ethernet8 10.0.0.4/31The following re-check is an addition to the PDF. Confirm that none of the three ports retains a configured IPv4 or IPv6 address.
show ip interfaces
show ipv6 interfacesThe PDF recommends saving the configuration. This guide adds a save command here, after the address checks. It writes the running configuration to /etc/sonic/config_db.json, which SONiC loads at boot.
sudo config save -yStep 3. Create PortChannel0002
Check whether a PortChannel already exists. The historical check has no PortChannel rows.
show interfaces portchannelCreate PortChannel0002, then check its state. No member interfaces have been added yet.
sudo config portchannel add PortChannel0002
show interfaces portchannelThe historical output below shows the PortChannel down. A identifies active LACP mode, and Dw shows that PortChannel0002 is down.
admin@sonic:~$ show interfaces portchannel
Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available,
S - selected, D - deselected, * - not synced
No. Team Dev Protocol Ports
----- --------------- ----------- -------
0002 PortChannel0002 LACP(A)(Dw)The flags below apply to show interfaces portchannel. SONiC 202205 creates PortChannels in active LACP mode, so this lab shows A.
| Flag | Meaning |
|---|---|
| A | Active LACP mode. Sends LACP messages, called LACPDUs, without waiting for the other switch. |
| I | Passive LACP mode. Keeps sending LACP messages only while the other switch is in active mode. The output legend calls this inactive. |
| Up | The PortChannel is operationally up. |
| Dw | The PortChannel is operationally down. |
| S | LACP has selected the member. |
| D | LACP has not selected the member. |
| * | The member's enabled state is missing or does not match LACP's selection. A selected member should be enabled to carry traffic, and a deselected member should be disabled. |
| N/A | Status is not available. |
Active mode does not mean the PortChannel is working. Its operational state is still down in this output.
Step 4. Add the Member Interfaces
Add Ethernet0 and Ethernet4 to the PortChannel. The command block below joins the member-add commands and display command from two separate PDF screenshots.
sudo config portchannel member add PortChannel0002 Ethernet0
sudo config portchannel member add PortChannel0002 Ethernet4
show interfaces portchannelUntil S2 runs LACP on the other ends, the expected state on S1 is LACP(A)(Dw) with Ethernet0(D) and Ethernet4(D). S1 receives no LACP messages until then, so LACP cannot select either member. The PDF has no output for this stage.
The historical output below was recorded with both switches configured. Expect this result after completing S2 in Step 7.
admin@sonic:~$ show interfaces portchannel
Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available,
S - selected, D - deselected, * - not synced
No. Team Dev Protocol Ports
----- --------------- ----------- -------------------------
0002 PortChannel0002 LACP(A)(Up) Ethernet4(S) Ethernet0(S)This PortChannel was created without --min-links, so SONiC uses 1 and can show Up with only one member selected. Check that both Ethernet0 and Ethernet4 show S with no asterisk.
Step 5. Create VLAN 10
Check the VLAN table before adding the lab VLAN. The historical check has no VLAN rows.
show vlan briefCreate VLAN 10 and display the table again. At this stage, it has no IP address or member ports.
sudo config vlan add 10
show vlan briefStep 6. Add the Access Port and PortChannel to VLAN 10
Make Ethernet8 an untagged member of VLAN 10 and add PortChannel0002 as a tagged member. Configure VLAN membership on the logical PortChannel, rather than its Ethernet0 and Ethernet4 members.
sudo config vlan member add -u 10 Ethernet8
sudo config vlan member add 10 PortChannel0002
show vlan briefThe historical output summary below retains the VLAN, port and tagging columns. Check that Ethernet8 is untagged and PortChannel0002 is tagged.
| VLAN ID | Ports | Port Tagging |
|---|---|---|
| 10 | Ethernet8 | untagged |
| 10 | PortChannel0002 | tagged |
Step 7. Configure S2
Repeat Steps 1 through 6 on S2, with Ethernet0 and Ethernet4 at the other ends of the same two links. Use VLAN 10 and make PortChannel0002 tagged as on S1. Ethernet8 connects to PC2 and is untagged in VLAN 10.
The PortChannel name matches on both switches for clarity. LACP does not exchange that name, so it only matters locally.
Check S2's existing addresses before removing them. The same virtual image normally starts with the same t1 addresses, but its configuration may have been changed.
Step 7 in the PDF has no verification block. Run the commands below on both switches and confirm the selected members and VLAN membership.
show interfaces portchannel
show vlan briefThe save block is also an addition at this point. Run it on both switches after completing the configuration.
sudo config save -yStep 8. Configure the Hosts
Assign PC1 192.168.11.2/24 and PC2 192.168.11.3/24. These hosts are on the same subnet and do not need a default gateway for this test.
The original PC1 command and its reply are preserved below. VPCS accepts 255.255.255.0 as a subnet mask. In this command, it also stores that mask as the default gateway.
PC1> ip 192.168.11.2/24 255.255.255.0
Checking for duplicate address...
PC1 : 192.168.11.2 255.255.255.0This historical excerpt from sh ip retains only the address and gateway fields. It shows the wrong gateway set by the original command.
PC1> sh ip
IP/MASK : 192.168.11.2/24
GATEWAY : 255.255.255.0Give the mask as a prefix length using the corrected commands below. The PC1 command corrects the original input, and the PC2 command is an addition using the address from the topology.
PC1> ip 192.168.11.2/24
PC2> ip 192.168.11.3/24Run the following command in each VPCS console. Confirm the address matches the topology and GATEWAY is 0.0.0.0.
show ipVPCS shows 0.0.0.0 when no gateway is set. The lab did not record this corrected output. The original wrong gateway did not stop the same-subnet ping.
Check Connectivity
Ping PC2 from PC1, then test the reverse direction. These are the commands and replies recorded in the 2023 lab.
PC1> ping 192.168.11.3
84 bytes from 192.168.11.3 icmp_seq=1 ttl=64 time=5.028 ms
84 bytes from 192.168.11.3 icmp_seq=2 ttl=64 time=5.433 ms
84 bytes from 192.168.11.3 icmp_seq=3 ttl=64 time=5.524 ms
84 bytes from 192.168.11.3 icmp_seq=4 ttl=64 time=5.206 ms
84 bytes from 192.168.11.3 icmp_seq=5 ttl=64 time=5.331 msPC2> ping 192.168.11.2
84 bytes from 192.168.11.2 icmp_seq=1 ttl=64 time=5.457 ms
84 bytes from 192.168.11.2 icmp_seq=2 ttl=64 time=5.146 ms
84 bytes from 192.168.11.2 icmp_seq=3 ttl=64 time=5.455 ms
84 bytes from 192.168.11.2 icmp_seq=4 ttl=64 time=5.725 ms
84 bytes from 192.168.11.2 icmp_seq=5 ttl=64 time=5.092 msThese replies confirm host reachability in the recorded lab. They do not measure aggregate throughput, traffic distribution across both members or recovery after a link failure.
Before Production Use
Confirm the PortChannel state, selected members and VLAN tagging on both switches, then test traffic in both directions. Test with one member link down at a time while --min-links is 1, as in this lab. Measure packet loss and recovery time.
Set --min-links, and --fallback if needed, when creating the PortChannel. In SONiC 202205, changing either requires deleting and re-creating it, which means removing its VLAN membership and members first. With fallback enabled, SONiC can select one member when the other end sends no LACP messages.
SONiC 202205 does not expose fast LACP through its CLI or CONFIG_DB settings. It asks the switch at the other end to send an LACP message every 30 seconds. SONiC sends its own LACP messages at the rate requested by the other switch. A member that stops receiving them times out after about 90 seconds, even if its physical link stays up. The --fast-rate option was added in SONiC 202211.
On a hardware switch, the switch ASIC chooses a member link for each traffic flow by calculating a hash from packet fields. Each switch makes that choice for the traffic it sends. SONiC 202205 has no command to change which packet fields the LAG hash uses. The config switch-hash commands first appear in the 202311 command reference.
This virtual lab does not show how a hardware switch distributes traffic or confirm that the saved configuration survives a reboot. Check the SONiC supported platforms and feature support for your intended image, then reboot the switch and check that the configuration is still there.
Use the optional diagnostic below to see the LACP details this switch has received from the other switch. SONiC 202205 installs teamdctl in the teamd container, but this command was not part of the original lab.
docker exec teamd teamdctl -v PortChannel0002 stateRun it on both switches when troubleshooting a D or * flag. Under each member, the partner system and key should match the actor values shown on the other switch, and both members should show the same partner. Without -v, the command shows only each member's link, aggregator, selection and LACP state.
Use the command reference and CLI help that match the exact SONiC release you run. This lab uses the 202205 command reference.
To connect one device through a single PortChannel to two switches, use multichassis link aggregation (MCLAG). Continue with the MCLAG guide for the additional configuration required on both switches.
The many benefits of SONiC, once exclusive to hyperscalers, are now within reach for enterprise clients. Contact our team of seasoned networking experts to learn why right now is a transformative time in the industry as we move closer to wider SONiC adoption.
Humza Altaf
Hardware Nation