Skip to content

L2 Switch mode

Qi Luo edited this page May 25, 2018 · 22 revisions

SONiC switches are normally operated in Layer 3 Switch mode, however, they could also be operated as L2 Switch. This document will describe the basic features supported in L2 Switch mode.

L2 Switch Configuration Workflow

1. Config the management port

Below is a sample command line. Please replace the eth0 and gwaddr values with correct management IP address and default gateway address.

cat <<EOF | sudo config reload /dev/stdin -y
{
    "MGMT_INTERFACE": {
        "eth0|10.3.147.46/23": {
            "gwaddr": "10.3.146.1"
        }
    },
    "DEVICE_METADATA": {
        "localhost": {
            "hostname": "sonic"
        }
    }
}
EOF

2. Config the switch MAC address with management port MAC address

sudo sonic-cfggen -H --write-to-db

3. Generate a configuration for L2 switch mode

Below is a sample command line. User should provide a SKU parameter. The output file is stdout for validation purpose.

sonic-cfggen -t /usr/local/lib/python2.7/dist-packages/usr/share/sonic/templates/l2switch.j2 -p -k Mellanox-SN2700

4. Load the configuration into ConfigDB

Existing ConfigDB will be overwritten.

sonic-cfggen -t /usr/local/lib/python2.7/dist-packages/usr/share/sonic/templates/l2switch.j2 -p -k Mellanox-SN2700 | sudo config load /dev/stdin -y

5. Save ConfigDB for persistence

sudo config save -y

6. Restart swss

sudo systemctl restart swss

Port Speed Configuration CLI (optional)

Port speed is initially specified in the minigraph and load into ConfigDB. During runtime, we could config port speed by CLI. Below is a sample.

sudo config interface speed Ethernet0 40000

We could verify the port speed by CLI.

show interface status
Clone this wiki locally