1

分布式非对称网关

clipboard.png

spine配置

bgp evpn配置

router bgp 7677
 bgp router-id 192.168.59.130
 bgp bestpath as-path multipath-relax
 neighbor fabric peer-group
 neighbor fabric remote-as external
 neighbor 192.168.59.128 peer-group fabric
 neighbor 192.168.59.129 peer-group fabric
 !
 address-family l2vpn evpn
  neighbor fabric activate
 exit-address-family
!

leaf1和host1配置

接口配置

#开启转发
sudo sysctl -w net.ipv4.ip_forward=1  
sudo sysctl -p

#添加host1
sudo ip netns add host1
sudo ip link add veth1 type veth peer name eth0 netns host1
sudo ip netns exec host1 ip link set lo up
sudo ip netns exec host1 ip link set eth0 up
sudo ip netns exec host1 ip addr add 2.2.2.2/24 dev eth0
sudo ip netns exec host1 ip route add default via 2.2.2.254 dev eth0

sudo ip link add br10 type bridge
sudo ip link add vxlan10 type vxlan id 10 local 192.168.59.128 dstport 4789 nolearning
sudo ip link set br10 up
sudo ip link set vxlan10 up
sudo ip link set veth1 up  
sudo ip link set veth1 master br10
sudo ip link set vxlan10 master br10  
sudo ip addr add 2.2.2.254/24 dev br10
sudo ip link set dev br10 address 00:00:01:02:03:03

#添加vni 20,即使本端不存在vni 20的主机也需要添加
sudo ip link add br20 type bridge
sudo ip link add vxlan20 type vxlan id 20 local 192.168.59.128 dstport 4789 nolearning
sudo ip link set br20 up
sudo ip link set vxlan20 up
sudo ip link set vxlan20 master br20  
sudo ip addr add 2.2.3.254/24 dev br20
sudo ip link set dev br20 address 00:00:01:02:03:04

bgp evpn配置

router bgp 7675
 bgp router-id 192.168.59.128
 bgp bestpath as-path multipath-relax
 neighbor fabric peer-group
 neighbor fabric remote-as external
 neighbor 192.168.59.130 peer-group fabric
 !
 address-family l2vpn evpn
  neighbor fabric activate
  advertise-all-vni
 exit-address-family
!

leaf2和host2配置

接口配置

#开启转发
sudo sysctl -w net.ipv4.ip_forward=1  
sudo sysctl -p

#添加host2
sudo ip netns add host2
sudo ip link add veth1 type veth peer name eth0 netns host2
sudo ip netns exec host2 ip link set lo up
sudo ip netns exec host2 ip link set eth0 up
sudo ip netns exec host2 ip addr add 2.2.2.3/24 dev eth0
sudo ip netns exec host2 ip route add default via 2.2.2.254 dev eth0 

#添加host3
sudo ip netns add host3
sudo ip link add veth2 type veth peer name eth0 netns host3
sudo ip netns exec host3 ip link set lo up
sudo ip netns exec host3 ip link set eth0 up
sudo ip netns exec host3 ip addr add 2.2.3.2/24 dev eth0
sudo ip netns exec host3 ip route add default via 2.2.3.254 dev eth0  

#subnet 1:    2.2.2.0/24
sudo ip link add br10 type bridge
sudo ip link add vxlan10 type vxlan id 10 local 192.168.59.129 dstport 4789 nolearning
sudo ip link set br10 up
sudo ip link set vxlan10 up
sudo ip link set veth1 up  
sudo ip link set veth1 master br10
sudo ip link set vxlan10 master br10  
sudo ip addr add 2.2.2.254/24 dev br10
sudo ip link set dev br10 address 00:00:01:02:03:03

#subnet 2:    2.2.3.0/24
sudo ip link add br20 type bridge
sudo ip link add vxlan20 type vxlan id 20 local 192.168.59.129 dstport 4789 nolearning
sudo ip link set br20 up
sudo ip link set vxlan20 up
sudo ip link set veth2 up  
sudo ip link set veth2 master br20
sudo ip link set vxlan20 master br20
sudo ip addr add 2.2.3.254/24 dev br20 
sudo ip link set dev br20 address 00:00:01:02:03:04

bgp evpn配置

router bgp 7676
 bgp router-id 192.168.59.129
 bgp bestpath as-path multipath-relax
 neighbor fabric peer-group
 neighbor fabric remote-as external
 neighbor 192.168.59.130 peer-group fabric
 !
 address-family l2vpn evpn
  neighbor fabric activate
  advertise-all-vni
 exit-address-family
!

查看bgp信息

leaf1

  • 查看转发表信息
ubuntu# show bgp l2vpn evpn 
BGP table version is 3, local router ID is 192.168.59.128
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: ip 192.168.59.128:4

*> [2]:[0]:[48]:[3a:58:62:d5:eb:53]
                    192.168.59.128                     32768 i
*> [2]:[0]:[48]:[3a:58:62:d5:eb:53]:[32]:[2.2.2.2]
                    192.168.59.128                     32768 i
*> [3]:[0]:[32]:[192.168.59.128]
                    192.168.59.128                     32768 i
Route Distinguisher: ip 192.168.59.128:5

*> [3]:[0]:[32]:[192.168.59.128]
                    192.168.59.128                     32768 i
Route Distinguisher: ip 192.168.59.129:4

*> [2]:[0]:[48]:[c6:cb:34:b1:a1:87]:[128]:[fe80::c3a:daff:fe3b:b737]
                    192.168.59.129                         0 7677 7676 i
*> [3]:[0]:[32]:[192.168.59.129]
                    192.168.59.129                         0 7677 7676 i
Route Distinguisher: ip 192.168.59.129:5

*> [2]:[0]:[48]:[3e:49:54:b9:f8:7e]:[32]:[2.2.3.254]
                    192.168.59.129                         0 7677 7676 i
*> [2]:[0]:[48]:[3e:49:54:b9:f8:7e]:[128]:[fe80::8891:c9ff:fe39:f3a3]
                    192.168.59.129                         0 7677 7676 i
*> [2]:[0]:[48]:[fa:45:2f:0a:43:51]
                    192.168.59.129                         0 7677 7676 i
*> [2]:[0]:[48]:[fa:45:2f:0a:43:51]:[32]:[2.2.3.2]
                    192.168.59.129                         0 7677 7676 i
*> [3]:[0]:[32]:[192.168.59.129]
                    192.168.59.129                         0 7677 7676 i

Displayed 11 out of 11 total prefixes
ubuntu# 

总结

​ 分布式非对称网关,要求所有的vtep有相同的bdif,即使本端没有该子网的主机存在也需要创建。非常消耗表项,一般会结合对称式网关一起使用。


ouyangxibao
189 声望161 粉丝

不生产代码,只是代码的搬运工