1. topo
vm1 vm2 vm3 vm4
ovs1 ovs2
2. 目的
VM1与VM3通过vxlan通信。 Vxlan的网段为192.168.1.X .
VM网段为10.1.2.X .
Br1 承载 vxlan , br2用于OVS内部交换
3. OVS 1 配置
ovs-vsctl add-br br1
ovs-vsctl add-br br2
ovs-vsctl add-port br1 eth1
ifconfig eth1 0
ifconfig br1 192.168.1.11 netmask 255.255.255.0
route add default gw 192.168.1.1 br1
ifconfig br2 10.1.2.11 netmask 255.255.255.0
ovs-vsctl add-port br0 vx0 -- set interface vx0 type=vxlan options:remote_ip=192.168.1.10
root@ubuntu:/ # ovs-vsctl show
c0b053e5-e205-487e-866f-ef997253387e
Bridge "br1"
Port "br1"
Interface "br1"
type: internal
Port "eth1"
Interface "eth1"
Bridge "br2"
Port "vx1"
Interface "vx1"
type: vxlan
options: {remote_ip="192.168.1.10"}
Port "br2"
Interface "br2"
type: internal
Port "vnet0"
Interface "vnet0"
4. OVS2配置:
ovs-vsctl add-br br1
ovs-vsctl add-br br2
ovs-vsctl add-port br1 eth1
ifconfig eth1 0
ifconfig br1 192.168.1.10 netmask 255.255.255.0
route add default gw 192.168.1.1 br1
ifconfig br2 10.1.2.10 netmask 255.255.255.0
ovs-vsctl add-port br0 vx0 -- set interface vx0 type=vxlan options:remote_ip=192.168.1.11
root@ubuntu4:/home /kvm# ovs-vsctl show
cad36a7b-dcde-4023-a7d6-b3778c334a07
Bridge "br1"
Port "eth1"
Interface "eth1"
Port "br1"
Interface "br1"
type: internal
Bridge "br2"
Port "vx0"
Interface "vx0"
type: vxlan
options: {remote_ip="192.168.1.11"}
Port "br2"
Interface "br2"
type: internal
Port "vnet0"
Interface "vnet0"
完成配置后,使用下面的命令可以查看学到的对端mac
root@ubuntu:/home# ovs-appctl fdb/show br2
port VLAN MAC Age
4 0 b6:0c:5b:f7:c7:43 206
2 0 d6:3a:2b:e5:58:41 158
5 0 52:54:00:99:7b:35 158
root@ubuntu:/home # ovs-appctl fdb/show br1
port VLAN MAC Age
3 0 00:25:86:90:1a:be 157
1 0 00:25:86:91:ef:eb 157
5. 报文分析
05:14:18.586153 IP (tos 0x0, ttl 64, id 34063, offset 0, flags [DF], proto UDP (17), length 78)
192.168.1.11.41728 > 192.168.1.10.8472: UDP, length 50
0x0000: 0025 8690 1abe 0025 8691 efeb 0800 4500 .%.....%......E.
0x0010: 004e 850f 4000 4011 322a c0a8 010b c0a8 .N..@.@.2*......
0x0020: 010a a300 2118 003a 0000 0800 0000 0000 ....!..:........
0x0030: 0000 ffff ffff ffff 5254 0099 7b35 0806 ........RT..{5..
0x0040: 0001 0800 0604 0001 5254 0099 7b35 0a01 ........RT..{5..
0x0050: 0264 0000 0000 0000 0a01 020a .d..........
图中udp数据就为vxlan数据。这个为arp请求报文,其中08 00 00 00 00 00 00为vxlan的报头。
05:14:18.586896 IP (tos 0x0, ttl 64, id 34064, offset 0, flags [DF], proto UDP (17), length 134)
192.168.1.11.43847 > 192.168.1.10.8472: UDP, length 106
0x0000: 0025 8690 1abe 0025 8691 efeb 0800 4500 .%.....%......E.
0x0010: 0086 8510 4000 4011 31f1 c0a8 010b c0a8 ....@.@.1.......
0x0020: 010a ab47 2118 0072 0000 0800 0000 0000 ...G!..r........
0x0030: 0000 b60c 5bf7 c743 5254 0099 7b35 0800 ....[..CRT..{5..
0x0040: 4500 0054 0000 4000 4001 223a 0a01 0264 E..T..@.@.":...d
0x0050: 0a01 020a 0800 ce59 0573 0001 f9a1 2451 .......Y.s....$Q
0x0060: 0000 0000 426c 0500 0000 0000 1011 1213 ....Bl..........
0x0070: 1415 1617 1819 1a1b 1c1d 1e1f 2021 2223 .............!"#
0x0080: 2425 2627 2829 2a2b 2c2d 2e2f 3031 3233 $%&'()*+,-./0123
0x0090: 3435 3637 4567
上图为ping request的情况。