Skip to content

Configuration

Taoyu Li edited this page Sep 23, 2017 · 27 revisions

SONiC is managing configuration in a single source of truth - a redisDB instance that we refer as ConfigDB. Applications subscribe to ConfigDB and generate their running configuration correspondingly.

(Before Sep 2017, we were using an xml file named Minigraph to configure SONiC devices. For historical documentation, please refer to Configuration with Minigraph)

Config Load and Save

In current version of SONiC, ConfigDB is implemented as database 4 of local redis. When system boots, configurations will be loaded from /etc/sonic/config_db.json file into redis. Please note that ConfigDB content won't be written back into /etc/sonic/config_db.json file automatically. In order to do that, a config save command need to be manually executed from CLI. Similarly, config load will trigger a force load of json file into DB.

We keep a way to load configuration from minigraph and write into ConfigDB for backward compatibility. To do that, run config load_minigraph.

Incremental Configuration

The design of ConfigDB supports incremental configuration - application could subscribe to changes in ConfigDB and response correspondingly. However, this feature is not implemented by all applications yet. By Sep 2017 now, the only application that supports incremental configuration is BGP (docker-fpm-quagga). For other applications, a manual restart is required after configuration changes in ConfigDB.

Json Schema and DB Schema

A sample config_db.json file is available at here.

Device Metadata

The DEVICE_METADATA table contains only one object named localhost. In this table the device metadata such as hostname, hwsku, deployment envionment id and deployment type are specified. BGP local AS number is also specified in this table as current only single BGP instance is supported in SONiC.

    "DEVICE_METADATA": {
        "localhost": {
            "bgp_asn": 65100,
            "deployment_id": null,
            "hostname": "switch1",
            "type": "LeafRouter",
            "hwsku": "Force10-S6000"
        }
    },

Port

In this table the physical port configurations are defined. Each object will have port name as its key, and port name alias and port speed as optional attributes.

    "PORT": {
        "Ethernet0": {
            "alias": "fortyGigE0/0",
            "speed": "40000"
        },
        "Ethernet4": {
            "alias": "fortyGigE0/4"
        },
        "Ethernet8": {
            "alias": "fortyGigE0/8"
        },
        ...
    }
    "INTERFACE": {
        "Ethernet0|10.0.0.0/31": {},
        "Ethernet4|10.0.0.2/31": {},
        "Ethernet8|10.0.0.4/31": {},
        ...
    }
    "PORTCHANNEL_INTERFACE": {},
    "VLAN_INTERFACE": {},
    "MGMT_INTERFACE": {
        "eth0|10.3.147.195/23": {
            "forced_mgmt_routes": [
                "10.3.145.98/31", 
                "10.3.145.0/24", 
                "100.127.20.16/28", 
                "10.3.149.170/31", 
                "40.122.216.24", 
                "13.91.48.226", 
                "10.20.6.16", 
                "10.20.8.128/25", 
                "10.64.5.5"
            ], 
            "gwaddr": "10.3.146.1"
        }
    }
    "LOOPBACK_INTERFACE": {
        "Loopback0|10.1.0.32/32": {}, 
        "Loopback0|FC00:1::32/128": {}
    }, 
    "ACL_TABLE": {},
    "MIRROR_SESSION": {
        "everflow0": {
            "src_ip": "10.1.0.32",
            "dst_ip": "2.2.2.2"
        }
    },

    "PORTCHANNEL": {},
    "MGMT_INTERFACE": {},
    "DHCP_SERVER": {},
    "SYSLOG_SERVER": {},
    "NTP_SERVER": {
        "2.debian.pool.ntp.org": {},
        "1.debian.pool.ntp.org": {},
        "3.debian.pool.ntp.org": {},
        "0.debian.pool.ntp.org": {}
    },
    "DEVICE_NEIGHBOR": {
        "ARISTA04T1": {
            "mgmt_addr": "10.64.246.163", 
            "hwsku": "Arista", 
            "lo_addr": null, 
            "local_port": "Ethernet124", 
            "type": "LeafRouter", 
            "port": "Ethernet1"
        }, 
        "ARISTA03T1": {
            "mgmt_addr": "10.64.246.162", 
            "hwsku": "Arista", 
            "lo_addr": null, 
            "local_port": "Ethernet120", 
            "type": "LeafRouter", 
            "port": "Ethernet1"
        }, 
        "ARISTA02T1": {
            "mgmt_addr": "10.64.246.161", 
            "hwsku": "Arista", 
            "lo_addr": null, 
            "local_port": "Ethernet116", 
            "type": "LeafRouter", 
            "port": "Ethernet1"
        }, 
        "ARISTA01T1": {
            "mgmt_addr": "10.64.246.160", 
            "hwsku": "Arista", 
            "lo_addr": null, 
            "local_port": "Ethernet112", 
            "type": "LeafRouter", 
            "port": "Ethernet1"
        }
    }
    "BGP_NEIGHBOR": {
        "10.0.0.61": {
            "local_addr": "10.0.0.60",
            "asn": 64015,
            "name": "ARISTA15T0"
        },
        "10.0.0.49": {
            "local_addr": "10.0.0.48",
            "asn": 64009,
            "name": "ARISTA09T0"
        },
Clone this wiki locally