L2 Switching Configuration in SONiC: VLANs and Port Channels

Layer 2 switching is a fundamental networking capability that forms the backbone of modern data center networks. As networks evolve toward more open and flexible architectures, Enterprise SONiC (Software for Open Networking in the Cloud) has emerged as a powerful open-source network operating system that provides robust L2 switching capabilities. In this article, I’ll explore how to configure two essential L2 switching features in Enterprise SONiC: VLANs and Port Channels.

Understanding VLANs in SONiC

VLAN Configuration in SONiC

In SONiC’s CLI mode (known as “sonic-cli” or “Klish”), VLAN configuration is straightforward. A VLAN is created by configuring a Switched Virtual Interface (SVI).

Here’s the basic syntax for creating a VLAN:

interface vlan <number>

For example, to create VLAN 100:

sonic(config)# interface Vlan 100

Once the VLAN is created, you can assign it to ports in either access or trunk mode.

Access ports belong to a single VLAN and typically connect to end devices like servers or workstations. To configure a port as an access port and assign it to a VLAN, use the following commands:

sonic(config)# interface Ethernet 12
sonic(conf-if-Ethernet12)# switchport access Vlan 100
sonic(conf-if-Ethernet12)# end

You can verify your configuration with:

sonic# show Vlan
Q: A - Access (Untagged), T - Tagged
NUM        Status      Q Ports
100        Inactive    A  Ethernet12

Configuring Trunk Ports

Trunk ports carry traffic for multiple VLANs and are typically used for connections between switches or to virtualization hosts running multiple virtual machines. To configure a port as a trunk and allow specific VLANs:

sonic(conf-if-Ethernet12)# no switchport access Vlan
sonic(conf-if-Ethernet12)# switchport trunk allowed Vlan 100
sonic(conf-if-Ethernet12)# end

Verification:

sonic# show Vlan
Q: A - Access (Untagged), T - Tagged
NUM        Status      Q Ports
100        Inactive    T  Ethernet12

Port Channels (also known as Link Aggregation Groups or LAGs) allow bundling multiple physical links between devices to provide increased bandwidth and redundancy. SONiC supports both static link aggregation and dynamic link aggregation using the Link Aggregation Control Protocol (LACP).

Configuring a Port Channel in SONiC is a two-step process:

  1. Create a new Port Channel interface in Global Configuration Mode
  2. Assign individual Ethernet interfaces to the Port Channel

Here’s the syntax for creating a Port Channel:

interface PortChannel <lag-id> [ mode <PoMode> ] [ min-links <min-links-value> ] [fallback ] [ fast_rate ]

The mode parameter can be set to “active” for LACP or “on” for static LAG.

For example, to create Port Channel 1:

sonic(config)# interface PortChannel 1

After creating the Port Channel, you need to assign physical interfaces to it:

sonic(config)# interface Ethernet 13
sonic(conf-if-Ethernet13)# channel-group 1

You can verify your Port Channel configuration with:

show PortChannel summary

This command displays information about all configured Port Channels, including their operational status and member ports:

Flags(oper-status):  D - Down U - Up (portchannel) P - Up in portchannel (members)
-------------------------------------------------------------------------
Group               PortChannel                   Type                Protocol       Member Ports
-------------------------------------------------------------------------
1                   PortChannel1   (D)            Eth                 LACP           Ethernet13(D)

When implementing VLANs and Port Channels in your SONiC environment, consider the following best practices:

  • Plan your VLAN numbering scheme carefully to ensure consistency and scalability
  • Document the purpose of each VLAN to maintain clarity as your network grows
  • Consider using VRF (Virtual Routing and Forwarding) for multi-tenancy when needed
  • Remember that SONiC supports up to 4094 VLANs, following the IEEE 802.1Q standard
  • Use LACP (mode “active”) when possible for dynamic negotiation of link aggregation
  • Configure consistent settings on both ends of the Port Channel
  • Consider setting min-links to ensure minimum bandwidth requirements
  • For critical applications, distribute Port Channel member links across different line cards or modules for hardware redundancy

Advanced Configuration Options

While the basic configuration is sufficient for many environments, SONiC offers advanced options for both VLANs and Port Channels.

  • min-links: Specifies the minimum number of operational links required for the Port Channel to be considered up
  • fallback: Enables fallback mode, which allows a port to join a Port Channel even if LACP negotiation fails
  • fast_rate: Configures LACP to use fast periodic transmissions (1 second instead of the default 30 seconds)

For example:

sonic(config)# interface PortChannel 1 min-links 2 fast_rate

L2 switching capabilities like VLANs and Port Channels are fundamental building blocks for any network infrastructure. Enterprise SONiC provides a robust implementation of these features with a straightforward configuration syntax that will be familiar to network engineers with experience on other platforms.

By mastering these basic configurations, you’ll be well-positioned to implement more advanced features in SONiC, such as MCLAG (Multi-Chassis Link Aggregation Group), VXLAN overlays, and BGP EVPN. These foundational elements form the basis for building scalable, resilient, and high-performance data center networks with Enterprise SONiC.

As you continue your journey with SONiC, remember that its open architecture provides flexibility while maintaining compatibility with industry standards, making it an excellent choice for modern data center deployments.