This document describes how to use the Open vSwitch in different host allows two virtual machines communicate via the GRE tunnel based on the port.
Note :
This guide describes the steps required to GRE tunnel configuration. Any other tunneling protocol may be used to configure the same method Open vSwitch supports.
set up
This guide is assumed that the configuration environment as follows.
Two physical networks
-
Transport network
Ethernet network for communication between hosts running tunnels of OVS. Tunneling protocol (as used herein GRE) depends on being used, may need to modify some of the physical configuration of the switch (e.g., the need to adjust the MTU value). The physical configuration of the switching device is not within the scope of this discussion. -
Network Management
Strictly speaking, this network is not required, but it is an easy way to provide remote access to the physical host IP address, because the IP addresses can not be directly assigned as a member of the OVS bridge the physical interface.
Two physical hosts
The current environment is assumed that two named host1
and host2
hosts. Open vSwitch two hosts are running a hypervisor. Each host has two NIC, eth0
and `eth1``, configuration is as follows:
-
eth0
Connected to the transmission network.eth0
IP address for communicating with the host 2 through the transmission network. -
eth1
Connected to the management network.eth1
The IP address used to reach the physical host management.
Four virtual machines
Each host will run two virtual machines (VM). vm1
And vm2
running on the host host1
, while vm3
and vm4
run host2
.
Each virtual machine has a display device for Linux (e.g., on a physical host tap0
) single interface.
Note :
For Xen / XenServer, VM interfaces in the form of Linux device, similar to the name vif1.0
. Other Linux systems may treat these interfaces appear as vnet0
, vnet1
and so on.
Configuration Steps
Before you begin, you need to make sure to know the distribution host1
and host2
the eth0
IP address of the interface, as you will need during the configuration process.
In host1
the following configuration.
# Create OVS Bridge:
$ ovs-vsctl add-br br0
Note :
你不需要添加`eth0`到OVS网桥下.
# Start host1
on the host vm1
and vm2
if these two virtual machines do not automatically associated with the OVS, relating them to the OVS bridge you just created (the following command assumes that tap0
correspond vm1
and tap1
correspondence vm2
) ::
$ ovs-vsctl add-port br0 tap0
$ ovs-vsctl add-port br0 tap1
# Add a GRE tunnel port:
$ ovs-vsctl add-port br0 gre0 \
-- set interface gre0 type=gre options:remote_ip=<IP of eth0 on host2>
Using the same basic steps in host2
creating a mirror disposed on the host:
# Create OVS bridge, but the bridge is not adding any physical interfaces:
$ ovs-vsctl add-br br0
# Start host2
on the host vm3
and vm4
, if you need to add them to the OVS interface bridge (again, tap0
corresponding to vm3
and tap1
corresponds to vm4
) ::
$ ovs-vsctl add-port br0 tap0
$ ovs-vsctl add-port br0 tap1
# In host2
Create a GRE tunnel interface, this time at a specified remote_ip
time Remote IP address, use host1
the `` IP address eth0` interface:
$ ovs-vsctl add-port br0 gre0 \
-- set interface gre0 type=gre options:remote_ip=<IP of eth0 on host1>
test
Regardless of whether the virtual machine running on the same host or on different hosts, four virtual machines directly to the PING operation should be working properly.
Use ip route show
(or equivalent command), running inside a virtual machine operating system's routing table should not display any information used by hosts IP subnet, IP subnets configured to display only the virtual machine operating system. To help illustrate this point, it is best to use the host system is completely different IP subnets in the guest virtual machine.
Troubleshooting
If the connection between virtual machines on different hosts does not work, check the following items:
-
Ensuring
host1
andhost2
byeth0
(NIC connected to the transport network) connection to the network. This may require additional or IP routing IP routing rules. -
To ensure that
host1
thegre0
pointhost2
oneth0
andhost2
thegre0
point on the 'host1' ofeth0
. -
Make sure that all virtual machines are assigned IP addresses on the same subnet; this configuration does not require IP routing function.