SDN Lab with Ryu controller

Useful OpenvSwitch commands


  1. Add bridge
    sudo ovs-vsctl add-br ovs-br
  2. mapping interface
    sudo ovs-vsctl add-port ovs-br eth0
  3. 1+2
    sudo ovs−vsctl add−br ovs-br -- add−port ovs-br eth0
  4. Remove bridge
    sudo ovs-vsctl del-br ovs-br
  5. Remove bridge safety
    sudo ovs-vsctl --if-exists del-br ovs-br


  1. Set controller
    sudo ovs-vsctl set-controller ovs-br tcp:
  2. Set multi controller
    sudo ovs-vsctl set-controller ovs-br tcp: tcp:
  3. Remove controller
    sudo ovs-vsctl del-controller ovs-br

SDN version

  1. OpenFlow Version 1.3
    sudo ovs-vsctl set bridge ovs-br protocols=OpenFlow13
  2. OpenFlow Version 1.3 1.2
    sudo ovs-vsctl set bridge ovs-br protocols=OpenFlow12,OpenFlow13
  3. Remove
    sudo ovs-vsctl clear bridge ovs-br protocols

Dump flow

  1. Dumps OpenFlow flows without hidden flows
    sudo ovs-ofctl dump-flows ovs-br
  2. Dumps OpenFlow flows with hidden flows
    sudo ovs-appctl bridge/dump-flows ovs-br
  3. Dumps particular bridge's datapath flows
    sudo ovs-appctl dpif/dump-flows ovs-br
  4. Dumps Linux kernel datapath flow table
    sudo ovs-dpctl dump-flows [dp]


  1. Set VLAN tag
    sudo ovs-vsctl add-port ovs-br vlan3 tag=3 -- set interface vlan3 type=internal
  2. Remove VLAN tag
    sudo ovs-vsctl del-port ovs-br vlan3
  3. Set VLAN trunk (default allow all)
    sudo ovs-vsctl add-port ovs-br eth0 trunk=3,4,5,6
  4. Show switch port infomation
    sudo ovs-vsctl list port brLAN
  5. Set access port
    sudo ovs-vsctl set port brLAN trunk=3,4,5,6

Switch infomation

  1. Show switch setting
    sudo ovs-vsctl show
  2. Show switch port info
    sudo ovs-dpctl show

Lab 1: Source NAT

# This program was modified from and kevin's NAT.

Main purpose

cd /src3/KVM/ryu
PYTHONPATH=. ./bin/ryu-manager ../kevin/

Lab 2: Trunk

sudo ovs-vsctl add-br brLAN
sudo ovs-vsctl add-port brLAN eth0
sudo ovs-vsctl del-controller brWAN
sudo ovs-vsctl set-controller brLAN tcp:

Lab 3: Tunnel

QinQ, VLAN, VxLan, GRE, ...