Skip to content

Instantly share code, notes, and snippets.

@shreyakupadhyay
Last active August 26, 2021 16:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shreyakupadhyay/84dc75607ec1078aca3129c8958f3683 to your computer and use it in GitHub Desktop.
Save shreyakupadhyay/84dc75607ec1078aca3129c8958f3683 to your computer and use it in GitHub Desktop.
Connecting mininet host with Internet.
<-- Commands below connects the mininet hosts to internet and also with other mininet hosts.-->
$ sudo mn --topo=single,2 (topology of consisting 1 switch and 2 hosts)
$ sudo ifconfig s1 up
$ sudo ovs-vsctl add-port s1 enp0s3(or your NAT interface of virtual machine)
$ ifconfig enp0s3 0
$ dhclient s1 (To get the IP address for s1. Till here VM will get the internet connectivity through OVS.)
mininet> xterm h1
h1> ifconfig h1-eth0 0
h1> dhclient h1-eth0 (This will give the IP address to host h1)
h1> exit
h2> ifconfig h2-eth0 0
h2> dhclient h2-eth0 (This will give the IP address to host h2. h2 will be in the same network as h1).
mininet> h1 ping -c 10 google.com
mininet> h1 ping h2
mininet> h2 ping h1 (This will update the rules in OVS.)
@lowkeyboard
Copy link

lowkeyboard commented Dec 22, 2020

could you help? how can i change and find my port because enp0s3 is not working
"ovs-vsctl: cannot create a port named enp0s3 because a port named enp0s3 already exists on bridge s1"

@shreyakupadhyay
Copy link
Author

Hey @lowkeyboard, I worked on this long back but still I may be able to help you. enp0s3 is specific to your operating system, instead you can use any other wifi interface which is as per your OS. Let me know if it helps.

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