Currently Empty: 0.00 €
Open Networking
L2 Switching Configuration in SONiC: VLANs and Port Channels

Listen to this Article
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.
Whether youâre building a new data center fabric or migrating from a proprietary solution, understanding these basic building blocks is crucial. SONiCâs implementation of these features follows industry standards while providing the flexibility and performance required in modern data centers.
Understanding VLANs in SONiC
Virtual LANs (VLANs) allow network administrators to create logically separated networks on the same physical infrastructure. This segmentation improves security, reduces broadcast domains, and enables more efficient network design.
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.
Configuring Access Ports
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 in SONiC
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).
Creating a Port Channel
Configuring a Port Channel in SONiC is a two-step process:
- Create a new Port Channel interface in Global Configuration Mode
- 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
Adding Interfaces to a Port Channel
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
Verifying Port Channel Configuration
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)
Design Considerations and Best Practices
When implementing VLANs and Port Channels in your SONiC environment, consider the following best practices:
For VLANs:
- 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
For Port Channels:
- 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.
Port Channel Options:
- 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
Conclusion
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.