Testing virtual interface inside an open virtual swich distributed in two hosts with a GRE / VxLAN tunnel

12 09 2016

– First of all, enable ip forward:

echo 1 > /proc/sys/net/ipv4/ip_forward

– Install open virtual swich:

apt-get install openvswitch-switch

– Create the virtual ethernet interface, a veth pair, and bring one side up:

ip link add veth0 type veth peer name veth1
ip link set veth0 up

– Create the bridge inside the ovs (open virtual swich):

ovs-vsctl add-br br0

– Include the veth0 into the bridge:

ovs-vsctl add-port br0 veth0

– Create the gre tunnel from this hots to the remote, change “remote_ip” to the remote ip addres. Take one option, GRE or VxLAN:

Using GRE:
ovs-vsctl add-port br0 gre0 -- set interface gre0 type=gre options:remote_ip=10.10.10.1Using VxLAN:
ovs-vsctl add-port br10 vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip=10.10.10.1

– Create the namespace and include the other side of the veth interface:

ip netns add green
ip link set veth1 netns green

– Assign an IP address to the interface inside the namespace, and bring it up, the same for lo:

ip netns exec green ifconfig veth1 192.168.1.1/24 up
ip netns exec green ip link set dev lo up

– Repeat this process in the remote hosts assigning the correct “remote_ip” and a different “veth1” ip (in this example 192.168.1.2).

– Test conectivity between the different hosts:

Host 1:
ip netns exec green ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.597 m

ip netns exec green traceroute 192.168.1.1
traceroute to 192.168.1.1 (192.168.1.1), 30 hops max, 60 byte packets
1 * 192.168.1.1 (192.168.1.1) 0.635 ms *

Host 2:
ip netns exec green ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.408 ms

ip netns exec green traceroute 192.168.1.2
traceroute to 192.168.1.2 (192.168.1.2), 30 hops max, 60 byte packets
1 192.168.1.2 (192.168.1.2) 1.287 ms 1.071 ms 1.056 ms

– The command “ovs-vsctl show” report the status of the ovs:

GRE:
ce14f19a-978d-47f9-83a9-f00f2f1655f4
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
Port "gre0"
Interface "gre0"
type: gre
options: {remote_ip="192.168.1.1"}
Port "veth0"
Interface "veth0"
ovs_version: "2.3.0"

VxLAN:
ce14f19a-978d-47f9-83a9-f00f2f1655f4
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
Port "vxlan0"
Interface "vxlan0"
type: vxlan
options: {remote_ip="192.168.1.1"}
Port "veth0"
Interface "veth0"
ovs_version: "2.3.0"

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: