用MPLS VPN配置Hub and Spoke
2020-05-23 本文已影响0人
爱看时事的通信崔
目前行业的组网应用开始出现网络扁平化趋势,其中Hub-And-Spoke组网就是一种典型的扁平化组网方式。该模式是通过在VPN中设置总部,要求其它分部的互访全部通过总部进行,以实现对分部网络流量的集中控制。
在本文中,我们基于华为ENSP模拟器,用BGP/MPLS VPN完成Hub and Spoke组网的配置实验,模拟实现某企业总公司和分公司之间的安全互访。具体实验拓扑如下:
实验拓扑图有几点进行说明
- 中间的三台PE路由器模拟的是骨干网,其IGP使用OSPF协议以实现骨干网IP连通,并配置MPLS和MPLS-LDP;
- PE和CE间使用静态路由,配置不同的BGP AS号,模拟公司接入网;
- 总公司PE作为Hub,分公司PE作为Spoke,Hub和Spoke之间需要建立MP-IBGP对等体;
- 分公司间的流量互访经过总公司,所以分公司间无需建立MP-IBGP对等体,总公司CE要设置允许AS号重复;
- 限于篇幅,不对基础知识进行讲解,下面直接贴出详细配置。
总公司PE
sysname 总公司-PE
#
ip vpn-instance vpn_in
ipv4-family
route-distinguisher 100:21
vpn-target 100:1 import-extcommunity
#
ip vpn-instance vpn_out
ipv4-family
route-distinguisher 100:22
vpn-target 200:1 export-extcommunity
#
mpls lsr-id 1.1.1.1
mpls
label advertise non-null
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 10.1.1.2 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 11.1.1.2 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
ip binding vpn-instance vpn_in
ip address 12.1.1.2 255.255.255.0
#
interface GigabitEthernet4/0/0
ip binding vpn-instance vpn_out
ip address 13.1.1.2 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
bgp 100
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 as-number 100
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 2.2.2.2 enable
peer 3.3.3.3 enable
#
ipv4-family vpnv4
policy vpn-target
peer 2.2.2.2 enable
peer 3.3.3.3 enable
#
ipv4-family vpn-instance vpn_in
import-route direct
peer 12.1.1.1 as-number 65430
#
ipv4-family vpn-instance vpn_out
import-route direct
peer 13.1.1.1 as-number 65430
peer 13.1.1.1 allow-as-loop
#
ospf 1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 10.1.1.0 0.0.0.255
network 11.1.1.0 0.0.0.255
总公司CE
sysname 总公司-CE
#
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 13.1.1.1 255.255.255.0
#
bgp 65430
peer 12.1.1.2 as-number 100
peer 13.1.1.2 as-number 100
#
ipv4-family unicast
undo synchronization
import-route direct
peer 12.1.1.2 enable
peer 13.1.1.2 enable
分公司PE1
#
sysname 分公司-PE1
ip vpn-instance vpna
ipv4-family
route-distinguisher 100:1
vpn-target 100:1 export-extcommunity
vpn-target 200:1 import-extcommunity
#
mpls lsr-id 2.2.2.2
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 10.1.1.1 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
ip binding vpn-instance vpna
ip address 100.1.1.2 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 1.1.1.1 enable
#
ipv4-family vpnv4
policy vpn-target
peer 1.1.1.1 enable
#
ipv4-family vpn-instance vpna
import-route direct
peer 100.1.1.1 as-number 65410
#
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 10.1.1.0 0.0.0.255
分公司CE1
#
sysname 分公司-CE1
interface GigabitEthernet0/0/0
ip address 100.1.1.1 255.255.255.0
#
bgp 65410
peer 100.1.1.2 as-number 100
#
ipv4-family unicast
undo synchronization
import-route direct
peer 100.1.1.2 enable
分公司PE2
#
sysname 分公司-PE2
#
ip vpn-instance vpna
ipv4-family
route-distinguisher 100:3
vpn-target 100:1 export-extcommunity
vpn-target 200:1 import-extcommunity
#
mpls lsr-id 3.3.3.9
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 11.1.1.1 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
ip binding vpn-instance vpna
ip address 120.1.1.2 255.255.255.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 1.1.1.1 enable
#
ipv4-family vpnv4
policy vpn-target
peer 1.1.1.1 enable
#
ipv4-family vpn-instance vpna
import-route direct
peer 120.1.1.1 as-number 65420
#
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 11.1.1.0 0.0.0.255
分公司CE2
#
sysname 分公司-CE2
#
interface GigabitEthernet0/0/0
ip address 120.1.1.1 255.255.255.0
#
bgp 65420
peer 120.1.1.2 as-number 100
#
ipv4-family unicast
undo synchronization
import-route direct
peer 120.1.1.2 enable
验证
实验配置完成,验证一下实验效果。
- 从分公司1 ping 分公司2,验证连通情况
ping 120.1.1.1
PING 120.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 120.1.1.1: bytes=56 Sequence=1 ttl=250 time=70 ms
- 从分公司1 tracert 分公司2,注意中间总公司负责流量的汇聚和转发
tracert 120.1.1.1
1 100.1.1.2 20 ms 10 ms 20 ms
2 13.1.1.2 < AS=100 > 20 ms 50 ms 30 ms
3 13.1.1.1 < AS=100 > 30 ms 20 ms 20 ms
# 第3和4步,流量在总公司CE进行汇聚转发
4 12.1.1.2 < AS=65430 > 30 ms 30 ms 20 ms
5 120.1.1.2 < AS=100 > 40 ms 30 ms 30 ms
6 120.1.1.1 < AS=100 > 60 ms 40 ms 50 ms