MPLS VPN
前言
VPN----虚拟专用网络-----overlay逻辑上的
提示:以下是本篇文章正文内容,下面案例可供参考
一、名词介绍
- CE:用户网络边界设备。
- PE:运营商的边缘设备。
- P:骨干路由器。
二、VPN实例
华为叫VPN instance,思科叫VRF----虚拟转发路由器表,虚构的私网路由器表,用于私网转发的,私网和公网路由表互不影响,完全隔离,安全性。
三、步骤
- CE给PE建立路由关系
- PE将私网路由加入VRF表中,还需要加入RD RT 私网标签,变成了一个vpnv4路由,然后发出去【(RD RT是BGP打的),RT全称Route Target】
- VPNv4路由在MPLS骨干网中传输。
- 传到对端PE后,看RT决定导入到哪个VRF表,RD直接剥掉,私网标签放入对应的VRF中,变成一个私网路由,然后通过普通的路由协议发到对端的CE设备
四、实验
1.拓扑
2.CE1配置
sysname CE1 #修改主机名
interface GigabitEthernet0/0/0
ip address 172.16.1.1 255.255.255.0
interface LoopBack0
ip address 1.1.5.5 255.255.255.0
# 底层通过OSPF打通
ospf 1
area 0.0.0.0
network 1.1.5.5 0.0.0.0
network 172.16.1.0 0.0.0.255
3.PE1配置
sysname PE1
# 创建VPN实例
ip vpn-instance vpna
ipv4-family
#配置RD,对端也要配置,PE从CE接收到IPv4路由后,转换为全局唯一的VPN-IPv4路由,并在公网上发布。
route-distinguisher 100:1
#这条命令是为了VPN路由添加到本地路由
vpn-target 100:1 export-extcommunity
vpn-target 100:1 import-extcommunity
mpls lsr-id 10.1.1.1 #配置LDP实例的LSR ID
mpls
#
mpls ldp #开启LDP
interface GigabitEthernet0/0/0
ip binding vpn-instance vpna #将PE上的接口与VPN实例绑定
ip address 172.16.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.1.12.1 255.255.255.0
mpls
mpls ldp
interface LoopBack0
ip address 10.1.1.1 255.255.255.0
bgp 100 #直接与对端的PE建立BGP连接
peer 10.1.4.4 as-number 100
peer 10.1.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 10.1.4.4 enable
#
ipv4-family vpnv4
policy vpn-target # 对收到的VPNv4路由进行VPN Target过滤。
peer 10.1.4.4 enable
#
ipv4-family vpn-instance vpna
import-route ospf 2
#
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 10.1.12.0 0.0.0.255
#
ospf 2 vpn-instance vpna
import-route bgp
area 0.0.0.0
network 172.16.1.0 0.0.0.255
4.P1配置
sysname P1
mpls lsr-id 10.1.2.2
mpls
mpls ldp
interface GigabitEthernet0/0/0
ip address 10.1.12.2 255.255.255.0
mpls
mpls ldp
interface GigabitEthernet0/0/1
ip address 10.1.23.2 255.255.255.0
mpls
mpls ldp
interface LoopBack0
ip address 10.1.2.2 255.255.255.0
ospf 1
area 0.0.0.0
network 10.1.2.2 0.0.0.0
network 10.1.12.0 0.0.0.255
network 10.1.23.0 0.0.0.255
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
5.P2配置
sysname P2
mpls lsr-id 10.1.3.3
mpls
mpls ldp
interface GigabitEthernet0/0/0
ip address 10.1.23.3 255.255.255.0
mpls
mpls ldp
interface GigabitEthernet0/0/1
ip address 10.1.34.3 255.255.255.0
mpls
mpls ldp
interface LoopBack0
ip address 10.1.3.3 255.255.255.0
ospf 1
area 0.0.0.0
network 10.1.3.3 0.0.0.0
network 10.1.23.0 0.0.0.255
network 10.1.34.0 0.0.0.255
5.PE2配置
sysname PE2
ip vpn-instance vpna
ipv4-family
route-distinguisher 100:1
vpn-target 100:1 export-extcommunity
vpn-target 100:1 import-extcommunity
mpls lsr-id 10.1.4.4
mpls
mpls ldp
interface GigabitEthernet0/0/0
ip address 10.1.34.4 255.255.255.0
mpls
mpls ldp
interface GigabitEthernet0/0/1
ip binding vpn-instance vpna
ip address 172.16.2.2 255.255.255.0
interface LoopBack0
ip address 10.1.4.4 255.255.255.0
bgp 100
peer 10.1.1.1 as-number 100
peer 10.1.1.1 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
peer 10.1.1.1 enable
ipv4-family vpnv4
policy vpn-target
peer 10.1.1.1 enable
ipv4-family vpn-instance vpna
import-route ospf 2
ospf 1
area 0.0.0.0
network 10.1.4.4 0.0.0.0
network 10.1.34.0 0.0.0.255
ospf 2 vpn-instance vpna
import-route bgp
area 0.0.0.0
network 172.16.2.0 0.0.0.255
6.CE2配置
sysname CE2
interface GigabitEthernet0/0/0
ip address 172.16.2.1 255.255.255.0
interface LoopBack0
ip address 1.1.6.6 255.255.255.0
ospf 1
area 0.0.0.0
network 1.1.6.6 0.0.0.0
network 172.16.2.0 0.0.0.255
7.实验结论
CE双归属如何防环
OSPF 三类LSA中有DN位,当PE设备发给CE设备的路由的时候,DN位会置位,当CE设备再往OSPF区域里面发DN位置位的路由,该路由不会在被发送。
VPN的后门链路
有后门链路,如果后门链路同区域的话,会采用shamlink技术使后门链路当备份链路。shamlink必须是32位地址。
关于shamlink实验见下一节!