我正在尝试与Linux的vxlan ,这个问题已经让我坚持了几天。
简单的vxlan与muticast适用于跨主机通信,这只需创build一个vxlan vtep并分配一个ip地址:
ip link add vxlan100 type vxlan id 100 group 239.1.1.1 dev enp0s8 ip addr add 10.20.1.2/24 dev vxlan100 ip link set vxlan100 up
在两台主机上运行上述命令后,拓扑如下:
这工作正常!
然后我尝试设置桥接vxlan,连接容器与vxlan,它不起作用。 以下是我设置bridge和vxlan的过程:
ip link add br0 type bridge ip link add vxlan100 type vxlan id 100 group 239.1.1.1 dev enp0s8 ip link set dev vxlan100 master br0 ip link set vxlan100 up ip link set br0 up
至于vms /容器,我只是使用networking命名空间和veth peer来testing目的:
ip link add veth0 tyep veth peer name veth1 ip link set dev veth0 master br0 ip link set veth0 up ip netns add container1 ip link set dev veth1 netns container1 ip netns exec container1 ip link set lo up ip netns exec contianer1 ip link set veth1 name eth0 ip netns exec container1 ip addr add 10.20.1.2/24 dev eth0 ip netns exec container1 ip link set eth0 up
而且拓扑结构如下图所示:
当我尝试从VM1 ping VM2时,它打印出目标Host Unreachable错误:
[root@localhost ~]# ip netns exec container2 ping -c 3 10.20.1.3 PING 10.20.1.3 (10.20.1.3) 56(84) bytes of data. From 10.20.1.2 icmp_seq=1 Destination Host Unreachable From 10.20.1.2 icmp_seq=2 Destination Host Unreachable From 10.20.1.2 icmp_seq=3 Destination Host Unreachable --- 10.20.1.3 ping statistics --- 3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 1999ms
使用tcpdump捕获br0上的数据包,结果是:
[root@localhost vagrant]# tcpdump -e -nn -i br0 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on br0, link-type EN10MB (Ethernet), capture size 65535 bytes 15:35:02.533609 0e:f3:f2:c1:9a:b5 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.20.1.3 tell 10.20.1.2, length 28 15:35:02.533609 0e:f3:f2:c1:9a:b5 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.20.1.3 tell 10.20.1.2, length 28 15:35:02.534184 76:c2:07:e6:c2:7b > 0e:f3:f2:c1:9a:b5, ethertype ARP (0x0806), length 42: Reply 10.20.1.3 is-at 76:c2:07:e6:c2:7b, length 28 15:35:03.534274 0e:f3:f2:c1:9a:b5 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.20.1.3 tell 10.20.1.2, length 28 15:35:03.534274 0e:f3:f2:c1:9a:b5 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.20.1.3 tell 10.20.1.2, length 28 15:35:03.535261 76:c2:07:e6:c2:7b > 0e:f3:f2:c1:9a:b5, ethertype ARP (0x0806), length 42: Reply 10.20.1.3 is-at 76:c2:07:e6:c2:7b, length 28 15:35:04.536105 0e:f3:f2:c1:9a:b5 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.20.1.3 tell 10.20.1.2, length 28 15:35:04.536105 0e:f3:f2:c1:9a:b5 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.20.1.3 tell 10.20.1.2, length 28 15:35:04.536696 76:c2:07:e6:c2:7b > 0e:f3:f2:c1:9a:b5, ethertype ARP (0x0806), length 42: Reply 10.20.1.3 is-at 76:c2:07:e6:c2:7b, length 28 ^C 9 packets captured 9 packets received by filter 0 packets dropped by kernel
如输出所示,ARP请求是在vxlan中发送的,并获得对br0的响应,但桥不会将其转发给VM1 。 有两个问题我完全不明白:
br0不能将ARP响应转发给VM1 ,即使目标MAC地址恰好是VM1 ? 为了您的参考,我正在阅读vincent bernat的2017年vxlan linux发布 。
不知道我做错了什么,或者错过了一些configuration。 真的需要一个解决scheme或debugging提示。