偶有机会遇到一个全CISCO组网的配置需求,结合GRE提供的逻辑直连能力,解决了MPLS中CE和PE需要直连的要求,把GRE和BGP/MPLS VPN配置在GNS3上实现了下,留此笔记。
组网需求
整体架构:
说明
- 骨干网路使用IP/MPLS网络,具体使用BGP/MPLS VPN实现;
- CE和PE之间是物理直连链路,并使用EBGP接入;
- S-CE和S-PE之间没有物理直连;
- S-CE和S-R之间存在地星直连链路;
- S-PE和S-R之间存在地星直连链路;
- 各AS之间使用EBGP互联。
目标
实现S-CE和CE接入骨干网。
问题
S-CE到S-PE之间不是物理直连,S-CE组为“CE设备”不能直接接入骨干网IP/MPLS网络。
思路
通过在S-CE到S-PE之间创建GRE隧道,实现逻辑直连,解决MPLS网络中“CE设备”到“PE设备”必须是物理直连的要求。
配置
配置思路
- 在S-PE、P和PE上运行ISIS路由协议实现互通,并且使能MPLS。
- 在S-CE、S-R和S-PE上运行BGP路由协议实现互通。
- 在S-CE和S-PE之间建立GRE隧道。
- 在S-PE和PE上建立名为“test”的VRF,并在S-PE上将名为“test”的VRF与GRE隧道接口“tunnel0”进行绑定,在PE上将名为“test”的VRF与连接CE的物理接口e0/1绑定。
- 在S-CE和CE上配置到达各自连接“PE设备”的路由,这里使用EBGP。
- 在S-PE和PE之间配置IBGP,完成CE1和CE2之间的互通。
具体步骤
步骤1 配置各接口IP地址
配置S-CE各接口地址
interface loopback0
ip address 20.10.0.2 255.255.255.255
no shutdown
interface ethernet0/0
ip address 10.0.1.2 255.255.255.252
no shutdown
interface ethernet0/1
ip address 192.168.1.1 255.255.255.0
no shutdown
exit
配置S-R各接口地址
interface loopback0
ip address 20.10.0.200 255.255.255.255
no shutdown
interface ethernet0/0
ip address 10.0.0.2 255.255.255.252
no shutdown
interface ethernet0/1
ip address 10.0.1.1 255.255.255.252
no shutdown
exit
配置S-PE各接口地址
interface loopback0
ip address 20.10.0.1 255.255.255.255
no shutdown
interface ethernet0/0
ip address 172.16.0.2 255.255.255.252
no shutdown
interface ethernet0/1
ip address 10.0.0.1 255.255.255.252
no shutdown
exit
配置P各接口地址
interface loopback0
ip address 10.0.0.1 255.255.255.255
no shutdown
interface ethernet0/0
ip address 172.16.0.1 255.255.255.252
no shutdown
interface ethernet0/1
ip address 172.16.0.5 255.255.255.252
no shutdown
exit
配置PE各接口地址
interface loopback0
ip address 20.20.0.1 255.255.255.255
no shutdown
interface ethernet0/0
ip address 172.16.0.6 255.255.255.252
no shutdown
interface ethernet0/1
ip address 192.168.0.5 255.255.255.252
no shutdown
exit
配置CE各接口地址
interface Loopback0
ip address 20.20.0.2 255.255.255.255
no shutdown
interface Ethernet0/0
ip address 192.168.0.6 255.255.255.252
no shutdown
interface Ethernet0/1
ip address 192.168.11.1 255.255.255.0
no shutdown
exit
步骤2 配置骨干网(AS:65000)的IGP和MPLS
ISIS中NET地址设置,以P设备为例:区域地址(Area Address)取私有地址49.0001;系统ID(System ID)使用Loopback 0的地址进行转换10.0.0.1->010.000.000.001->0100.0000.0001;NSEL在IP网络中衡为00,以下是各个设备的NET取值。
设备 | Loopback 0 | ISIS的NET地址 |
---|---|---|
S-PE | 10.20.0.1 | 49.0001.0200.1000.0001.00 |
P | 10.0.0.1 | 49.0001.0200.0000.0001.00 |
PE | 20.20.0.1 | 49.0001.0200.2000.0001.00 |
配置S-PE的ISIS和MPLS
router isis
net 49.0001.0200.1000.0001.00
is-type level-1
exit
interface loopback0
ip router isis
isis circuit-type level-1
interface ethernet0/0
ip router isis
isis circuit-type level-1
mpls ip
exit
配置P的ISIS和MPLS
router isis
net 49.0001.0200.0000.0001.00
is-type level-1
exit
interface loopback0
ip router isis
isis circuit-type level-1
interface ethernet0/0
ip router isis
isis circuit-type level-1
mpls ip
interface ethernet0/1
ip router isis
isis circuit-type level-1
mpls ip
exit
配置PE的ISIS和MPLS
router isis
net 49.0001.0200.2000.0001.00
is-type level-1
exit
interface loopback0
ip router isis
isis circuit-type level-1
interface ethernet0/0
ip router isis
isis circuit-type level-1
mpls ip
exit
步骤3 配置S-CE、S-R和S-PE之间的EBGP协议
配置S-CE的BGP协议
router bgp 65001
neighbor 10.0.1.1 remote-as 65100
neighbor 192.168.0.1 remote-as 65000
redistribute connected // 向EBGP中引入S-CE的直连路由(此处需要引入10.0.1.0/30和192.168.1.0/24)
配置S-R的BGP协议
router bgp 65100
neighbor 10.0.0.1 remote-as 65000
neighbor 10.0.1.2 remote-as 65001
exit
配置S-PE的BGP协议
router bgp 65000
neighbor 10.0.0.2 remote-as 65100
redistribute connected // 向EBGP中引入S-PE的直连路由(此处需要引入10.0.0.0/30)
exit
步骤4 创建VRF并绑定接口
配置S-PE的VRF和绑定(GRE隧道)接口
ip vrf test
rd 65000:1
route-target export 100:1
route-target import 100:1
exit
interface tunnel0
ip vrf forwarding test
ip address 192.168.0.1 255.255.255.252
exit
配置PE的VRF
ip vrf test
rd 65000:1
route-target both 100:1
exit
interface ethernet0/1
ip vrf forwarding test
ip address 192.168.0.5 255.255.255.252
exit
补充说明——RD和VPN-IPv4
传统BGP无法正确处理地址空间重叠的VPN的路由。假设VPN1和VPN2都使用了10.110.10.0/24网段的地址,并各自发布了一条去往此网段的路由。虽然本端PE通过不同的VPN实例可以区分地址空间重叠的VPN的路由,但是这些路由发往对端PE后,由于不同VPN的路由之间不进行负载分担,因此对端PE将根据BGP选路规则只选择其中一条VPN路由,从而导致去往另一个VPN的路由丢失。 PE之间使用MP-BGP(Multiprotocol Extensions for BGP-4,BGP-4的多协议扩展)来发布VPN路由,并使用VPN-IPv4地址来解决上述问题。VPN-IPv4地址共有12个字节,包括8字节的路由标识符RD(Route Distinguisher)和4字节的IPv4地址前缀。 RD用于区分使用相同地址空间的IPv4前缀,增加了RD的IPv4地址称为VPN-IPv4地址(即VPNv4地址)。PE从CE接收到IPv4路由后,转换为全局唯一的VPN-IPv4路由,并在公网上发布。RD的结构使得每个服务供应商可以独立地分配RD,但为了在CE双归属的情况下保证路由正常,必须保证PE上的RD全局唯一。
补充说明——VPN Target
BGP/MPLS IP VPN使用BGP扩展团体属性-VPN Target(也称为Route Target)来控制VPN路由信息的发布。每个VPN实例关联一个或多个VPN Target属性。有两类VPN Target属性:
- Export Target: 本地PE从直接相连Site学到IPv4路由后,转换为VPN-IPv4路由,并为这些路由设置Export Target属性。Export Target属性作为BGP的扩展团体属性随路由发布。
- Import Target: PE收到其它PE发布的VPN-IPv4路由时,检查其Export Target属性。当此属性与PE上某个VPN实例的Import Target匹配时,PE就把路由加入到该VPN实例中。
在BGP/MPLS IP VPN网络中,通过VPN Target属性来控制VPN路由信息在各Site之间的发布和接收。VPN Export Target和Import Target的设置相互独立,并且都可以设置多个值,能够实现灵活的VPN访问控制,从而实现多种VPN组网方案。
步骤5 创建GRE隧道
配置S-PE隧道接口
interface tunnel0
tunnel source ethernet0/1
tunnel destination 10.0.1.2
tunnel mode gre ip
exit
配置S-CE隧道接口
interface tunnel0
tunnel source ethernet0/0
tunnel destination 10.0.0.1
tunnel mode gre ip
exit
步骤6 在S-PE和PE之间建立MP-IBGP对等体
配置S-PE的MP-IBGP对等体
使用loopback0接口与PE建立IBGP连接,启动对等体交换VPN-IPv4路由信息。
router bgp 65000
neighbor 20.20.0.1 remote-as 65000
neighbor 20.20.0.1 update-source loopback0
address-family vpnv4
neighbor 20.20.0.1 activate
neighbor 20.20.0.1 send-community extended
exit
exit
配置PE的MP-IBGP对等体
使用loopback0接口与S-PE建立IBGP连接,启动对等体交换VPN-IPv4路由信息。
router bgp 65000
neighbor 20.10.0.1 remote-as 65000
neighbor 20.10.0.1 update-source loopback0
address-family vpnv4
neighbor 20.10.0.1 activate
neighbor 20.10.0.1 send-community extended
exit
exit
步骤7 配置S-CE和S-PE之间的EBGP路由,引入VPN路由
MPLS VPN网络中CE与PE之间(GRE隧道)可以使用静态路由、RIP、OSPF、IS-IS或BGP,此处我们使用BGP来实现。
配置S-CE与S-PE连接的BGP
router bgp 65001
neighbor 192.168.0.1 remote-as 65000
redistribute connected
exit
配置S-PE与S-CE连接的BGP
router bgp 65000
address-family ipv4 vrf test // !需要使用VRF绑定接口
neighbor 192.168.0.2 remote-as 65001
neighbor 192.168.0.2 activate
redistribute connected
exit
exit
步骤8 配置CE和PE之间的EBGP路由,引入VPN路由
配置CE与PE连接的BGP
router bgp 65002
neighbor 192.168.0.5 remote-as 65000
redistribute connected
exit
配置PE与CE连接的BGP
router bgp 65000
address-family ipv4 vrf test // !需要使用VRF绑定接口
neighbor 192.168.0.6 remote-as 65002
neighbor 192.168.0.6 activate
redistribute connected
exit
exit
后记
本文是个人实验结果和理解,对于引入VPN路由,是指整个VPN链路上的路由,包括CE设备<->PE设备和PE设备<->PE设备之间路由的总和,因为本次实验CE和PE之间使用的是BGP直连,所以只需导入直连路由。如果CE和PE设备之间使用的是IGP,则需要在IGP中导入BGP,及BGP中导入IGP,如此打通整个VPN路由。另外,实际工程中CE设备后端还有很多设备,需要根据具体情况配置需要导入的路由。 本人在实验写作中参看了华为AR路由器配置指南——VPN(命令行)中的《配置CE使用公网GRE隧道接入VPN示例》和《配置BGP/MPLS IP VPN示例》,在此表示感谢。不过话说回来,实验是配置是CISCO的,我真没在其官网上找到案例,这点个人感觉华为的文档案例方面还是比思科好点。 本次实验是在GNS3(2.2.24)上通过的,真吐槽下充满铜臭味的思科模拟器们。