实验拓扑:
ip vrf *** 命名vrf为“***”
rd 100:1 设置RD
route-target export 100:1设置出口路由标记
route-target import 100:1设置入口路由标记 注:一端的出口标记和对端的入口标记需一致!
interface FastEthernet0/1
ip vrf forwarding ***
ip address 12.1.1.2 255.255.255.0
interface FastEthernet0/0
ip vrf forwarding ***
ip address 45.1.1.4 255.255.255.0
network 2.2.2.2 0.0.0.0
network 23.1.1.2 0.0.0.0
no auto-summary
eigrp router-id 2.2.2.2
router eigrp 10
network 3.3.3.3 0.0.0.0
network 23.1.1.3 0.0.0.0
network 34.1.1.3 0.0.0.0
no auto-summary
eigrp router-id 3.3.3.3
!
router eigrp 10
network 4.4.4.4 0.0.0.0
network 34.1.1.4 0.0.0.0
no auto-summary
eigrp router-id 4.4.4.4
配置IGP的目的是为了是mpls域内路由互通,为配置MP-BGP做准备
router bgp 100
bgp router-id 2.2.2.2
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
address-family ***v4 配置***v4地址簇,与p路由器建立***v4邻居
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community both 配置扩展团体属性的发送包括了route-tag,***标签等信息
exit-address-family
!
address-family ipv4 vrf *** 配置vrf地址簇,将CE点的路由协议重分发进mpbgp
redistribute eigrp 100
no synchronization
exit-address-family
router bgp 100
bgp router-id 3.3.3.3
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 update-source Loopback0
!
address-family ***v4 配置***v4邻居的反射,解决iGP水平分割问题,也可以不配反射,以R2-4建立全互联邻居关系代替
neighbor 2.2.2.2 activate
neighbor 2.2.2.2 send-community both
neighbor 2.2.2.2 route-reflector-client
neighbor 4.4.4.4 activate
neighbor 4.4.4.4 send-community both
neighbor 4.4.4.4 route-reflector-client
exit-address-family
router bgp 100
bgp router-id 4.4.4.4
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
address-family ***v4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community both
exit-address-family
!
address-family ipv4 vrf ***
redistribute ospf 1 vrf *** match internal external 1 external 2 重分发ospf时注意匹配范围(inter or external)
no synchronization
exit-address-family
no auto-summary
!
address-family ipv4 vrf *** 指定vrf地址簇的配置
redistribute bgp 100 metric 10000 100 255 1 1500 将mpbgp路由重 分发进CE端
network 12.1.1.2 0.0.0.0
no auto-summary
autonomous-system 100 通告自治系统号( 必须配置!)
exit-address-family
!
R1:
router eigrp 100
network 1.1.1.1 0.0.0.0
network 12.1.1.1 0.0.0.0
no auto-summary
eigrp router-id 1.1.1.1
!
site2:
R4:
router ospf 1 vrf *** ospf不能在进程下配置ipv4vrf地址簇,需在起进程时配置!
router-id 4.4.4.4
log-adjacency-changes
redistribute bgp 100 metric-type 1 subnets 将mpbgp路由充分发进ce端
network 45.1.1.4 0.0.0.0 area 0
router-id 5.5.5.5
log-adjacency-changes
network 5.5.5.5 0.0.0.0 area 0
network 45.1.1.5 0.0.0.0 area 0
!
mpls label protocol ldp cisco路由器默认标签分配协议为tdp,这里改为ldp协议
mpls ip 使路由器支持mpls 转发 默认已配置
mpls ldp router-id Loopback0 force 设置标签分配的源端口
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
5.0.0.0/32 is subnetted, 1 subnets
D EX 5.5.5.5 [170/307200] via 12.1.1.2, 01:09:39, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/1
45.0.0.0/24 is subnetted, 1 subnets
D EX 45.1.1.0 [170/307200] via 12.1.1.2, 01:09:39, FastEthernet0/1
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O E1 1.1.1.1 [110/409610] via 45.1.1.4, 01:10:11, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
C 5.5.5.5 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
O E1 12.1.1.0 [110/11] via 45.1.1.4, 01:10:10, FastEthernet0/0
45.0.0.0/24 is subnetted, 1 subnets
C 45.1.1.0 is directly connected, FastEthernet0/0
1.0.0.0/32 is subnetted, 1 subnets
D 1.1.1.1 [90/409600] via 12.1.1.1, 01:14:33, FastEthernet0/1
5.0.0.0/32 is subnetted, 1 subnets
B 5.5.5.5 [200/11] via 4.4.4.4, 01:13:04
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/1
45.0.0.0/24 is subnetted, 1 subnets
B 45.1.1.0 [200/0] via 4.4.4.4, 01:13:04
R2#sh ip bgp ***v4 all
BGP table version is 9, local router ID is 2.2.2.2
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 ***)
*> 1.1.1.1/32 12.1.1.1 409600 32768 ?
*>i5.5.5.5/32 4.4.4.4 11 100 0 ?
*> 12.1.1.0/24 0.0.0.0 0 32768 ?
*>i45.1.1.0/24 4.4.4.4 0 100 0 ?
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
200 Pop tag 3.3.3.3/32 0 Fa0/0 23.1.1.3
201 Pop tag 34.1.1.0/24 0 Fa0/0 23.1.1.3
203 Untagged 1.1.1.1/32[V] 0 Fa0/1 12.1.1.1
204 Aggregate 12.1.1.0/24[V] 1164
205 302 4.4.4.4/32 0 Fa0/0 23.1.1.3
BGP table version is 5, 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
*>i1.1.1.1/32 2.2.2.2 409600 100 0 ?
*>i5.5.5.5/32 4.4.4.4 11 100 0 ?
*>i12.1.1.0/24 2.2.2.2 0 100 0 ?
*>i45.1.1.0/24 4.4.4.4 0 100 0 ?
R4#traceroute vrf *** 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 34.1.1.3 [MPLS: Labels 300/203 Exp 0] 132 msec 180 msec 188 msec
2 12.1.1.2 [MPLS: Label 203 Exp 0] 100 msec 112 msec 84 msec
3 12.1.1.1 128 msec * 124 msec