Configure a node as a switch that supports vlan


  sudo apt-get install bridge-utils

  sudo apt-get install vlan







from import Mininet

from mininet.node import Controller, RemoteController, OVSKernelSwitch, OVSLegacyKernelSwitch, UserSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from import Link, TCLink


def topology():

    "Create a network."

    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"

    h1 = net.addHost( 'h1', mac='00:00:00:00:00:01')

    h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='' )

    h3 = net.addHost( 'h3', mac='00:00:00:00:00:03', ip='' )

    h4 = net.addHost( 'h4', mac='00:00:00:00:00:04', ip='' )

    h5 = net.addHost( 'h5', mac='00:00:00:00:00:05', ip='' )

    c7 = net.addController( 'c7', controller=RemoteController, ip='', port=6633 )

    print "*** Creating links"

    Link(h1, h2)

    Link(h1, h3, intfName1='h1-eth1')

    Link(h1, h4, intfName1='h1-eth2')

    Link(h1, h5, intfName1='h1-eth3')

    h1.cmd("sudo ifconfig h1-eth0 0")

    h1.cmd("sudo ifconfig h1-eth1 0")

    h1.cmd("sudo ifconfig h1-eth2 0")

    h1.cmd("sudo ifconfig h1-eth3 0")

    h1.cmd("sudo brctl addbr brvlan10")

    h1.cmd("sudo brctl addif brvlan10 h1-eth0")

    h1.cmd("sudo brctl addif brvlan10 h1-eth1")

    h1.cmd("sudo ifconfig brvlan10 up")

    h1.cmd("sudo brctl addbr brvlan20")

    h1.cmd("sudo brctl addif brvlan20 h1-eth2")

    h1.cmd("sudo brctl addif brvlan20 h1-eth3")

    h1.cmd("sudo ifconfig brvlan20 up")


    print "*** Running CLI"

    CLI( net )

    print "*** Stopping network"



if __name__ == '__main__':

    setLogLevel( 'info' )







Dr. Chih-Heng Ke (

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan