Configuring SVI

Introduction

A Switched Virtual Interface (SVI) is a VLAN of switch ports represented by a single interface to a routing system. The SVI provides Layer 3 packet processing to route traffic to other Layer 3 interfaces, representing additional broadcast domains. The mapping between a VLAN and an SVI is one-to-one, meaning that only one SVI can be mapped to a VLAN.

SVIs are generally configured for a VLAN for the following reasons: 1

  • Allow traffic to be routed between VLANs by providing a default gateway for the VLAN.
  • Provide fallback bridging (if required for non-routable protocols).
  • Provide Layer 3 IP connectivity to the switch.
  • Support bridging configurations and routing protocol.

SVIs advantages include: 1

  • Much faster than router-on-a-stick, because everything is hardware-switched and routed.
  • No need for external links from the switch to the router for routing.
  • Not limited to one link. Layer 2 EtherChannels can be used between the switches to get more bandwidth.
  • Latency is much lower, because it does not need to leave the switch

Sample SVI Topology

Prerequisites

  • A VLAN that is not already associated with an SVI

Configuring SVI Using the FlexSwitch CLI

For more information about how to use the CLI, see Accessing the Command Line.

In the following steps we will create two SVIs on two different switches and test the connectivity.

VLAN Verification

Use the following CLI command to verify that the VLAN exists.

localhost(config)#show vlan

If the VLAN exists, the following response is displayed.

Applying Show:

 VLAN    Name    Status    Ports
------------------
sdk:printCombinedVlanStates() result: SUCCESS

Attaching A Tagged VLAN to a Port

Use the CLI commands shown in the example below to attach vlan 20 to the fpPort 1 port.

localhost(config)#interface fpPort 1
localhost(config-if-eth-1)#vlan 20
localhost(config-if-eth-1)#apply

Applying Config:
[63599.080000] rtnetlink_event: fpPort1.20: ifindex 62 admin UP operstate UP
[63599.080000] device fpPort1.20 entered promiscuous mode
[63599.090000] device fpPort1 entered promiscuous mode
[63599.100000] rtnetlink_event: vlan20: ifindex 61 admin UP operstate UP
id: 7   object: Vlan   status: APPLIED CONFIG  valid: True delete: False num user cmds: 2
 command               attr      value    model attr    iskey    required    userprov    time provisioned
------------------------------------------------------------------------------------------------------------------
 interface fpPort 1    fpPort    ['1']    IntfList      True     X           X           Sun Nov 20 13:11:06 2033
 vlan 20               vlan      20       VlanId        True     X           X           Sun Nov 20 13:15:16 2033

sdk:updateVlan(20,UntagIntfList=[],AdminState=UP,IntfList=['fpPort1'],Description=none,AutoState=UP) result: SUCCESS: http status code: 200

Creating the SVI

Use the CLI commands shown in the example below to create an SVI with an IP address of 1.1.1.21/30.

localhost(config)#interface vlan 20
localhost(config-if-vlan-20)#ip address 1.1.1.21/30
localhost(config-if-vlan-20-ip-1.1.1.21/30)#no shut
localhost(config-if-vlan-20-ip-1.1.1.21/30)#apply
Applying Config:
id: 4   object: IPv4Intf   status: APPLIED CONFIG  valid: True delete: False num user cmds: 3
 command                   attr        value          model attr    iskey    required    userprov    time provisioned
------------------------------------------------------------------------------------------------------------------------------
 interface vlan 20         vlan        20             IntfRef       True     X           X           Sun Nov 20 13:28:10 2033
 ip address 1.1.1.21/30    address     1.1.1.21/30    IpAddr        True     X           X           Sun Nov 20 13:28:10 2033
 no shutdown UP            shutdown    UP             AdminState    False                X           Sun Nov 20 13:28:13 2033

sdk:createIPv4Intf(vlan20,1.1.1.21/30,AdminState=UP) result: SUCCESS: http status code: 201

Verifying the SVI Status

Use the CLI commands shown in the example below to verify the status of the SVI .

localhost#show ip interface vlan 20
Applying Show:
---------------------------------------------------------------------------------------------------------------------------------------------------
 IntfRef    IfIndex     IpAddr         OperState    NumUpEvents    LastUpEventTime    NumDownEvents    LastDownEventTime    L2IntfType    L2IntfId
---------------------------------------------------------------------------------------------------------------------------------------------------
 vlan20     33554452    1.1.1.21/30    UP           0                                 0                                     vlan          20
sdk:printIPv4IntfState(vlan20,) result: SUCCESS


############################################################################################################################################################

