ovs 实验 vxlan gre

1. 实验环境:

virtual box 虚拟机两台,host-only 网卡一个,系统CentOS Linux release 7.4.1708 (Core) 

安装openvswitch

ovs 实验 vxlan gre_第1张图片

2. 配置vm1

ovs-vsctl add-br br0
ovs-vsctl add-br br1 
opvs-vsctl add-port br1 enp0s8
ovs-vsctl add-port br0 vx1 -- set interface vx1 type=vxlan options:remote_ip=1.1.1.2
ifconfig br0 11.1.1.1/24 up 
ifconfig br1 1.1.1.1/24 up 
#ip a 
3: enp0s8:  mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 08:00:27:76:e2:f3 brd ff:ff:ff:ff:ff:ff
4: ovs-system:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 5e:d2:fc:2d:09:e0 brd ff:ff:ff:ff:ff:ff
5: br0:  mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether 16:ad:32:28:95:4a brd ff:ff:ff:ff:ff:ff
    inet 11.1.1.1/24 brd 11.1.1.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::14ad:32ff:fe28:954a/64 scope link
       valid_lft forever preferred_lft forever
6: vxlan_sys_4789:  mtu 65470 qdisc noqueue master ovs-system state UNKNOWN qlen 1000
    link/ether ea:0b:2c:a7:ab:31 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::e80b:2cff:fea7:ab31/64 scope link
       valid_lft forever preferred_lft forever
7: br1:  mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether 08:00:27:76:e2:f3 brd ff:ff:ff:ff:ff:ff
    inet 1.1.1.1/24 brd 1.1.1.255 scope global br1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe76:e2f3/64 scope link
       valid_lft forever preferred_lft forever
[root@ovs-vm1 ~]# ovs-vsctl show
68de0632-ae7d-4f9b-a3c7-30a89a969f15
    Bridge "br0"
        Port "br0"
            Interface "br0"
                type: internal
        Port "vx1"
            Interface "vx1"
                type: vxlan
                options: {local_ip="1.1.1.1", remote_ip="1.1.1.2"}
    Bridge "br1"
        Port "br1"
            Interface "br1"
                type: internal
        Port "enp0s8"
            Interface "enp0s8"
    ovs_version: "2.5.0"
[root@ovs-vm1 ~]# ip -o -4 a
1: lo    inet 127.0.0.1/8 scope host lo\       valid_lft forever preferred_lft forever
2: enp0s3    inet 172.16.51.8/24 brd 172.16.51.255 scope global enp0s3\       valid_lft forever preferred_lft forever
5: br0    inet 11.1.1.1/24 brd 11.1.1.255 scope global br0\       valid_lft forever preferred_lft forever
7: br1    inet 1.1.1.1/24 brd 1.1.1.255 scope global br1\       valid_lft forever preferred_lft forever

3. 配置vm2

ovs-vsctl add-br br0
ovs-vsctl add-br br1 
opvs-vsctl add-port br1 enp0s8
ovs-vsctl add-port br0 vx1 -- set interface vx1 type=vxlan options:remote_ip=1.1.1.1
ifconfig br0 11.1.1.2/24 up 
ifconfig br1 1.1.1.2/24 up 
3: enp0s8:  mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 08:00:27:73:cd:4a brd ff:ff:ff:ff:ff:ff
4: ovs-system:  mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether a6:74:cc:c6:0f:75 brd ff:ff:ff:ff:ff:ff
5: vxlan_sys_4789:  mtu 65470 qdisc noqueue master ovs-system state UNKNOWN qlen 1000
    link/ether b2:0c:3d:58:5f:b7 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::b00c:3dff:fe58:5fb7/64 scope link
       valid_lft forever preferred_lft forever
6: br0:  mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether 2a:71:13:de:57:4f brd ff:ff:ff:ff:ff:ff
    inet 11.1.1.2/24 brd 11.1.1.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::2871:13ff:fede:574f/64 scope link
       valid_lft forever preferred_lft forever
7: br1:  mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether 08:00:27:73:cd:4a brd ff:ff:ff:ff:ff:ff
    inet 1.1.1.2/24 brd 1.1.1.255 scope global br1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe73:cd4a/64 scope link
       valid_lft forever preferred_lft forever
[root@ovs-vm2 ~]# ovs-vsctl show
68de0632-ae7d-4f9b-a3c7-30a89a969f15
    Bridge "br0"
        Port "vx1"
            Interface "vx1"
                type: vxlan
                options: {remote_ip="1.1.1.1"}
        Port "br0"
            Interface "br0"
                type: internal
    Bridge "br1"
        Port "br1"
            Interface "br1"
                type: internal
        Port "enp0s8"
            Interface "enp0s8"
    ovs_version: "2.5.0"
[root@ovs-vm2 ~]# ip -o -4 a
1: lo    inet 127.0.0.1/8 scope host lo\       valid_lft forever preferred_lft forever
2: enp0s3    inet 172.16.51.9/24 brd 172.16.51.255 scope global enp0s3\       valid_lft forever preferred_lft forever
6: br0    inet 11.1.1.2/24 brd 11.1.1.255 scope global br0\       valid_lft forever preferred_lft forever
7: br1    inet 1.1.1.2/24 brd 1.1.1.255 scope global br1\       valid_lft forever preferred_lft forever

3. vm1 11.1.1.1 ping 11.1.1.2

ovs 实验 vxlan gre_第2张图片

4. 抓包

tcpdump -i br1 -w vxlan11

5. 数据包分析

ovs 实验 vxlan gre_第3张图片

6.总结

vxlan数据结构

icmp原始报文封装+vxlan包头+udp包头+外部ip封装+外层mac封装,

icmp+ip header+Ethernet header + vxlan header + udp header + outer ip header + outer Ethernet header 

ovs 实验 vxlan gre_第4张图片


你可能感兴趣的:(openstack)