SONiC Network OS Configuration with GNS3: Easy Guide - 夜莺博客

SONiC Network OS Configuration with GNS3: Easy Guide

SONiC is the open-source network operating system that is taking over data center switching, but practicing on real hardware is expensive. The SONiC Virtual Switch (VS) solves that: it runs as a Docker container or KVM image, and with GNS3 you can build a complete multi-switch Clos topology on a laptop. This article, based on PLVision's hands-on SONiC tutorial, walks through downloading and installing the SONiC VS image in GNS3, understanding ConfigDB (the Redis-backed running configuration), and configuring VLANs, LAGs, routed interfaces and BGP using real SONiC CLI commands.

SONiC Virtual Switch and GNS3

The SONiC VS platform is implemented as a vslib library linked with the syncd daemon at build time; it stores SAI configuration data while the Linux networking stack (routes, ARP entries) makes forwarding decisions. To use it in GNS3, download a pre-built image and register it as an appliance:

wget https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-201911/181/artifact/target/sonic-vs.img.gz
gunzip sonic-vs.img.gz
wget https://raw.githubusercontent.com/Azure/sonic-buildimage/master/platform/vs/sonic-gns3a.sh
./sonic-gns3a.sh -b <path to sonic.img>

ConfigDB: Running vs. Startup Configuration

On boot, configurations load from /etc/sonic/config_db.json into the Redis ConfigDB namespace - think of the file as startup configuration and ConfigDB as the running configuration. CLI changes update ConfigDB but are not written back automatically. Save with sudo config save -y; apply a saved file with sudo config reload -y (restarts SONiC services). For multi-node topologies, give each switch a unique router MAC and BGP ASN in the DEVICE_METADATA section, and unique Loopback0 addresses.

Intra-Rack Switching: VLANs

config vlan add 100
config vlan member add -u 100 Ethernet12
config vlan member add -u 100 Ethernet16
config vlan member add -u 100 Ethernet20
show vlan brief

From Linux, verify with bridge vlan list. The default image contains ebtables rules blocking ARP forwarding between L2 interfaces (ebtables --list); remove the ARP drop rule with ebtables --delete FORWARD 2 if your hosts need to communicate within the VLAN.

Link Aggregation with PortChannels

config portchannel add PortChannel0001
config portchannel member add PortChannel0001 Ethernet0
config portchannel member add PortChannel0001 Ethernet4
show interfaces portchannel

Inter-Rack Routing: RIFs and BGP

config interface ip add Ethernet8 32.0.0.1/24
config interface ip add PortChannel0001 12.0.0.2/24
config interface ip add Vlan100 10.0.0.1/24
show ip interfaces
show ip route

Add BGP neighbors in the BGP_NEIGHBOR section of /etc/sonic/config_db.json (asn, holdtime, keepalive, local_addr), then sudo config reload -y and check show ip bgp summary. Redistribution of connected routes must be configured inside the FRR shell:

sonic# configure terminal
sonic(config)# router bgp 64002
sonic(config-router)# address-family ipv4 unicast
sonic(config-router-af)# redistribute connected
sonic(config-router)# end
sonic# write

With that, inter-rack traffic flows across your virtual fabric - a complete, free lab for learning SONiC network OS configuration.

Related Reading

原文链接:https://plvision.eu/blog/sdn/sonic-network-os-configuration