Mpls的配置
一、基本配置:
R1(config)#interface serial 1/1
R1(config-if)#ip add
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config-if)#no shut
R1(config)#interface loopback 0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R6(config)#interface serial 1/1
R6(config-if)#ip add
R6(config-if)#ip address 192.168.2.1 255.255.255.0
R6(config-if)#no shut
R6(config)#interface loopback 0
R6(config-if)#ip address 192.168.1.1 255.255.255.0
R6(config-if)#exit
R5(config)#interface serial 1/0
R5(config-if)#
R5(config-if)#ip add
R5(config-if)#ip address 192.168.4.1 255.255.255.0
R5(config-if)#no shut
R5(config)#interface loopback 0
R5(config-if)#ip address 192.168.3.1 255.255.255.0
R5(config-if)#exit
R5(config)#
R7(config)#interface serial 1/1
R7(config-if)#ip add
R7(config-if)#ip address 192.168.4.1 255.255.255.0
R7(config-if)#no shut
R7(config-if)#exit
R7(config)#interface loopback 0
R7(config-if)#ip address 192.168.3.1 255.255.255.0
R2-R3-R4为2——3网段3——4网段,环回2.2.2.2 等。
二、IGP环境:
1、
R2-R3-R4属于同一个AS,运行eigrp, bgp基于eigrp 工作。
R2(config)#router eigrp 90
R2(config-router)#no auto-summ
R2(config-router)#network 2.2.2.0
R2(config-router)#network 23.1.1.0
R2(config-router)#exit
R3 、R4的配置同上一样;
测试一下,保证IGP 的正常运行
R2#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/52/80 ms
R2#
R3#show ip eigrp nei
R3#show ip eigrp neighbors
EIGRP-IPv4 Neighbors for AS(90)
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
1 34.1.1.2 Se1/1 12 00:06:12 166 996 0 4
0 23.1.1.1 Se1/0 14 00:06:54 106 636 0 5
2、
因为ibgp的水平分割,所以指定ibgp的邻居关系。
R2(config)#router bgp 1
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 4.4.4.4 remote-as 1
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R4(config)#router bgp 1
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#neighbor 2.2.2.2 remote-as 1
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
查看BGP的邻居关系
R2# show ip bgp summary
BGP router identifier 2.2.2.2, local AS number 1
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4 4 1 14 13 1 0 0 00:09:14 0
3、
为了双边的私网互通,使用标签转发,所以开启mpls协议,而普通的mpls主要解决BGP 的路由黑洞,本实验私网配置相同,所以用二层标签mpls vpn,并且路由经过的接口都要开启。
R2(config)#interface serial 1/1
R2(config-if)#mpls ip
R2(config-if)#mtu 1508
R3、R4 同上一样
4、RT要传输至目标,所以带属性(R2一样)
R4(config)#router bgp 1
R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate
R4(config-router-af)#neighbor 2.2.2.2 send-community
R4(config-router-af)#exit
三、PE端配置,
R2创建空间 qq
R2(config)#ip vrf qq
R2(config-vrf)#rd 100:1
R2(config-vrf)#route-target 100:1
R2(config)#interface serial 1/0
R2(config-if)#ip vrf forwarding qq
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#exit
R2#ping vrf qq 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/
R2创建空间WW
R2(config)#ip vrf ww
R2(config-vrf)#rd 200:1
R2(config-vrf)#route-target 200:1
R2(config)#interface serial 1/2
R2(config-if)#no ip address
R2(config-if)#ip vrf forwarding ww
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2#ping vrf ww 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/49/100 ms
R4创建空间 qq
R4创建空间WW
将对应接口划入空间( r2 r4都一样),如下:
R4(config)#interface serial 1/2
R4(config-if)#no ip address
R4(config-if)#ip vrf forwarding ww
R4(config-if)#ip address 192.168.4.2 255.255.255.0
R4(config-if)#exit
R4(config)#interface serial 1/1
R4(config-if)#no ip address
R4(config-if)#ip vrf forwarding qq
R4(config-if)#ip address 192.168.4.2 255.255.255.0
R4(config-if)#exit
R2(config)#router bgp 1
R2(config-router)#address-family ipv4 vrf qq
R2(config-router-af)#redistribute static
R2(config-router-af)#redistribute connected
R2#show ip bgp vpnv4 vrf qq
BGP table version is 3, 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, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 100:1 (default for vrf qq)
*> 192.168.1.0 0.0.0.0 0 32768 ?
*> 192.168.2.0 0.0.0.0 0 32768 ?
因为R4 没有重发布,所以R2没有收到路由。
CE 端配置:
R5运行rip,正常宣告
R5(config)#router rip
R5(config-router)#network 192.168.3.0
R5(config-router)#network 192.168.4.0
R5(config-router)#exit
PE 进行双相重发布
R4(config)#router rip
R4(config-router)#version 2
R4(config-router)#no auto-summary
R4(config-router)#address-family ipv4 vrf qq
R4(config-router-af)#network 192.168.4.0
R4(config-router-af)#redistribute bgp 1 metric 1
R4(config-router-af)#exit
R4(config)#router bgp 1
R4(config-router)#address-family ipv4 vrf qq
R4(config-router-af)#redistribute rip
R4(config-router-af)#exit
R4#ping vrf qq 192.168.4.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/44/108 ms
R4#
R4#ping vrf qq 192.168.3.1
*Nov 30 11:54:14.667: %SYS-5-CONFIG_I: Configured from console by console
R4#ping vrf qq 192.168.3.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 p
R1(ce)配置静态
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
R2 (Pe)配置静态
R2(config)#ip route vrf qq 192.168.1.0 255.255.255.0 serial 1/0
R6 CE端:运行eigrp 协议
R6(config)#router eigrp 90
R6(config-router)#no auto-summary
R6(config-router)#network 192.168.1.0
R6(config-router)#network 192.168.2.0
R6(config-router)#exit
PE 端:eigrp
R2(config)#router eigrp 1
R2(config-router)#no auto-summa
R2(config-router)#address-family ipv4 vrf ww
R2(config-router-af)#autonomous-system 90
R2(config-router-af)#network 192.168.2.0
R2(config-router-af)#redistribute bgp 1 metric 1544 100 255 1 1500
R2(config-router-af)#exit
重发布
R2(config)#router bgp 1
R2(config-router)#address-family ipv4 vrf ww
R2(config-router-af)#redistribute eigrp 90
R2(config-router-af)#exit
R2#show ip bgp vpnv4 vrf ww
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, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 200:1 (default for vrf ww)
*> 192.168.1.0 192.168.2.1 2297856 32768 ?
*> 192.168.2.0 0.0.0.0 0 32768 ?
CE端配置
R7(config)#router ospf 89
R7(config-router)# router-id 7.7.7.7
R7(config-router)#network 192.168.4.1 0.0.0.0 area 0
R7(config-router)#network 192.168.3.1 0.0.0.0 area 0
R4(config-router)#router-id 4.4.4.4
R4(config-router)#network 192.168.4.2 0.0.0.0 area 0
R4(config-router)#redistribute bgp 1 subnets
R4(config)#router bgp 1
R4(config-router)#address-family ipv4 vrf ww
R4(config-router-af)#redistribute ospf 89
PE端
R4#show ip bgp vpnv4 vrf ww
BGP table version is 13, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 200:1 (default for vrf ww)
*>i 192.168.1.0 2.2.2.2 2297856 100 0 ?
*>i 192.168.2.0 2.2.2.2 0 100 0 ?
*> 192.168.3.1/32 192.168.4.1 65 32768 ?
*> 192.168.4.0 0.0.0.0 0 32768 ?
R7#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 116/126/144 ms