简体   繁体   中英

Connecting VMs Using GRE Tunnels - Openvswitch

Hello everyone i'm really new in networking, so i i'm a little bit lost please i hope anyone can help me...

I have two physical nodes with the same configuration in the interface:

# The primary network interface
#auto eth0
#iface eth0 inet dhcp

auto br0
    iface br0 inet dhcp
    bridge_ports eth0
    bridge_fd 9
    bridge_hello 2
    bridge_maxage 12
    bridge_stp off

my nodes have the following public ip:
ubuntu001: 158.42.104.129
ubuntu002: 158.42.104.139

I run one VM in each node using the default configuration of libvirt:
Vm in ubuntu001: 10.1.1.189
Vm in ubuntu002: 10.1.1.59

I want to do ping between the VMs through "gre tunnel using OVS", so i did the next but it didn't work:

First i create an OVS bridge:
# ovs-vsctl add-br ovs-br0

Second i connect my bridge with its uplink which in this case is eth0
# ovs-vsctl add-port ovs-br0 eth0

Third i run a VM in each node (ubuntu001: 10.1.1.189 and ubuntu002: 10.1.1.59 respectively)

Fourth i add a port for the GRE tunnel:
# ovs-vsctl add-port ovs-br0 gre0 -- set interface gre0 type=gre options:remote_ip=158.42.104.139 # ovs-vsctl add-port ovs-br0 gre0 -- set interface gre0 type=gre options:remote_ip=158.42.104.129

i did the same in the other node and this show when i use ovs-vsctl show:

root@ubuntu001:~# ovs-vsctl show
    41268e02-3996-4caa-b941-e4fe9c718e35
    Bridge "ovs-br0"
       Port "ovs-br0"
          Interface "ovs-br0"
              type: internal
       Port "gre0"
          Interface "gre0"
              type: gre
              options: {remote_ip="158.42.104.139"}
       Port "eth0"
          Interface "eth0"
       ovs_version: "2.0.2"

root@ubuntu002:~# ovs-vsctl show
    f0128df4-1a89-4999-8add-b5076ff055ee
    Bridge "ovs-br0"
       Port "ovs-br0"
          Interface "ovs-br0"
              type: internal
       Port "gre0"
          Interface "gre0"
              type: gre
              options: {remote_ip="158.42.104.129"}
       Port "eth0"
          Interface "eth0"
       ovs_version: "2.0.2"

what i am doing wrong or is missing something??

Add this to /etc/network/interfaces :

auto br-ovs=br-ovs
iface br-ovs inet manual
    ovs_type OVSBridge
    ovs_ports gre1 gre2
    ovs_extra set bridge ${IFACE} stp_enable=true
    mtu 1462

allow-br-ovs gre1
iface gre1 inet manual
    ovs_type OVSPort
    ovs_bridge br-ovs
    ovs_extra set interface ${IFACE} type=gre options:remote_ip=158.42.104.139 options:key=1

auto br1
iface br1 inet manual# (or static, or DHCP)
    mtu 1462   

I do not know how to do this with commands.

I think eth0 should not be in the output of ovs-vsctl show .

stp_enable=true is optional, I don't think it is needed in case of 2 nodes.

Set mtu to suit your needs. This example is for when the real NIC's mtu is 1500.

remote_ip=158.42.104.139 should contain the other node's IP. It is different on the 2 nodes.

options:key=1 is also optional, it can be used to label 2 GRE networks (eg. the second mesh would have key=2 etc.).

You can add VMs to br1 and they will be able to ping each other.

Don't forget to set the VMs' mtu to 1462.

This tutorial might be useful: https://wiredcraft.com/blog/multi-host-docker-network/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM