[关闭]
@MatheMatrix 2017-04-18T05:34:49.000000Z 字数 2583 阅读 240

使用 Linux Bridge 搭建 VXLAN Overlay 网络

vxlan linux bridge


前言

使用 Linux Bridge 搭建 VXLAN 网络不是件很难的事,但是目前确实有一些小坑,这里记录一下。

本文会介绍:

本文不会介绍:

命令

没有多大难度,直接介绍使用的命令。

  1. iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
  2. # 在我的环境里总会有默认的两条 reject 规则,好烦,先干掉
  3. ip link add vxlan21 type vxlan id 100 dev eth0
  4. # 先添加 vxaln 接口,这个是最简洁的版本,你可以依照喜好添加一些参数,比如:
  5. # local 10.0.121.180,指定一个本地地址,linux 下的 VXLAN 接口可以不指定 IP 地址、网卡,也可以指定,看需要设置;
  6. # group 239.1.1.1 使用组播模式,239.1.1.1 即为组播地址;
  7. # dstport 4789 指定 vxlan 端口,如果不写的或者写 dspport 0 的话系统会自动使用 8472——根据 IANA 的[标准][1]现在应该使用 4789,包括 VMware NSX 6.2.3 开始也默认从 8472 该到了 4789;
  8. # srcport 32768 61000 可以指定源端口的范围;
  9. # 此外还有一些 DOVE Extension 带来的参数,放在后面介绍
  10. ip link set vxlan21 up
  11. # 将接口 UP,系统会起一个 UDP Socket 监听相应端口
  12. brctl addbr lb-int
  13. ip link set dev lb-int up
  14. brctl addif vxlan21
  15. brctl addif lb-int vxlan21
  16. bridge fdb append to 00:00:00:00:00:00 dev vxlan21 dst 10.0.56.18
  17. # 配置一个对端 VTEP
  18. ip link add veth20 type veth peer name veth02
  19. ip link set veth02 up
  20. brctl addif lb-int veth02
  21. ip netns add veth2
  22. # 创建 namespace 和 veth 设备模拟虚拟机
  23. ip link set dev veth20 netns veth2
  24. ip netns exec veth2 ip a add dev veth20 192.168.0.12/24
  25. ip netns exec veth1 ip link set veth20 up
  26. ip netns exec veth2 ping 192.168.0.11
  27. # 如果你在另一台 hypervisor(VTEP)做好了相应操作模拟了 192.168.0.11 地址,此时应该已经可以通讯了

DOVE Extension

DOVE 的全称是 Distributed Overlay Virtual Ethernet,是从 Linux 3.8 开始引入到内核,目的是方便为 Linux VXLAN 接入控制平面,提升效率。

引入 DOVE 后目前在创建 VXLAN 设备时可以添加下面几个参数:

当然了,我说的都是错的,我建议你还是直接看代码。

如果觉得看 vxlan.c 比较困难的话,可以看 DOVE 的 Patch:http://lists.openwall.net/netdev/2012/11/15/96

Reference

  1. Rami Cohen, et al: Distributed Overlay Virtual Ethernet (DOVE) integration with Openstack,
    IFIP/IEEE International Symposium on Integrated Network Management (IM 2013), 29-
    31-May-2013, pp 1088-1089

  2. Etsuji Nakai: How VXLAN works on Linux, https://www.slideshare.net/enakai/how-vxlan-works-on-linux

  3. Joe Julian: How to configure linux vxlans with multiple unicast endpoints, https://joejulian.name/blog/how-to-configure-linux-vxlans-with-multiple-unicast-endpoints/

  4. Thomas Richter: Software Defined Networking using VXLAN, LinuxCon Edinburgh 21-Oct-2013

  5. 刘世民: Neutron 理解(14):Neutron ML2 + Linux bridge + VxLAN 组网, http://www.cnblogs.com/sammyliu/p/4985907.html

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注