Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Let mininet nodes can connect to the internet
#!/usr/bin/env python
import os
from import Mininet
from mininet.node import Controller, RemoteController
from mininet.cli import CLI
from import Intf
from mininet.log import setLogLevel, info
def myNetwork():
net = Mininet( topo=None, build=False)
info( '*** Adding controller\n' )
info( '*** Add switches\n')
s1 = net.addSwitch('s1')
# Intf( 'eth0', node=s1 ) #Some Problem
info( '*** Add hosts\n')
h1 = net.addHost('h1', ip='')
h2 = net.addHost('h2', ip='')
info( '*** Add links\n')
net.addLink(h1, s1)
net.addLink(h2, s1)
info( '*** Starting network\n')
os.popen('ovs-vsctl add-port s1 eth0')
h1.cmdPrint('dhclient '+h1.defaultIntf().name)
h2.cmdPrint('dhclient '+h2.defaultIntf().name)
if __name__ == '__main__':
setLogLevel( 'info' )
Copy link

Yi-Tseng commented Aug 10, 2016

Line 18 should be work now?

Copy link

nux150 commented May 28, 2018

I have a problem in assigning a dhcp address to h1, when i try to run that script it just stuck in this line h1.cmdPrint('dhclient '+h1.defaultIntf().name) and i don't know the reason, can you plz help me to solve it? this issue is happening also when i try to do it manually from h1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment