以下面拓扑为例配置MPLS ×××
拓扑说明:R1,R2、R3路由器上分别配置Loopback1 接口,IP地址分别为1.1.1.1,2.2.2.2 3.3.3.3;并配置OSPF,让MPLS区域内的地址可以进行标签交换
1、在MPLS区域配置标签交换
R1:
interface Serial0/0
ip address 12.1.1.1 255.255.255.0
mpls label protocol ldp
mpls ip
R2:
mpls label protocol ldp
interface Serial0/0
ip address 12.1.1.2 255.255.255.0
mpls ip
serial restart-delay 0
!
interface Serial0/1
ip address 23.1.1.2 255.255.255.0
mpls ip
serial restart-delay 0
R3:
interface Serial0/1
ip address 23.1.1.3 255.255.255.0
mpls label protocol ldp
mpls ip
serial restart-delay 0
验证R1、R3双方的Loopback1接口已经进行标签交换
R1#traceroute 3.3.3.3
Type escape sequence to abort.
Tracing the route to 3.3.3.3
1 12.1.1.2 [MPLS: Label 17 Exp 0] 56 msec 40 msec 40 msec
2 23.1.1.3 40 msec * 40 msec
2、在R1、R3间配置普通的BGP,保证BGP邻居的建立
R1#sh run | section bgp
router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback1
no auto-summary
R1#
R3#sh run | section bgp
router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback1
no auto-summary
R3#
验证BGP邻居已经正常建立
R1#sh ip bgp summary
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3.3.3.3 4 100 20 20 1 0 0 00:17:42 0
R1#
3、在PE上创建VRF,需要通信的两个用户网络的VRF与RD值要保持一致
R1:
ip vrf vpn1
rd 100:1
!
R3:
ip vrf vpn1
rd 100:1
!
4、在PE上将连接CE的接口划入到相应的VRF中,这样表示从该接口进入的流量均通过VRF进行转发
R1:
interface Serial0/1
ip vrf forwarding vpn1
ip address 14.1.1.1 255.255.255.0
serial restart-delay 0
R3:
!
interface Serial0/0
ip vrf forwarding vpn1
ip address 23.1.1.3 255.255.255.0
mpls label protocol ldp
mpls ip
serial restart-delay 0
!
在这里需要注意的是,当把一个接口加入到VRF中时,接口IP地址会丢失,需要重新配置IP地址。
在PE上查看VRF路由表
R1#sh ip route vrf vpn1
Routing Table: vpn1
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial0/1
R1#
在这里接口14.1.1.4已经进入VRF路由表,需要说明的是该接口路由不会再出现在全局路由表中。
5、在R1、R3上创建MP-BGP帮助传递用户网络信息
R1:
router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback1
no auto-summary
!
address-family vpnv4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community both
exit-address-family
R3:
router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback1
no auto-summary
!
address-family vpnv4
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 send-community both
exit-address-family
验证MP-BGP邻居已经建立
R1#sh ip bgp all summary
For address family: IPv4 Unicast
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3.3.3.3 4 100 45 46 1 0 0 00:08:45 0
For address family: ×××v4 Unicast
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3.3.3.3 4 100 45 46 1 0 0 00:08:45 0
R1#
6、为MP-BGP创建VRF表
R1(config)#router bgp 100
R1(config-router)#address-family ipv4 vrf vpn1
R3(config)#router bgp 100
R3(config-router)#address-family ipv4 vrf vpn1
7、配置PE-CE路由协议
在LAN1用户网络边缘配置RIP
R1#sh running-config | section rip
router rip
version 2
no auto-summary
!
address-family ipv4 vrf vpn1
redistribute bgp 100 metric 1
network 14.0.0.0
no auto-summary
exit-address-family
R4#sh running-config | section rip
router rip
version 2
network 10.0.0.0
network 14.0.0.0
no auto-summary
在LAN2用户网络边缘配置OSPF
R3#sh running-config | section ospf
router ospf 100 vrf vpn1
router-id 36.1.1.3
log-adjacency-changes
redistribute bgp 100 subnets
network 36.1.1.3 0.0.0.0 area 0
R6#sh running-config | section ospf
router ospf 100
router-id 6.6.6.6
log-adjacency-changes
network 36.1.1.6 0.0.0.0 area 0
network 192.168.1.6 0.0.0.0 area 0
R6#
验证PE R1路由器已经收到LAN1内部路由信息
R1#sh ip route vrf vpn1
Routing Table: vpn1
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
R 10.1.1.0 [120/1] via 14.1.1.4, 00:00:00, Serial0/1
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial0/1
同理验证R3也同样拥有LAN2内部路由信息
8、将路由重分布进MP-BGP
R1:
router bgp 100
address-family ipv4 vrf vpn1
redistribute rip
no synchronization
exit-address-family
R3:
!
router bgp 100
address-family ipv4 vrf vpn1
redistribute ospf 100 vrf vpn1
no synchronization
exit-address-family
验证MP-BGP路由,到此PE上应该有双方用户网络的路由信息
R1#sh ip bgp vpnv4 all
BGP table version is 9, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 100:1 (default for vrf vpn1)
*> 10.1.1.0/24 14.1.1.4 1 32768 ?
*> 14.1.1.0/24 0.0.0.0 0 32768 ?
*>i36.1.1.0/24 3.3.3.3 0 100 0 ?
*>i192.168.1.0 3.3.3.3 128 100 0 ?
R1#
R3#sh ip bgp vpnv4 all
BGP table version is 9, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 100:1 (default for vrf vpn1)
*>i10.1.1.0/24 1.1.1.1 1 100 0 ?
*>i14.1.1.0/24 1.1.1.1 0 100 0 ?
*> 36.1.1.0/24 0.0.0.0 0 32768 ?
*> 192.168.1.0 36.1.1.6 128 32768 ?
R3#
10、查看VRF路由
R1#sh ip route vrf vpn1
Routing Table: vpn1
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
36.0.0.0/24 is subnetted, 1 subnets
B 36.1.1.0 [200/0] via 3.3.3.3, 00:21:27
10.0.0.0/24 is subnetted, 1 subnets
R 10.1.1.0 [120/1] via 14.1.1.4, 00:00:25, Serial0/1
B 192.168.1.0/24 [200/128] via 3.3.3.3, 00:21:27
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial0/1
R1#
R3#sh ip route vr
R3#sh ip route vrf vpn1
Routing Table: vpn1
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
36.0.0.0/24 is subnetted, 1 subnets
C 36.1.1.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
B 10.1.1.0 [200/1] via 1.1.1.1, 00:28:37
O 192.168.1.0/24 [110/128] via 36.1.1.6, 00:22:30, Serial0/0
14.0.0.0/24 is subnetted, 1 subnets
B 14.1.1.0 [200/0] via 1.1.1.1, 00:28:37
R3#
11、查看CE路由
R4#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
36.0.0.0/24 is subnetted, 1 subnets
R 36.1.1.0 [120/1] via 14.1.1.1, 00:00:25, Serial0/1
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial0/0
R 192.168.1.0/24 [120/1] via 14.1.1.1, 00:00:25, Serial0/1
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial0/1
R4#
R6#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
36.0.0.0/24 is subnetted, 1 subnets
C 36.1.1.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.1.1.0 [110/1] via 36.1.1.3, 00:23:58, Serial0/0
C 192.168.1.0/24 is directly connected, Serial0/1
14.0.0.0/24 is subnetted, 1 subnets
O E2 14.1.1.0 [110/1] via 36.1.1.3, 00:23:58, Serial0/0
R6#
12、测试用户通信
R5#traceroute 192.168.1.6
Type escape sequence to abort.
Tracing the route to 192.168.1.6
1 10.1.1.4 32 msec 36 msec 24 msec
2 14.1.1.1 12 msec 32 msec 40 msec
3 12.1.1.2 [MPLS: Labels 17/22 Exp 0] 68 msec 68 msec 104 msec
4 36.1.1.3 [MPLS: Label 22 Exp 0] 56 msec 96 msec 52 msec
5 36.1.1.6 100 msec * 92 msec