實驗拓撲:redis
第一步:創建VRFide
R2/R4:oop
ip vrf *** 命名vrf爲「***」
rd 100:1 設置RD
route-target export 100:1設置出口路由標記
route-target import 100:1設置入口路由標記 注:一端的出口標記和對端的入口標記需一致!ui
第二步:將CE接口設置成vrf轉發code
R2:
interface FastEthernet0/1
ip vrf forwarding ***
ip address 12.1.1.2 255.255.255.0router
R4:
interface FastEthernet0/0
ip vrf forwarding ***
ip address 45.1.1.4 255.255.255.0blog
注意:在配置完 「 ip vrf forwarding ***」後,接口上原先配置的ip地址會消失,需從新配置。接口
第三步:配置mpls域的igp進程
R2:ip
router eigrp 10
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
R3:
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
!
R4:
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作準備
第四步:配置mpbgp:
R2:
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
R3:
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
R4:
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
第五步:配置site端的路由
site1:
R2:
router eigrp 100
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
R5:
router ospf 1
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轉發
R2/R3/R4
全局:
ip cef 開啓cef轉發,必定要配置!!
mpls label range x00 x99 指定本地標籤的分配範圍,以便於管理, 也可由系統自動分配
mpls label protocol ldp cisco路由器默認標籤分配協議爲tdp,這裏改成ldp協議
mpls ip 使路由器支持mpls 轉發 默認已配置
mpls ldp router-id Loopback0 force 設置標籤分配的源端口
接口下(PE和p端的接口)
mpls ip 在接口上啓用mpls
現象:
1.查看R1的路由表:
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
查看R5的路由表:
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
查看R2的vrf路由表:
show ip vrf *** route :
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的bgp ***v4表:
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 ?
R2的mpls轉發表
R2#sh mpls forwarding-table
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
R3(p路由器)的***v4 bgp表:
R3#sh ip bgp ***v4 all
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的各表略
R4前往R1:
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
能夠看到,從R2發出的包帶有雙層標籤 內層爲203 外層爲300;其中203爲R2爲1.1.1.1的路由分配的***v4標籤,300爲R3分配的普通mpls標籤 而當報文到達R3時,由於「次末跳彈出機制(PHP)」報文將彈出上層標籤(普通mpls標籤300),到達R2後就剩下了***v4標籤(203),此時再根據***v4標籤查找標籤轉發表 發現出口無標籤,因而直接以ip報文形式傳給了R1。