在CE-PE间配置穿过公网的GRE隧道,使CE的用户接入MPLS VPN
应用环境
在正常的网络接入环境中,如果用户需要穿越公共网络接入MPLS VPN时,用户端设备CE往往需要与PE之间有直接的物理链路,即必须在同一个网络中。
如果用户端设备CE和PE并不在同一个网络中的话,为了让CE也能接入到VPN中,可以考虑在CE和PE之间创建“逻辑上的直连”,也就是在CE与PE之间创建GRE隧道。
配置思路
在部署在CE-PE间配置穿过公网的GRE隧道,使CE的用户接入MPLS VPN时,采用如下的配置思路:
1.在骨干网中配置IGP,通常使用OSPF或IS-IS,使PE之间有可达的路由。
2.在CE和PE之间配置静态路由。
3.在CE和PE之间配置GRE隧道。
4.在PE上配置VPN实例,并与GRE隧道绑定。
5.配置穿过CE与PE之间的GRE隧道的路由
组网需求
如下图所示,路由器PE1和PE2位于MPLS骨干网,CE1和PE1之间为公共网络,其间通过路由器R1互连,CE2与PE2直连。现在,要求在此网络环境中部署一个基于MPLS网络的VPN,使其包含直连到CE1的用户和直连到CE2的用户。
CE通过它与PE之间的GRE隧道接入到MPLS VPN
| 路由器 | 接口 | IP地址 |
| CE1 | GE1/0/0 | 21.1.1.2/24 |
| GE2/0/0 | 30.1.1.1/24 | |
| Tunnel2/0/0 | 2.2.2.1/24 | |
| R1 | GE1/0/0 | 30.1.1.2/24 |
| GE2/0/0 | 50.1.1.1/24 | |
| PE1 | Loopback1 | 1.1.1.9/32 |
| GE1/0/0 | 50.1.1.2/24 | |
| GE2/0/0 | 110.1.1.1/24 | |
| Tunnel1/0/0 | 2.2.2.2/24 | |
| PE2 | Loopback1 | 3.3.3.9/32 |
| GE1/0/0 | 110.1.1.2/24 | |
| GE2/0/0 | 11.1.1.2/24 | |
| CE2 | GE1/0/0 | 11.1.1.1/24 |
适用产品和版本
路由器可以使用任意一款NE产品。版本为VRP5.30及后续版本。
配置步骤
步骤 1 配置各接口IP地址及骨干网的路由协议
按照上图配置各物理接口和Loopback接口的IP地址;并在骨干网上运行路由协议实现骨干网各路由器之间的互通。
具体配置过程略。
步骤 2 配置CE1与PE1之间的静态路由
在CE1上配置:
[CE1] ip route-static 50.1.1.0 255.255.255.0 30.1.1.2
在PE1上配置:
[PE1] ip route-static 30.1.1.0 255.255.255.0 50.1.1.1
上述配置完成后,CE1与PE1之间有可达的路由,在CE1上可以ping通PE1的接口GigabitEthernet1/0/0的IP地址50.1.1.2。
步骤 3 配置CE1与PE1之间的GRE隧道
在CE1上配置:
[CE1] interface tunnel2/0/0 [CE1-Tunnel2/0/0] ip address 2.2.2.1 255.255.255.0 [CE1-Tunnel2/0/0] source 30.1.1.1 [CE1-Tunnel2/0/0] destination 50.1.1.2
在PE1上配置:
[PE1] interface tunnel1/0/0 [PE1-Tunnel1/0/0] ip address 2.2.2.2 255.255.255.0 [PE1-Tunnel1/0/0] source 50.1.1.2 [PE1-Tunnel1/0/0] destination 30.1.1.1
上述配置完成后,CE1与PE1之间的GRE隧道已建立,在CE1上可以ping通PE1的隧道Tunnel1/0/0的IP地址2.2.2.2。
步骤 4 在PE1创建VPN实例vpn1并与GRE隧道绑定
[PE1]ip vpn-instance vpn1 [PE1-vpn-instance-vpn1] route-distinguisher 100:1 [PE1-vpn-instance-vpn1] vpn-target 111:1 export-extcommunity [PE1-vpn-instance-vpn1] vpn-target 111:1 import-extcommunity [PE1-vpn-instance-vpn1] quit [PE1] interface tunnel1/0/0 [PE1-Tunnel1/0/0] ip binding vpn-instance vpn1 [PE1-Tunnel1/0/0] ip address 2.2.2.2 255.255.255.0
步骤 5 配置穿过CE1与PE1之间的GRE隧道的路由
在CE1上配置到CE2的路由:
[CE1] ip route-static 11.1.1.0 255.255.255.0 tunnel2/0/0
在PE1上配置到CE1的路由:
[PE1] ip route-static vpn-instance vpn1 21.1.1.0 255.255.255.0 tunnel1/0/0
在PE1、PE2以及CE2上部署MPLS VPN的配置请参见后面的配置文件。
以上配置完成后,从CE1上可以ping通CE2上连接PC2的接口的IP地址。
配置文件
CE1的配置文件
sysname CE1 # interface GigabitEthernet1/0/0 ip address 21.1.1.2 255.255.255.0 interface GigabitEthernet2/0/0 ip address 30.1.1.1 255.255.255.0 interface Tunnel2/0/0 ip address 2.2.2.1 255.255.255.0 source 30.1.1.1 destination 50.1.1.2 # ip route-static 11.1.1.0 255.255.255.0 Tunnel2/0/0 ip route-static 50.1.1.0 255.255.255.0 30.1.1.2 # return
R1的配置文件
sysname R1 # interface GigabitEthernet1/0/0 ip address 30.1.1.2 255.255.255.0 interface GigabitEthernet2/0/0 ip address 50.1.1.1 255.255.255.0 # return
PE1的配置文件
sysname PE1 # ip vpn-instance vpn1 route-distinguisher 100:1 vpn-target 111:1 export-extcommunity vpn-target 111:1 import-extcommunity # mpls lsr-id 1.1.1.9 mpls lsp-trigger all # mpls ldp # interface GigabitEthernet1/0/0 ip address 50.1.1.2 255.255.255.0 interface GigabitEthernet2/0/0 ip address 110.1.1.1 255.255.255.0 mpls mpls ldp # interface LoopBack1 ip address 1.1.1.9 255.255.255.255 # interface Tunnel1/0/0 ip binding vpn-instance vpn1 ip address 2.2.2.2 255.255.255.0 source 50.1.1.2 destination 30.1.1.1 # bgp 100 peer 3.3.3.9 as-number 100 peer 3.3.3.9 connect-interface LoopBack1 # ipv4-family unicast undo synchronization peer 3.3.3.9 enable # ipv4-family vpnv4 policy vpn-target peer 3.3.3.9 enable # ipv4-family vpn-instance vpn1 import-route direct import-route static # ospf 1 area 0.0.0.0 network 110.1.1.0 0.0.0.255 network 1.1.1.9 0.0.0.0 # ip route-static 30.1.1.0 255.255.255.0 50.1.1.1 ip route-static vpn-instance vpn1 21.1.1.0 255.255.255.0 Tunnel1/0/0 # return
PE2的配置文件
Sysname PE2 # ip vpn-instance vpn1 route-distinguisher 200:1 vpn-target 111:1 export-extcommunity vpn-target 111:1 import-extcommunity # mpls lsr-id 3.3.3.9 mpls lsp-trigger all # mpls ldp # interface GigabitEthernet2/0/0 ip binding vpn-instance vpn1 ip address 11.1.1.2 255.255.255.0 # interface GigabitEthernet1/0/0 ip address 110.1.1.2 255.255.255.0 mpls mpls ldp # interface LoopBack1 ip address 3.3.3.9 255.255.255.255 # bgp 100 peer 1.1.1.9 as-number 100 peer 1.1.1.9 connect-interface LoopBack1 # ipv4-family unicast undo synchronization peer 1.1.1.9 enable # ipv4-family vpnv4 policy vpn-target peer 1.1.1.9 enable # ipv4-family vpn-instance vpn1 import-route direct import-route static # ospf 1 area 0.0.0.0 network 110.1.1.0 0.0.0.255 network 3.3.3.9 0.0.0.0 # ip route-static vpn-instance vpn1 21.1.1.0 255.255.255.0 110.1.1.0 # return
CE2的配置文件
Sysname CE2 # interface GigabitEthernet1/0/0 ip address 11.1.1.1 255.255.255.0 # ip route-static 21.1.1.0 255.255.255.0 11.1.1.2 # retur





