Open laik opened 2 years ago
// host1 10.102.126.141
ip link add vxlan0 type vxlan id 42 dstport 4789 local 10.102.126.141 group 239.1.1.1 dev eth0
ip link add br0 type bridge
ip link set vxlan0 master br0
ip link set vxlan0 up
ip link set br0 up
ip link add veth0 type veth peer name veth1 mtu 1400
ip link set veth0 mtu 1400
ip link set dev veth0 master br0
ip link set dev veth0 up
ip netns add ns0
ip link set dev veth1 netns ns0
ip netns exec ns0 ip link set lo up
ip netns exec ns0 ip link set veth1 name eth0
ip netns exec ns0 ip addr add 10.20.1.2/24 dev eth0
ip netns exec ns0 ip link set eth0 up
//host2 10.102.126.146
ip link add vxlan0 type vxlan id 42 dstport 4789 local 10.102.126.146 group 239.1.1.1 dev eth0
ip link add br0 type bridge
ip link set vxlan0 master br0
ip link set vxlan0 up
ip link set br0 up
ip link add veth0 type veth peer name veth1 mtu 1400
ip link set veth0 mtu 1400
ip link set dev veth0 master br0
ip link set dev veth0 up
ip netns add ns0
ip link set dev veth1 netns ns0
ip netns exec ns0 ip link set lo up
ip netns exec ns0 ip link set veth1 name eth0
ip netns exec ns0 ip addr add 10.20.1.3/24 dev eth0
ip netns exec ns0 ip link set eth0 up
ip netns exec ns0 ping -c 2 10.20.1.2
// clean
ip link del dev vxlan0
ip netns del ns0
ip link del veth0
ip link del br0
root@10-102-126-146:/# ip netns exec ns0 ping -c 2 10.20.1.2
PING 10.20.1.2 (10.20.1.2) 56(84) bytes of data.
64 bytes from 10.20.1.2: icmp_seq=1 ttl=64 time=1.65 ms
64 bytes from 10.20.1.2: icmp_seq=2 ttl=64 time=0.679 ms
--- 10.20.1.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.679/1.165/1.652/0.486 ms
root@10-102-126-146:/# ip netns exec ns0 ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0
46: eth0@if47: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc noqueue state UP group default qlen 1000
link/ether a6:db:eb:70:f9:a3 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.20.1.3/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::a4db:ebff:fe70:f9a3/64 scope link
valid_lft forever preferred_lft forever
root@10-102-126-146:/# ip netns exec ns0 arp
Address HWtype HWaddress Flags Mask Iface
10.20.1.2 ether 96:45:3b:d2:2c:5c C eth0
https://github.com/withlin/blog-private/issues/250
在underlay不支持组播的情况下这种方式是不能使用的。
手动维护fdb实现简单的sdn http://just4coding.com/2020/04/20/vxlan-fdb/