您的位置:首页 > 运维架构

openvswitch创建vxlan隧道和gre隧道的mtu问题

2016-11-07 00:58 239 查看
先贴实验方法

Server1

ip netns add red
ip link add veth0 type veth peer name veth1
ip link set veth0 netns red
ip netns exec red ip li set lo up
ip netns exec red ip li set veth0 up
ip netns exec red ip addr add 10.1.1.1/24 dev veth0
ip netns exec red ip a

ovs-vsctl add-br br-int
ip li set br-int up
ovs-vsctl add-port br-int vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip=10.10.10.34

ovs-vsctl add-port br-int veth1
ip li set veth1 up
ovs-vsctl set port veth1 tag=10

ovs-vsctl del-port br-int vxlan0
ovs-vsctl add-port br-int gre0 -- set interface gre0 type=gre options:remote_ip=10.10.10.34

Server2
ip netns add red
ip link add veth0 type veth peer name veth1
ip link set veth0 netns red
ip netns exec red ip li set lo up
ip netns exec red ip li set veth0 up
ip netns exec red ip addr add 10.1.1.2/24 dev veth0
ip netns exec red ip a

ovs-vsctl add-br br-int
ip li set br-int up
ovs-vsctl add-port br-int vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip=10.10.10.66

ovs-vsctl add-port br-int veth1
ip li set veth1 up
ovs-vsctl set port veth1 tag=10

ovs-vsctl del-port br-int vxlan0
ovs-vsctl add-port br-int gre0 -- set interface gre0 type=gre options:remote_ip=10.10.10.66


上面的代码其实是在两台机器上分别创建了vxlan隧道和gre隧道进行测试,所以并不是一起执行的。

用iperf3进行tcp和udp打流测试,发现无法正常地通信。

网上一般的文章的做法都是修改客户机(本例来讲就是veth0)MTU值成1450甚至更小,或者用iperf3进行测速的时候手工设置更小的一个mss值,或者增大互联网卡设备及veth设备的MTU值。像openstack中neutron部分如果使用了vxlan的话,也需要在dhcp模块的配置文件中设置一个dhcp参数,以控制VM获取IP时自动设置减少mtu。但是这些做法在大规模网络或者公共互联网上做隧道的时候都有其局限性,为了在公共互联网上可能发生的问题,需要配合iptables在端点机器修改mss值。

从原理上进行分析,一个网卡一个网卡地进行抓包,会发现超过1500的数据包会被openvswitch或系统丢弃,并没有到互联网卡上,即:用tcpdump等抓包工具无法在互联网卡上抓到大包。

因为我们知道数据包中有一个DF标志位,进行跟踪抓包时发现其数据包中有df置位,即不允许分片,所以才会被丢弃。于是查openvswitch文档发现有参数: options:df_default=false,使用这个参数创建vtep设备,发现问题解决。

但是有一篇文章中说VXLAN协议规定不允许分片传输,不知道为什么。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: