How to configure VLANs in SONiC?

Table of Contents

 

Introduction

VLANs allow segmentation of Layer 2 broadcast domains. In this article, we configure two VLANs (10 and 55) across two switches connected via a trunk link.

 

Prerequisites

Before starting the configuration, ensure you have the following:

  • Installed SONiC on both switches.
  • Console/SSH access to both switches S1 and S2.
  • Console terminal software: PuTTY, Teraterm, SecureCRT, etc.
  • Serial Console cable: Provided with the device.
  • Basic Linux CLI knowledge.

 

Topology

Configure VLANs

Note

By default, all Ethernet interfaces have IP addresses assigned. Remove these addresses and keep IP configuration only on the docker0 and Loopback interfaces.

This can be done manually using CLI commands or by using an automation script.

 

STEP 1: Create VLANs 

On both switches:

sudo config vlan add -m 10,55

The "-m" option allow you to add multiple VLANs separated by comma.


STEP 2: Assign Access Ports

Switch S1:

sudo config vlan member add -u 10 Ethernet4
sudo config vlan member add -u 10 Ethernet12
sudo config vlan member add -u 55 Ethernet28

The "-u" option specifies untagged (access) port.

 

STEP 3: Configure Trunk Ports

On both switches:

sudo config vlan member add -m 10,55 Ethernet32

Without "-u" option, ports are tagged.

 

Switch S2:

sudo config vlan member add -u 55 Ethernet4
sudo config vlan member add -u 10 Ethernet20
sudo config vlan member add -m 10,55 Ethernet32

 

STEP 4: Save configuration
sudo config save -y

 

STEP 5: Configure static IP addresses on all PCs (according to Topology above)

 

STEP 6: Verification

Check VLAN table:

show vlan brief

Switch S1:

Switch S2:

 

STEP 7: Test connectivity
  • Ping between PCs in VLAN 10 → should succeed.

  • Ping between PCs in VLAN 55 → should succeed.

  • Ping between PCs in VLAN 10 and 55 → should fail.

 

Troubleshooting

If connectivity fails:

  • show interfaces status
  • show vlan brief
  • Verify trunk configuration
  • Check IP addresses

 

Congratulations!

You have successfully configured VLANs on both SONiC switches and verified Layer 2 connectivity across a trunk link based on IEEE 802.1Q. 

If you have any questions related to this article, feel free to reach out to our technical support team.

Happy Networking!

 

Useful links

Official SONiC repository

 

If you want to explore more topics, be sure to check out our other guides, including:

How can I set up a console connection to Edgecore Open Networking switch?

How to Reset Password in SONiC?

How to install and deploy SONiC on network switches?

How to configure VLANs in SONiC?

Where to download the SONiC Virtual Switch (VS) community pre-built image?

 

For more free resources, visit: 

https://stordis.com/free-resources/

 

Still have questions? You can find more answers in our full FAQ - just follow the link below.

STORDIS Support Portal FAQ

 

 

Comments 0

Articles in this section