CE与PE之间跑OSPF为例
1、配置IGP(OSPF)
show ip ospf neighbor
show ip route ospf
2、配置MPLS
可以配置mpls的标签范围
mpls label range xx-xx
默认是ldp协议
接口下启用mpls
int fa0/0
mpls ip
查看邻居
show mpls ldp discovery
show mpls ldp neighbor
show mpls forwarding-table\\查看标签分配情况
3、配置MP-BGP
1)PE之间配置BGP VPNV4邻居关系
R1:
router bgp 100
no bgp default ipv4-unicast
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
address-family vpnv4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community extended
R3:
router bgp 100
bgp log-neighbor-changes
no bgp default ipv4-unicast
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
!
address-family vpnv4
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 send-community extended
4、配置VRF应用至接口
R1:
ip vrf Mao
rd 100:10
route-target export 100:11
route-target import 100:10
ip vrf Ting
rd 100:11
route-target export 100:13 //表示输出的路由打上100:13标记
route-target import 100:14 //将标记为100:14的路由加入VRF路由表中
interface FastEthernet0/0
ip vrf forwarding Mao
ip address 14.1.1.1 255.255.255.252
interface FastEthernet0/1
ip vrf forwarding Ting
ip address 15.1.1.1 255.255.255.252
R3:
ip vrf Mao
rd 100:10
route-target export 100:10
route-target import 100:11
!
ip vrf Ting
rd 100:11
route-target export 100:14
route-target import 100:13
interface FastEthernet0/1
ip vrf forwarding Mao
ip address 36.1.1.1 255.255.255.252
!
interface FastEthernet1/0
ip vrf forwarding Ting
ip address 37.1.1.1 255.255.255.252
查看VRF基本情况Show ip vrf detail
R1#show ip vrf detail
VRF Mao (VRF Id = 1); default RD 100:10; default VPNID
Interfaces:
Fa0/0
VRF Table ID = 1
Export VPN route-target communities
RT:100:10
Import VPN route-target communities
RT:100:11
No import route-map
No global export route-map
No export route-map
VRF label distribution protocol: not configured
VRF label allocation mode: per-prefix
VRF Ting (VRF Id = 2); default RD 100:11; default VPNID
Interfaces:
Fa0/1
VRF Table ID = 2
Export VPN route-target communities
RT:100:14
Import VPN route-target communities
RT:100:13
No import route-map
No global export route-map
No export route-map
VRF label distribution protocol: not configured
VRF label allocation mode: per-prefix
5、CE和PE之间配置路由协议
CE-R4:
router ospf 10
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 1
network 14.1.1.0 0.0.0.3 area 1
PE-R1:
router ospf 10 vrf Mao
network 14.1.1.0 0.0.0.3 area 1
PE-R3:
router ospf 2 vrf Mao
network 36.1.1.0 0.0.0.3 area 2
CE-R6:
router ospf 2
router-id 6.6.6.6
network 6.6.6.6 0.0.0.0 area 2
network 36.1.1.0 0.0.0.3 area 2
show ip route vrf Mao 查看VRF Mao路由
Routing Table: Mao
Gateway of last resort is not set
6.0.0.0/32 is subnetted, 1 subnets
O 6.6.6.6 [110/2] via 36.1.1.2, 00:12:43, FastEthernet0/1
36.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 36.1.1.0/30 is directly connected, FastEthernet0/1
L 36.1.1.1/32 is directly connected, FastEthernet0/1
6、CE客户路由与MP-BGP之间重分布
PE-R1:
router ospf 10 vrf Mao
redistribute bgp 100 subnets
network 14.1.1.0 0.0.0.3 area 1
router bgp 100
address-family ipv4 vrf Mao
redistribute ospf 10
PE-R3:
router ospf 2 vrf Mao
redistribute bgp 100 subnets
network 36.1.1.0 0.0.0.3 area 2
router bgp 100
address-family ipv4 vrf Mao
redistribute ospf 2
exit-address-family
查看bgp VPNV4路由
Show ip bgp vpnv4 all
扩展知识:
R1#show ip bgp vpnv4 all 4.4.4.4
BGP routing table entry for 100:10:4.4.4.4/32, version 2
Paths: (1 available, best #1, table Mao)
Advertised to update-groups:
1
Refresh Epoch 1
Local
14.1.1.2 from 0.0.0.0 (1.1.1.1)
Origin incomplete, metric 2, localpref 100, weight 32768, valid, sourced, best
Extended Community: RT:100:10 OSPF DOMAIN ID:0x0005:0x0000000A0200
OSPF RT:0.0.0.1:2:0 OSPF ROUTER ID:14.1.1.1:0
mpls labels in/out 103/nolabel //表示MP-BGP给4.4.4.4分配的内层标签;
rx pathid: 0, tx pathid: 0x0
RT:0.0.0.1:2:0 0.0.0.1表示区域,2表示OSPF LSA类型(一般为1LSA或者2LAS),区域间路由,如果是3表示ospf 3 LAS,如果是5则表
R1#show ip bgp vpnv4 all 77.1.1.1
BGP routing table entry for 100:11:77.1.1.1/32, version 24
Paths: (1 available, best #1, table Ting)
Not advertised to any peer
Refresh Epoch 1
Local
3.3.3.3 (metric 3) from 3.3.3.3 (3.3.3.3)
Origin incomplete, metric 20, localpref 100, valid, internal, best
Extended Community: RT:100:13 OSPF DOMAIN ID:0x0005:0x0000000C0200
OSPF RT:0.0.0.0:5:1 OSPF ROUTER ID:37.1.1.1:0
mpls labels in/out nolabel/310
// 如果RT:0.0.0.0:5:1 5表示为OSPF LSA 5
总结: CE端路由重分布至MP-BGP时,能够承载OSPF属性值。