Connecting two Mininet networks with GRE tunnel
September 11, 2013 19 Comments
Update1: I have a follow up post with some newer examples and extra which might help you debug any issues.
Update2: I have another post that show how to use Linux GRE tunnels instead of the OVS builtin GRE support. Seems more stable.
——-
I was wondering if there was a way to connect two separate Mininet networks, then a little while ago, I came across a post about OpenVSwitch and using GRE tunnels. So today, I thought I would try an experiment and try and connect two separate Mininet networks that are also running in separate VMs.
First, I started two Mininet networks in the separate VMs.
VM2(VirtualBox 192.168.56.102):
- host2
- switch2
I use the following mininet custom topology.
from mininet.topo import Topo class MyTopo( Topo ): "Simple topology example." def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches leftHost = self.addHost( 'h2' ) leftSwitch = self.addSwitch( 's2' ) # Add links self.addLink( leftHost, leftSwitch ) topos = { 'mytopo': ( lambda: MyTopo() ) }
Start the network.
sudo mn –custom ./simple.py –topo mytopo –switch ovsk
VM1 (VirtualBox 192.168.56.101):
- host1
- switch1
I use the following mininet custom topology.
from mininet.topo import Topo class MyTopo( Topo ): "Simple topology example." def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) # Add hosts and switches h1 = self.addHost( 'h1' ) s1 = self.addSwitch( 's1' ) # Add links self.addLink( h1, s1 ) topos = { 'mytopo': ( lambda: MyTopo() ) }
Start the VM and have it point to the controller in the other VM.
sudo mn --custom ./simple.py --topo mytopo --switch ovsk --controller=remote,ip=192.168.56.102,port=6633
But before I can connect them, I have to change the default IP address that the hosts get automatically configured with so that I do not get two hosts with 10.0.0.1. So I open an xterm in host2 and changed the IP address from the default assigned IP of 10.0.0.1 to 10.0.0.2.
ifconfig h2-eth0 inet 10.0.0.2
To make sure, I try and ping h1 from h2 from VM2 mininet CLI and it fails.
mininet> h2 ping -c 1 10.0.0.1 PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. From 10.0.0.2 icmp_seq=1 Destination Host Unreachable --- 10.0.0.1 ping statistics --- 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
Now we setup the tunnel between the switches.
VM1:
sudo ovs-vsctl add-port s1 s1-gre1 -- set interface s1-gre1 type=gre options:remote_ip=192.168.56.102
VM2:
sudo ovs-vsctl add-port s2 s2-gre1 -- set interface s2-gre1 type=gre options:remote_ip=192.168.56.101
And then I try the test again.
mininet> h2 ping -c 1 10.0.0.1 PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_req=1 ttl=64 time=0.044 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.044/0.044/0.044/0.000 ms
It was a fun test. Hope someone finds this useful. I hope to add the feature into my next version on MiniEdit.
Hi, I followed your step strictly but it didn’t work out.
When I
sudo ovs-vsctl add-port s1 s1-gre1 — set interface s1-gre1 type=gre options:remote_ip=x.x.x.x
I can see “s1-gre1” in “ovs-vsctl show”. But I cannot see it in “s1 ifconfig”.
Or is there any instructions on checkpoints for make it through?
Thanks!
No, you won’t see the GRE interface listed in ‘ifconfig’. You can check my latest post on the topic for more information that might help.
Pingback: Connecting two Mininet networks with GRE tunnel – Part 2 | Tech and Trains
Hi, can you explain, how switch s1 is talking to eth0 of mininet vm ? you have created tunnel between s1 on first mininet VM and interface of second mininet vm. but how packets are moving from s1 on first vm to eth0 of first VM ? I hope you got my question.
Hi,
you have created tunnel between ovs (s1) on 1st VM and eth0 of second VM. Can you explain how packet will move from s1 on 1st mininet VM to eth0 of same VM ? As i observed, you haven’t added eth0 into s1 bridge. so how they will talk ?
The tunnel is between the OVS on VM1 and the OVS on VM2. It is the tunnel endpoints that are added into the OVS bridges, not the VM eth interfaces. Once the traffic is in the tunnel, then it is up to the GRE tunnel packets to be routed between the source and destination OVS bridges. The GRE is acting as a virtual wire which be span the internet if needed.
Hi author!
consider me dumb but i am new to mininet and i have been given an assignment to make a connection between two different topologies. i found ur blog and i am gona follow these instructions but i dont know where to store/place your given python script(simple.py) or how to run it in mininet.
Any suggestion please?
Doesn’t matter what directory. As long as it is on the same system you are running mininet.
hello,
i am following your mentioned steps exactly and i have created 2 topologies on 2 different VMs, but when i execute this command i got an error every time.
mininet> sudo ovs-vsctl add-port s1 s1-gre1 — set interface s1-gre1 type=gre options:remote_ip=192.168.56.102
*** Unknown command: sudo ovs-vsctl add-port s1 s1-gre1 — set interface s1-gre1 type=gre options:remote_ip=192.168.56.102
mininet>
can you please help me in finding whats wrong happening here?
You don’t run it from within mininet. You run it from your regular command prompt.
hello again Gregory,
i got this thing working as you said. but now i have to connect 2 different switches which are in 2 different networks. but i cant use GRE Tunneling. because in GRE tunneling i am allowing 1 controller to access and control switch of another network. (e.g C1 can control switch of C2). i dont want this.
i was wondering is there any other way to connect 2 different switches.
i want this thing.
VM1:
H1—->S1…….>C1
vm2:
H2……>S2…….>C2
now H2 want to ping H1. how can i connect 2 switches so that the host can ping each other. any idea?
Hello Zafar I want to know if you found out a way to do this, because now I need to do the same but I haven’t found how yet.
I would appreciate if you could give me any ideas.
Are you able to get it working like above? How are you running each topology file? You shouldn’t have any problem with each switch having its own controller.
Were you able to connect two switches from two different networks through GRE tunneling? We are also facing the same problem. We want to connect the two switches from two different networks. It is possible through GRE tunneling.
Pingback: Connect two mininet – Mohit Ritolia
after executing sudo ovs-vsctl add-port s1 s1-gre1 — set interface s1-gre1 type=gre options:remote_ip=x.x.x.x .
I am getting ovs-vsctl: no bridge named s1
how to resolve this issue?
When I execute
sudo ovs-vsctl add-port s1 s1-gre1 — set interface s1-gre1 type=gre options:remote_ip=x.x.x.x
I get ovs-vsctl: no bridge named s1
How to resolve this issue?
Hi Gregory I have been trying to implement this, I am following your mentioned steps exactly, but I’ve got some issues.
– On VM1 When I execute: sudo ovs-vsctl add-port s1 s1-gre1 — set interface s1-gre1 type=gre options:remote_ip=x.x.x.x
I get ovs-vsctl: no bridge named s1
– On VM2 when I execute the same command I get: ovs-vsctl commando not found, but I don’t know why because it is the same command on VM1.
Can you tell me please how can I resolve this?
Hi,
What if i wanted to using 3 VM?