lost and found ( for me ? )

Ubuntu 13.10: use KVM and open vswitch GRE tunnel


Reference


Here is how to configure GRE tunnel on openvswitch.
# tail -1 /etc/lsb-release ;uname -ri
DISTRIB_DESCRIPTION="Ubuntu 13.10"
3.11.0-17-generic x86_64
root@ubuntu:~:# dpkg -l openvswitch-switch


+++-==============-============-============-=================================
ii  openvswitch-sw 1.10.2-0ubun amd64        Open vSwitch switch implementatio



VM1: 10.0.0.10
VM2: 10.0.0.20
KVM1 br2: 10.0.0.100
KVM2 br2: 10.0.0.200
KVM1 br0: 192.168.11.100
KVM2 br0: 192.168.11.44
VM1 gateway: 10.0.0.100
VM2 gateway: 10.0.0.200





configure GRE tunnel to have VM1(10.0.0.10) and VM2(10.0.0.20) communicate each other over GRE tunnel.


I have already set up openvswitch and associated br0 with eth0.
http://lost-and-found-narihiro.blogspot.jp/2014/02/ubuntu-1310-install-use-openvswitch.html


on the KVM1 host.
# ovs-vsctl add-br br2
# ifconfig br2 10.0.0.100 netmask 255.255.255.0
# ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=192.168.11.44


# ovs-vsctl show
41d09907-b8ac-4000-817c-41571e987aea
   Bridge "br2"
       Port "gre0"
           Interface "gre0"
               type: gre
               options: {remote_ip="192.168.11.44"}
       Port "br2"
           Interface "br2"
               type: internal
   Bridge "br0"
       Port "br0"
           Interface "br0"
               type: internal
       Port "eth0"
           Interface "eth0"
   ovs_version: "1.10.2"


# ifconfig br0 | grep 'inet'
         inetアドレス:192.168.11.100  ブロードキャスト:192.168.11.255  マスク:255.255.255.0



# ifconfig br2 | grep 'inet'
         inetアドレス:10.0.0.100  ブロードキャスト:10.0.0.255  マスク:255.255.255.0


on the KVM2 host
#  ovs-vsctl add-br br2
# ifconfig br2 10.0.0.200 netmask 255.255.255.0
# ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=192.168.11.100


# ovs-vsctl show
188ac705-d04f-42e1-b194-c90db8176629
   Bridge "br2"
       Port "gre0"
           Interface "gre0"
               type: gre
               options: {remote_ip="192.168.11.100"}
       Port "br2"
           Interface "br2"
               type: internal
   Bridge "br0"
       Port "br0"
           Interface "br0"
               type: internal
       Port "eth0"
           Interface "eth0"
   ovs_version: "1.10.2"


- VM1 ( KVM1 )


VM1 definition file
   <interface type='bridge'>
     <mac address=''/>
     <source bridge='br2'/>
     <virtualport type='openvswitch'>
     </virtualport>



# ifconfig eth0 | grep 'inet'
         inetアドレス:10.0.0.10  ブロードキャスト:10.0.0.255  マスク:255.255.255.0


# netstat -rn
カーネルIP経路テーブル
受信先サイト    ゲートウェイ    ネットマスク   フラグ   MSS Window  irtt インタフェース
0.0.0.0         10.0.0.100      0.0.0.0         UG        0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0





- VM2 ( KVM2 )


   <interface type='bridge'>
     <mac address=''/>
     <source bridge='br2'/>
     <virtualport type='openvswitch'>



ifconfig eth0 | grep inet
         inet addr:10.0.0.20  Bcast:10.0.0.255  Mask:255.255.255.0


# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.0.0.200      0.0.0.0         UG        0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0


send icmp packets to the VM2 from VM1.


# ping 10.0.0.20 -c 1
PING 10.0.0.20 (10.0.0.20) 56(84) bytes of data.
64 bytes from 10.0.0.20: icmp_seq=1 ttl=64 time=18.3 ms


--- 10.0.0.20 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 18.372/18.372/18.372/0.000 ms
root@ubuntu:~# ping 10.0.0.20 -c 4
PING 10.0.0.20 (10.0.0.20) 56(84) bytes of data.
64 bytes from 10.0.0.20: icmp_seq=1 ttl=64 time=24.1 ms
64 bytes from 10.0.0.20: icmp_seq=2 ttl=64 time=11.9 ms
64 bytes from 10.0.0.20: icmp_seq=3 ttl=64 time=7.88 ms
64 bytes from 10.0.0.20: icmp_seq=4 ttl=64 time=6.31 ms



arp table on the VM1
# arp -an
? (10.0.0.100) at 4e:b7:81:f6:c7:44 [ether] on eth0
? (10.0.0.20) at 52:54:00:04:16:21 [ether] on eth0


arp table on the VM2
# arp -an
? (10.0.0.200) at d2:55:99:61:8e:47 [ether] on eth0
? (10.0.0.10) at 52:54:00:1c:ca:06 [ether] on eth0


on the KVM1


n_packets and n_bytes are counting up.
# ovs-ofctl dump-flows br2
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=5800.189s, table=0, n_packets=395, n_bytes=39402, idle_age=0, priority=0 actions=NORMAL
#
# ovs-ofctl dump-flows br2
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=5801.861s, table=0, n_packets=399, n_bytes=39794, idle_age=0, priority=0 actions=NORMAL


on the KVM1
# ovsdb-tool show-log -m



record 47: 2014-02-25 15:43:29 "ovs-vsctl: ovs-vsctl add-br br2"
table Port insert row "br2" (d5f96248):
table Bridge insert row "br2" (f681b74d):
table Interface insert row "br2" (c66453e1):
table Open_vSwitch row 41d09907 (41d09907):


record 48: 2014-02-25 15:43:29
table Interface row "br2" (c66453e1):
table Open_vSwitch row 41d09907 (41d09907):


record 49: 2014-02-25 15:44:22 "ovs-vsctl: ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=192.168.11.44"
table Port insert row "gre0" (4dec49ac):
table Bridge row "br2" (f681b74d):
table Interface insert row "gre0" (4a98fd74):
table Open_vSwitch row 41d09907 (41d09907):


record 50: 2014-02-25 15:44:22
table Interface row "gre0" (4a98fd74):
table Open_vSwitch row 41d09907 (41d09907):


record 51: 2014-02-25 15:53:35 "ovs-vsctl: ovs-vsctl --timeout=5 -- --may-exist add-port br2 vnet0 -- set Interface vnet0 "external-ids:attached-mac=\"52:54:00:1c:ca:06\"" -- set Interface vnet0 "external-ids:iface-id=\"3a76a16f-3478-47b9-8783-798b655a6f6c\"" -- set Interface vnet0 "external-ids:vm-id=\"3f81fba0-7a06-3329-1f4a-516faaf35525\"" -- set Interface vnet0 external-ids:iface-status=active"
table Port insert row "vnet0" (dec63ba3):
table Interface insert row "vnet0" (07f7d36d):
table Bridge row "br2" (f681b74d):
table Open_vSwitch row 41d09907 (41d09907):


record 52: 2014-02-25 15:53:35
table Interface row "vnet0" (07f7d36d):
table Open_vSwitch row 41d09907 (41d09907):



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.