Configuring SVI Using the FlexSwitch REST (cURL) Interface

In the following set of examples we will create the same SVIs as in the CLI examples shown above.

VLAN Verification

The following example shows that no VLANs exist.

bash-4.3$ curl -k -u user:password -sX GET --header 'Accept: application/json' -d '{}' 'https://localhost:443/public/v1/state/Vlans' | python -m json.tool
{
    "CurrentMarker": 0,
    "MoreExist": false,
    "NextMarker": 0,
    "ObjCount": 0,
    "Objects": []
}

Creating the VLAN

Use the following REST request (POST) to create a VLAN _ (Vlan20)_.

bash-4.3$ curl -k -u user:password -sX POST --header 'Accept: application/json' -d '{"VlanId":20}' 'https://localhost:443/public/v1/config/Vlan' | python -m json.tool

  {
      "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
      "Access-Control-Allow-Methods": "POST, GET, OPTIONS, PATCH, DELETE",
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Max_age": "86400",
      "ObjectId": "c5bfccd9-a416-4faa-490a-2c7e032e373e",
      "Result": "Success"
  }
 ```
Use the following REST Request (PATCH) to assign _Vlan20_ to the _fpPort1_ port.

```bash
bash-4.3$ curl -k -u user:password -sX PATCH --header 'Accept: application/json' -d '{"VlanId":20,"IntfList":["fpPort1"]}' 'https://localhost:443/public/v1/config/Vlan' | python -m json.tool
  {
      "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
      "Access-Control-Allow-Methods": "POST, GET, OPTIONS, PATCH, DELETE",
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Max_age": "86400",
      "ObjectId": "c5bfccd9-a416-4faa-490a-2c7e032e373e",
      "Result": "Success"
  }  

Verifying the VLAN-Port Association

Use the following REST request (GET) to verify that Vlan20 is attached to the fpPort1 port.

  bash-4.3$ curl -k -u user:password -sX GET --header 'Accept: application/json' -d '{"VlanId":20}' 'https://localhost:443/public/v1/config/Vlan' | python -m json.tool
  {
      "Object": {
          "AdminState": "UP",
          "AutoState": "UP",
          "Description": "none",
          "IntfList": [
              "fpPort1"
          ],
          "UntagIntfList": [],
          "VlanId": 20
      },
      "ObjectId": "c5bfccd9-a416-4faa-490a-2c7e032e373e"
  }

Verifying the State of the VLAN

Use the following REST request (GET) to verify the state of the Vlan.

Note

Notice that the endpoint is /state/Vlans/ instead of /config/Vlan.

bash-4.3$ curl -k -u user:password -sX GET --header 'Accept: application/json' -d '{}' 'https://localhost:443/public/v1/state/Vlans' | python -m json.tool
  {
      "CurrentMarker": 0,
      "MoreExist": false,
      "NextMarker": 4096,
      "ObjCount": 1,
      "Objects": [
          {
              "Object": {
                  "IfIndex": 33554452,
                  "Name": "vlan20",
                  "OperState": "UP",
                  "SysInternalDescription": "",
                  "VlanId": 20
              },
              "ObjectId": "c5bfccd9-a416-4faa-490a-2c7e032e373e"
          }
      ]
  }

Creating the SVI

Use the following REST request (POST) to create the SVI and assign an IP address of 1.1.1.21/30.

bash-4.3$ curl -k -u user:password -sX POST --header 'Accept: application/json' -d '{"IntfRef":"vlan20","IpAddr":"1.1.1.21/30"}' 'https://localhost:443/public/v1/config/IPv4Intf' | python -m json.tool
  {
      "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
      "Access-Control-Allow-Methods": "POST, GET, OPTIONS, PATCH, DELETE",
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Max_age": "86400",
      "ObjectId": "0d0af957-04ce-4f21-45e9-90fdb98bb07c",
      "Result": "Success"
  }

Verifying the SVI Creation

Use the following REST request (GET) to verify that the SVI was successfully created.

bash-4.3$ curl -k -u user:password -sX GET --header 'Accept: application/json' -d '{"IntfRef":"vlan20","IpAddr":"1.1.1.21/30"}' 'https://localhost:443/public/v1/config/IPv4Intf' | python -m json.tool
  {
      "Object": {
          "AdminState": "UP",
          "IntfRef": "vlan20",
          "IpAddr": "1.1.1.21/30"
      },
      "ObjectId": "0d0af957-04ce-4f21-45e9-90fdb98bb07c"
  }

References

[1] https://en.wikipedia.org/wiki/Switch_virtual_interface