文章目录
拓扑
客户设备为R5,R6,R7,R8
运营商设备为R1,R2,R3,R4
其中R1,R4位PE
需求:红和绿通,蓝和黄通;两者之间不通。
接口配置
客户设备
R5
R5(config)#int e0/0
R5(config-if)#ip add 15.1.1.5 255.255.255.0
R5(config-if)#no shutdown
R5(config-if)#int lo0
R5(config-if)#ip add 5.5.5.5 255.255.255.255
R6
R6#config t
R6(config)#int e0/0
R6(config-if)#ip add 16.1.1.6 255.255.255.0
R6(config-if)#no shutdown
R6(config-if)#int lo0
R6(config-if)#ip add 6.6.6.6 255.255.255.255
R7
R7# config t
R7(config)#int e0/0
R7(config-if)#ip add 47.1.1.7 255.255.255.0
R7(config-if)#no shutdown
R7(config-if)#int lo0
R7(config-if)#ip add 7.7.7.7 255.255.255.255
R8
R8#config t
R8(config)#int e0/0
R8(config-if)#no shutdown
R8(config-if)#ip add 48.1.1.8 255.255.255.0
R8(config-if)#int lo0
R8(config-if)#ip add 8.8.8.8 255.255.255.255
PE设备
子接口配置
R1
R1#config t
R1(config)#int e0/0
R1(config-if)#no shutdown
R1(config-if)#int e0/0.15
R1(config-subif)#encapsulation dot1Q 15
R1(config-subif)#ip add 15.1.1.1 255.255.255.0
R1(config)#int e0/0.16
R1(config-subif)#encapsulation dot1Q 16
R1(config-subif)#ip add 16.1.1.1 255.255.255.0
R4
R4(config)#int e0/0
R4(config-if)#no shutdown
R4(config-if)#int e0/0.47
R4(config-subif)#encapsulation dot1Q 47
R4(config-subif)#ip add 47.1.1.4 255.255.255.0
R4(config-subif)#int e0/0.48
R4(config-subif)#encapsulation dot1Q 48
R4(config-subif)#ip add 48.1.1.4 255.255.255.0
测试链路
R1#ping 15.1.1.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 15.1.1.5, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 60/66/80 ms
R1#ping 16.1.1.6
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 16.1.1.6, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 36/58/76 ms
R1#ping 16.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 16.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
R1#ping 15.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 15.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
vrf配置
把子接口划入相应的vrf
R1
R1(config)#ip vrf RED
R1(config-vrf)#int e0/0.15
R1(config-subif)#ip vrf forwarding RED
!补充接口ip地址
R1(config-subif)#ip add 15.1.1.1 255.255.255.0
R1(config-subif)#exit
R1(config)#ip vrf BLUE
R1(config-vrf)#int e0/0.16
R1(config-subif)#ip vrf forwarding BLUE
% Interface Ethernet0/0.16 IP address 16.1.1.1 removed due to enabling VRF BLUE
R1(config-subif)#ip add 16.1.1.1 255.255.255.0
R4
R4(config)#ip vrf GREEN
R4(config-vrf)#int e0/0.47
R4(config-subif)#ip vrf forwarding GREEN
R4(config-subif)#ip add 47.1.1.4 255.255.255.0
R4(config)#ip vrf YELLOW
R4(config-vrf)#int e0/0.48
R4(config-subif)#ip vrf forwarding YELLOW
R4(config-subif)#ip add 48.1.1.4 255.255.255.0
测试
R1#ping vrf BLUE 16.1.1.6
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 16.1.1.6, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 60/71/92 ms
R1#ping vrf RED 15.1.1.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 15.1.1.5, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 64/76/84 ms
R1#show ip route vrf BLUE
Routing Table: BLUE
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
16.0.0.0/24 is subnetted, 1 subnets
C 16.1.1.0 is directly connected, Ethernet0/0.16
客户路由协议配置
客户为rip
R5
R5#config t
Enter configuration commands, one per line. End with CNTL/Z.
R5(config)#router rip
R5(config-router)#no auto-summary
R5(config-router)#version 2
R5(config-router)#network 0.0.0.0
R1
R1(config)#router rip
R1(config-router)#address-family ipv4 vrf RED
R1(config-router-af)#version 2
R1(config-router-af)#no auto-summary
R1(config-router-af)#network 15.0.0.0
R1#show ip route vrf RED
Routing Table: RED
Gateway of last resort is not set
5.0.0.0/32 is subnetted, 1 subnets
R 5.5.5.5 [120/1] via 15.1.1.5, 00:00:10, Ethernet0/0.15
15.0.0.0/24 is subnetted, 1 subnets
C 15.1.1.0 is directly connected, Ethernet0/0.15
R1#show run | s r r
router rip
!
address-family ipv4 vrf RED
network 15.0.0.0
no auto-summary
version 2
exit-address-family
客户为ospf
R6
R6#config t
R6(config)#router ospf 16
R6(config-router)#router-id 6.6.6.6
R6(config-router)#network 0.0.0.0 0.0.0.0 area 0
R1
R1(config)#router ospf 16 vrf BLUE
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 16.1.1.1 0.0.0.0 area 0
客户为eigrp
R7
R7#config t
R7(config)#router eigrp 47
R7(config-router)#no auto-summary
R7(config-router)#network 0.0.0.0
R4
R4(config)#router eigrp 12345 //随便起,用于全局
R4(config-router)#address-family ipv4 vrf GREEN
R4(config-router-af)#autonomous-system 47 //必须和客户端一直
R4(config-router-af)#no auto-summary
R4(config-router-af)#network 47.1.1.4 0.0.0.0
R4(config-router-af)#do show ip route vrf GREEN
Routing Table: GREEN
Gateway of last resort is not set
7.0.0.0/32 is subnetted, 1 subnets
D 7.7.7.7 [90/409600] via 47.1.1.7, 00:02:06, Ethernet0/0.47
47.0.0.0/24 is subnetted, 1 subnets
C 47.1.1.0 is directly connected, Ethernet0/0.47
R4#show run | s r e
router eigrp 12345
auto-summary
!
address-family ipv4 vrf GREEN
network 47.1.1.4 0.0.0.0
no auto-summary
autonomous-system 47
exit-address-family
客户为bgp
R8
R8#config t
R8(config)#router bgp 8
R8(config-router)#bgp router-id 8.8.8.8
R8(config-router)#neighbor 48.1.1.4 remote-as 1234
R8(config-router)#network 8.8.8.8 mask 255.255.255.255
R4
需要vrf的rd配置后才能配此项
R4#config t
R4(config)#router bgp 1234
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#address-family ipv4 vrf YELLOW
R4(config-router-af)#neighbor 48.1.1.8 remote-as 8
R4
R4#sh ip route vrf GREEN
Routing Table: GREEN
Gateway of last resort is not set
7.0.0.0/32 is subnetted, 1 subnets
D 7.7.7.7 [90/409600] via 47.1.1.7, 00:11:54, Ethernet0/0.47
47.0.0.0/24 is subnetted, 1 subnets
C 47.1.1.0 is directly connected, Ethernet0/0.47
R4#sh ip route vrf YELLOW
Routing Table: YELLOW
Gateway of last resort is not set
48.0.0.0/24 is subnetted, 1 subnets
C 48.1.1.0 is directly connected, FastEthernet0/0.48
8.0.0.0/32 is subnetted, 1 subnets
B 8.8.8.8 [20/0] via 48.1.1.8, 00:07:54
全局互联配置
ospf
R1
R1#config t
R1(config)#router ospf 1234
R1(config-router)#router-id 11.11.11.11
R1(config-router)#network 12.1.1.1 0.0.0.0 area 0
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
R2
R2#config t
R2(config)#int e0/0
R2(config-if)#ip add 23.1.1.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int lo0
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#exit
R2(config)#router ospf 1234
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 0.0.0.0 0.0.0.0 area 0
R3
R3# config t
R3(config)#int e0/0
R3(config-if)#ip add 23.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#int e0/1
R3(config-if)#ip add 34.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#int lo0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#router ospf 1234
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 0.0.0.0 0.0.0.0 area 0
R4
R4(config)#int e0/1
R4(config-if)#ip add 34.1.1.4 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#in lo0
R4(config-if)#ip add 4.4.4.4 255.255.255.255
R4(config-if)#router ospf 1234
R4(config-router)#router-id 4.4.4.4
R4(config-router)#network 4.4.4.4 0.0.0.0 area 0
R4(config-router)#network 34.1.1.4 0.0.0.0 area 0
R1
R1#sh ip route
34.0.0.0/24 is subnetted, 1 subnets
O 34.1.1.0 [110/30] via 12.1.1.2, 00:02:46, Ethernet0/1
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 12.1.1.2, 00:02:46, Ethernet0/1
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/21] via 12.1.1.2, 00:02:46, Ethernet0/1
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/31] via 12.1.1.2, 00:02:46, Ethernet0/1
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/20] via 12.1.1.2, 00:02:47, Ethernet0/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Ethernet0/1
R4
R4#sh ip route
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, Ethernet0/1
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/31] via 34.1.1.3, 00:03:43, Ethernet0/1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/21] via 34.1.1.3, 00:03:43, Ethernet0/1
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/11] via 34.1.1.3, 00:03:43, Ethernet0/1
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/20] via 34.1.1.3, 00:03:44, Ethernet0/1
12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/30] via 34.1.1.3, 00:03:46, Ethernet0/1
建立bgp邻居
R1
R1#config t
R1(config)#router bgp 1234
R1(config-router)#no bgp default ipv4-unicast
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 4.4.4.4 remote-as 1234
R1(config-router)#neighbor 4.4.4.4 update-source lo0
R1(config-router)#do show run | s r b
router bgp 1234
bgp router-id 1.1.1.1
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 4.4.4.4 remote-as 1234
neighbor 4.4.4.4 update-source Loopback0
R4
R4#config t
R4(config)#router bgp 1234
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#neighbor 1.1.1.1 remote-as 1234
R4(config-router)#neighbor 1.1.1.1 update-source lo0
R4(config-router)#do show run | s r b
router bgp 1234
bgp router-id 4.4.4.4
no bgp default ipv4-unicast
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 1234
neighbor 1.1.1.1 update-source Loopback0
激活
R1(config)#router bgp 1234
R1(config-router)#address-family vpnv4
R1(config-router-af)#neighbor 4.4.4.4 activate
R4(config)#router bgp 1234
R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 1.1.1.1 activate
R1#sh ip bgp all summary
For address family: VPNv4 Unicast
BGP router identifier 1.1.1.1, local AS number 1234
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 1234 5 5 1 0 0 00:01:27 0
把客户路由传给bgp
RD
需要随vrf定义一起配置,这里是补充。
把客户路由重分布到bgp
RD 路由区分,router distinguisher
区分不同的业务,在同一个通路中传递
值必须唯一
格式 ASN:设备号
把rd值补到vrf
R1
R1#config t
R1(config)#ip vrf RED
R1(config-vrf)#rd 5:1
R1(config-vrf)#ip vrf BLUE
R1(config-vrf)#rd 6:1
R4
R4#config t
R4(config)#ip vrf GREEN
R4(config-vrf)#rd 7:1
R4(config-vrf)#ip vrf YELLOW
R4(config-vrf)#rd 8:1
重分布
R1
R1#config t
R1(config)#router bgp 1234
R1(config-router)#address-family ipv4 vrf RED
R1(config-router-af)#redistribute rip
R1(config-router-af)#add ipv4 vrf BLUE
R1(config-router-af)#redistribute ospf 16
R1#sh ip bgp all
For address family: VPNv4 Unicast
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: 5:1 (default for vrf RED)
*> 5.5.5.5/32 15.1.1.5 1 32768 ?
*> 15.1.1.0/24 0.0.0.0 0 32768 ?
Route Distinguisher: 6:1 (default for vrf BLUE)
*> 6.6.6.6/32 16.1.1.6 2 32768 ?
*> 16.1.1.0/24 0.0.0.0 0 32768 ?
R4
R4(config)#router bgp 1234
R4(config-router)#address-family ipv4 vrf GREEN
R4(config-router-af)#redistribute eigrp 47
R4(config-router-af)#add ipv4 vrf YELLOW
!yellow不用重分布
路由导出和导入
RT
route taget
RT值定义如下
R5=5:5
R6=6:6
R7=7:7
R8=8:8
RED的路由传递到green
RT配置
R1
R1#config t
R1(config)#ip vrf RED
R1(config-vrf)#route-target export 5:5
R4
R4#config t
R4(config)#ip vrf GREEN
R4(config-vrf)#route-target import 5:5
R4(config-vrf)#do sh ip bgp vpnv4 vrf GREEN
BGP table version is 9, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 7:1 (default for vrf GREEN)
*>i5.5.5.5/32 1.1.1.1 1 100 0 ?
*> 7.7.7.7/32 47.1.1.7 156160 32768 ?
*>i15.1.1.0/24 1.1.1.1 0 100 0 ?
*> 47.1.1.0/24 0.0.0.0 0 32768 ?
路由重分布
再重分布到客户green
R4
R4(config)#router eigrp 12345
R4(config-router)#address-family ipv4 vrf GREEN
R4(config-router-af)#redistribute bgp 1234 metric 10000 100 255 1 1500
R7
R7#sh ip route
Gateway of last resort is not set
5.0.0.0/32 is subnetted, 1 subnets
D EX 5.5.5.5 [170/307200] via 47.1.1.4, 00:01:26, Ethernet0/0
7.0.0.0/32 is subnetted, 1 subnets
C 7.7.7.7 is directly connected, Loopback0
47.0.0.0/24 is subnetted, 1 subnets
C 47.1.1.0 is directly connected, Ethernet0/0
15.0.0.0/24 is subnetted, 1 subnets
D EX 15.1.1.0 [170/307200] via 47.1.1.4, 00:01:26, Ethernet0/0
green已经有red路由
传递green路由到red
RT配置
R4
R4#config t
R4(config)#ip vrf GREEN
R4(config-vrf)#route-target export 7:7
R1
R1#config t
R1(config)#ip vrf RED
R1(config-vrf)#route-target import 7:7
R1(config-vrf)#do sh ip bgp vpnv4 vrf RED
BGP table version is 15, 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: 5:1 (default for vrf RED)
*> 5.5.5.5/32 15.1.1.5 1 32768 ?
*>i7.7.7.7/32 4.4.4.4 156160 100 0 ?
*> 15.1.1.0/24 0.0.0.0 0 32768 ?
*>i47.1.1.0/24 4.4.4.4 0 100 0 ?
路由重分布
把bgp路由重分布到rip
R1#config t
R1(config)#router rip
R1(config-router)#address-family ipv4 vrf RED
R1(config-router-af)#redistribute bgp 1234 metric 5
R5#sh ip rou
5.0.0.0/32 is subnetted, 1 subnets
C 5.5.5.5 is directly connected, Loopback0
7.0.0.0/32 is subnetted, 1 subnets
R 7.7.7.7 [120/5] via 15.1.1.1, 00:00:08, Ethernet0/0
47.0.0.0/24 is subnetted, 1 subnets
R 47.1.1.0 [120/5] via 15.1.1.1, 00:00:08, Ethernet0/0
15.0.0.0/24 is subnetted, 1 subnets
C 15.1.1.0 is directly connected, Ethernet0/0
配置mpls
解决路由黑洞
R1
R1#config t
R1(config)#mpls ldp router-id lo0
R1(config)#int f0/1
R1(config-if)#mpls ip
R1(config-if)#
R2
R2#config t
R2(config)#mpls ldp router-id lo0
R2(config)#int f0/0
R2(config-if)#mpls ip
R2(config-if)#int f0/1
R2(config-if)#mpls ip
R3
R3#config t
R3(config)#mpls ldp router-id lo0
R3(config)#int f0/0
R3(config-if)#mpls ip
R3(config-if)#int f0/1
R3(config-if)#mpls ip
R4
R4#config t
R4(config)#mpls ldp router-id lo0
R4(config)#int f0/1
R4(config-if)#mpls ip
R5#ping 7.7.7.7 sour 5.5.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 7.7.7.7, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 116/141/188 ms
R7#ping 5.5.5.5 source 7.7.7.7
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
Packet sent with a source address of 7.7.7.7
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/88/128 ms
R5#traceroute 7.7.7.7 source 5.5.5.5
Type escape sequence to abort.
Tracing the route to 7.7.7.7
1 15.1.1.1 72 msec 76 msec 64 msec
2 12.1.1.2 176 msec 120 msec 120 msec
3 23.1.1.3 116 msec 116 msec 148 msec
4 47.1.1.4 124 msec 120 msec 136 msec
5 47.1.1.7 168 msec 160 msec 160 msec
R4#sh mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 3.3.3.3/32 0 Fa0/1 34.1.1.3
17 Pop tag 23.1.1.0/24 0 Fa0/1 34.1.1.3
18 19 12.1.1.0/24 0 Fa0/1 34.1.1.3
19 16 1.1.1.1/32 0 Fa0/1 34.1.1.3
20 17 2.2.2.2/32 0 Fa0/1 34.1.1.3
21 Untagged 7.7.7.7/32[V] 5014 Fa0/0.47 47.1.1.7
22 Aggregate 47.1.1.0/24[V] 0
R1#sh mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 16 34.1.1.0/24 0 Fa0/1 12.1.1.2
17 Pop tag 2.2.2.2/32 0 Fa0/1 12.1.1.2
18 18 3.3.3.3/32 0 Fa0/1 12.1.1.2
19 19 4.4.4.4/32 0 Fa0/1 12.1.1.2
20 Pop tag 23.1.1.0/24 0 Fa0/1 12.1.1.2
21 Untagged 5.5.5.5/32[V] 6940 Fa0/0.15 15.1.1.5
22 Aggregate 15.1.1.0/24[V] 0
23 Aggregate 16.1.1.0/24[V] 0
24 Untagged 6.6.6.6/32[V] 0 Fa0/0.16 16.1.1.6
R3#sh mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 17 1.1.1.1/32 10156 Fa0/0 23.1.1.2
17 Pop tag 2.2.2.2/32 0 Fa0/0 23.1.1.2
18 Pop tag 4.4.4.4/32 7184 Fa0/1 34.1.1.4
19 Pop tag 12.1.1.0/24 0 Fa0/0 23.1.1.2
R1#sh ip bgp vpnv4 vrf RED Labels
Network Next Hop In label/Out label
Route Distinguisher: 5:1 (RED)
5.5.5.5/32 15.1.1.5 21/nolabel
7.7.7.7/32 4.4.4.4 nolabel/21
15.1.1.0/24 0.0.0.0 22/aggregate(RED)
47.1.1.0/24 4.4.4.4 nolabel/22
R4#sh ip bgp vpnv4 vrf GREEN labels
Network Next Hop In label/Out label
Route Distinguisher: 7:1 (GREEN)
5.5.5.5/32 1.1.1.1 nolabel/21
7.7.7.7/32 47.1.1.7 21/nolabel
15.1.1.0/24 1.1.1.1 nolabel/22
47.1.1.0/24 0.0.0.0 22/aggregate(GREEN)
另外两个客户
把blue传到yellow
RT配置
R1
ip vrf BLUE
route-target export 6:6
R4
R4(config)#ip vrf YELLOW
R4(config-vrf)#rout
R4(config-vrf)#route-target import 6:6
结果
R4(config-vrf)#do sh ip bgp vpnv4 vrf YELLOW
BGP table version is 14, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 8:1 (default for vrf YELLOW)
*>i6.6.6.6/32 1.1.1.1 2 100 0 ?
*> 8.8.8.8/32 48.1.1.8 0 0 8 i
*>i16.1.1.0/24 1.1.1.1 0 100 0 ?
6的路由传过来了
yellow也有了
R8#sh ip rou
16.0.0.0/24 is subnetted, 1 subnets
B 16.1.1.0 [20/0] via 48.1.1.4, 00:10:48
48.0.0.0/24 is subnetted, 1 subnets
C 48.1.1.0 is directly connected, FastEthernet0/0
6.0.0.0/32 is subnetted, 1 subnets
B 6.6.6.6 [20/0] via 48.1.1.4, 00:10:48
8.0.0.0/32 is subnetted, 1 subnets
C 8.8.8.8 is directly connected, Loopback0
把yellow传到blue
R4(config)#ip vrf YELLOW
R4(config-vrf)#ROUT
R4(config-vrf)#ROUTe-target export 8:8
R1(config)#ip vrf BLUE
R1(config-vrf)#rou
R1(config-vrf)#route-target import 8:8
R1(config-vrf)#do sh ip bgp all
For address family: VPNv4 Unicast
BGP table version is 17, 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: 5:1 (default for vrf RED)
*> 5.5.5.5/32 15.1.1.5 1 32768 ?
*>i7.7.7.7/32 4.4.4.4 156160 100 0 ?
*> 15.1.1.0/24 0.0.0.0 0 32768 ?
*>i47.1.1.0/24 4.4.4.4 0 100 0 ?
Route Distinguisher: 6:1 (default for vrf BLUE)
*> 6.6.6.6/32 16.1.1.6 2 32768 ?
*>i8.8.8.8/32 4.4.4.4 0 100 0 8 i
*> 16.1.1.0/24 0.0.0.0 0 32768 ?
Route Distinguisher: 7:1
*>i7.7.7.7/32 4.4.4.4 156160 100 0 ?
*>i47.1.1.0/24 4.4.4.4 0 100 0 ?
Route Distinguisher: 8:1
*>i8.8.8.8/32 4.4.4.4 0 100 0 8 i
重分布到blue
R1(config)#router ospf 16 vrf BLUE
R1(config-router)#redistribute bgp 1234 subnets
结果
R6#sh ip rout
16.0.0.0/24 is subnetted, 1 subnets
C 16.1.1.0 is directly connected, FastEthernet0/0
6.0.0.0/32 is subnetted, 1 subnets
C 6.6.6.6 is directly connected, Loopback0
8.0.0.0/32 is subnetted, 1 subnets
O E2 8.8.8.8 [110/1] via 16.1.1.1, 00:00:36, FastEthernet0/0
R8#ping 6.6.6.6 so lo0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds:
Packet sent with a source address of 8.8.8.8
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/94/128 ms
R6#ping 8.8.8.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 48/77/104 ms
扩展示例
拓扑
nat
R5#config t
R5(config)#int f0/1
R5(config-if)#ip nat outside
R5(config-if)#int f0/0
R5(config-if)#ip nat inside
R5(config)#access-list 1 permit any
R5(config)#ip nat inside source list 1 interface f0/1 overload
R5(config)#ip route 0.0.0.0 0.0.0.0 59.1.1.9
测试
R5#ping 114.114.114.114 so lo0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 114.114.114.114, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 44/60/72 ms
清楚pe上的import RT
R1
R1#config t
R1(config)#ip vrf BLUE
R1(config-vrf)#no route-target import 8:8
R1(config-vrf)#exit
R1(config)#ip vrf RED
R1(config-vrf)#no route-target import 7:7
R4
R4# config t
R4(config)#ip vrf GREEN
R4(config-vrf)#no route-target import 5:5
R4(config-vrf)#exit
R4(config)#ip vrf YELLOW
R4(config-vrf)#NO route-target import 6:6
R5重分布默认路由
R5#config t
R5(config)#router rip
R5(config-router)#redistribute static metric 1
R5(config-router)#end
结果
R1#sh ip rout vrf RED
5.0.0.0/32 is subnetted, 1 subnets
R 5.5.5.5 [120/1] via 15.1.1.5, 00:00:29, FastEthernet0/0.15
59.0.0.0/24 is subnetted, 1 subnets
R 59.1.1.0 [120/1] via 15.1.1.5, 00:00:29, FastEthernet0/0.15
15.0.0.0/24 is subnetted, 1 subnets
C 15.1.1.0 is directly connected, FastEthernet0/0.15
R* 0.0.0.0/0 [120/1] via 15.1.1.5, 00:00:29, FastEthernet0/0.15
R5接受路由
R1#config t
R1(config)#ip vrf RED
R1(config-vrf)#route-target import 6:6
R1(config-vrf)#route-target import 7:7
R1(config-vrf)#route-target import 8:8
结果
R1上有6、7、8的路由
R1#sh ip bgp vpnv4 vrf RED
BGP table version is 31, 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: 5:1 (default for vrf RED)
*> 5.5.5.5/32 15.1.1.5 1 32768 ?
*> 6.6.6.6/32 16.1.1.6 2 32768 ?
*>i7.7.7.7/32 4.4.4.4 156160 100 0 ?
*>i8.8.8.8/32 4.4.4.4 0 100 0 8 i
*> 15.1.1.0/24 0.0.0.0 0 32768 ?
*> 16.1.1.0/24 0.0.0.0 0 32768 ?
*>i47.1.1.0/24 4.4.4.4 0 100 0 ?
*> 59.1.1.0/24 15.1.1.5 1 32768 ?
R5上
有了6、7、8的路由
R5#sh ip rout
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 59.1.1.9 to network 0.0.0.0
16.0.0.0/24 is subnetted, 1 subnets
R 16.1.1.0 [120/5] via 15.1.1.1, 00:00:00, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
C 5.5.5.5 is directly connected, Loopback0
6.0.0.0/32 is subnetted, 1 subnets
R 6.6.6.6 [120/5] via 15.1.1.1, 00:00:00, FastEthernet0/0
7.0.0.0/32 is subnetted, 1 subnets
R 7.7.7.7 [120/5] via 15.1.1.1, 00:00:00, FastEthernet0/0
8.0.0.0/32 is subnetted, 1 subnets
R 8.8.8.8 [120/5] via 15.1.1.1, 00:00:00, FastEthernet0/0
59.0.0.0/24 is subnetted, 1 subnets
C 59.1.1.0 is directly connected, FastEthernet0/1
47.0.0.0/24 is subnetted, 1 subnets
R 47.1.1.0 [120/5] via 15.1.1.1, 00:00:05, FastEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
C 15.1.1.0 is directly connected, FastEthernet0/0
S* 0.0.0.0/0 [1/0] via 59.1.1.9
R4导入RT
R4(config)#ip vrf GREEN
R4(config-vrf)#route-target import 5:5
R4(config-vrf)#ip vrf YELLOW
R4(config-vrf)#route-target import 5:5
R4#sh ip bgp vpnv4 vrf YELLOW
BGP table version is 35, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 8:1 (default for vrf YELLOW)
*>i5.5.5.5/32 1.1.1.1 1 100 0 ?
*> 8.8.8.8/32 48.1.1.8 0 0 8 i
*>i15.1.1.0/24 1.1.1.1 0 100 0 ?
*>i59.1.1.0/24 1.1.1.1 1 100 0 ?
R4#sh ip bgp vpnv4 vrf GREEN
BGP table version is 35, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 7:1 (default for vrf GREEN)
*>i5.5.5.5/32 1.1.1.1 1 100 0 ?
*> 7.7.7.7/32 47.1.1.7 156160 32768 ?
*>i15.1.1.0/24 1.1.1.1 0 100 0 ?
*> 47.1.1.0/24 0.0.0.0 0 32768 ?
*>i59.1.1.0/24 1.1.1.1 1 100 0 ?
R7
R7#sh ip rout
5.0.0.0/32 is subnetted, 1 subnets
D EX 5.5.5.5 [170/284160] via 47.1.1.4, 00:03:36, FastEthernet0/0
7.0.0.0/32 is subnetted, 1 subnets
C 7.7.7.7 is directly connected, Loopback0
59.0.0.0/24 is subnetted, 1 subnets
D EX 59.1.1.0 [170/284160] via 47.1.1.4, 00:03:36, FastEthernet0/0
47.0.0.0/24 is subnetted, 1 subnets
C 47.1.1.0 is directly connected, FastEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
D EX 15.1.1.0 [170/284160] via 47.1.1.4, 00:03:37, FastEthernet0/0
R8
R8#sh ip rout
48.0.0.0/24 is subnetted, 1 subnets
C 48.1.1.0 is directly connected, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
B 5.5.5.5 [20/0] via 48.1.1.4, 00:03:06
8.0.0.0/32 is subnetted, 1 subnets
C 8.8.8.8 is directly connected, Loopback0
59.0.0.0/24 is subnetted, 1 subnets
B 59.1.1.0 [20/0] via 48.1.1.4, 00:03:06
15.0.0.0/24 is subnetted, 1 subnets
B 15.1.1.0 [20/0] via 48.1.1.4, 00:03:06
没有传默认路由,bgp默认是不传默认路由,防止打环。
R1
R1#sh run | s vrf
ip vrf BLUE
rd 6:1
route-target export 6:6
ip vrf RED
rd 5:1
route-target export 5:5
route-target import 6:6
route-target import 7:7
route-target import 8:8
ip vrf forwarding RED
ip vrf forwarding BLUE
router ospf 16 vrf BLUE
router-id 1.1.1.1
log-adjacency-changes
redistribute bgp 1234 subnets
network 16.1.1.1 0.0.0.0 area 0
address-family ipv4 vrf RED
redistribute bgp 1234 metric 5
network 15.0.0.0
no auto-summary
version 2
address-family ipv4 vrf RED
redistribute rip
no synchronization
address-family ipv4 vrf BLUE
redistribute ospf 16 vrf BLUE
no synchronization
R1直接下发
在R1的address-family ipv4 vrf RED中增加默认路由,
R1#config t
R1(config)#router bgp 1234
R1(config-router)#address-family ipv4 vrf RED
R1(config-router-af)#default-information originate
R1#sh ip bgp vpnv4 vrf RED
BGP table version is 33, 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: 5:1 (default for vrf RED)
*> 0.0.0.0 15.1.1.5 1 32768 ?
*> 5.5.5.5/32 15.1.1.5 1 32768 ?
*> 6.6.6.6/32 16.1.1.6 2 32768 ?
*>i7.7.7.7/32 4.4.4.4 156160 100 0 ?
*>i8.8.8.8/32 4.4.4.4 0 100 0 8 i
*> 15.1.1.0/24 0.0.0.0 0 32768 ?
*> 16.1.1.0/24 0.0.0.0 0 32768 ?
*>i47.1.1.0/24 4.4.4.4 0 100 0 ?
*> 59.1.1.0/24 15.1.1.5 1 32768 ?
有默认路由了
R4
R4#sh ip bgp vpnv4 vrf GREEN
BGP table version is 38, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 7:1 (default for vrf GREEN)
*>i0.0.0.0 1.1.1.1 1 100 0 ?
*>i5.5.5.5/32 1.1.1.1 1 100 0 ?
*> 7.7.7.7/32 47.1.1.7 156160 32768 ?
*>i15.1.1.0/24 1.1.1.1 0 100 0 ?
*> 47.1.1.0/24 0.0.0.0 0 32768 ?
*>i59.1.1.0/24 1.1.1.1 1 100 0 ?
R4#sh ip bgp vpnv4 vrf YELLOW
BGP table version is 38, 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
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 8:1 (default for vrf YELLOW)
*>i0.0.0.0 1.1.1.1 1 100 0 ?
*>i5.5.5.5/32 1.1.1.1 1 100 0 ?
*> 8.8.8.8/32 48.1.1.8 0 0 8 i
*>i15.1.1.0/24 1.1.1.1 0 100 0 ?
*>i59.1.1.0/24 1.1.1.1 1 100 0 ?
R4上也有了默认路由
R7
R7#sh ip route
Gateway of last resort is 47.1.1.4 to network 0.0.0.0
5.0.0.0/32 is subnetted, 1 subnets
D EX 5.5.5.5 [170/284160] via 47.1.1.4, 00:21:08, FastEthernet0/0
7.0.0.0/32 is subnetted, 1 subnets
C 7.7.7.7 is directly connected, Loopback0
59.0.0.0/24 is subnetted, 1 subnets
D EX 59.1.1.0 [170/284160] via 47.1.1.4, 00:21:09, FastEthernet0/0
47.0.0.0/24 is subnetted, 1 subnets
C 47.1.1.0 is directly connected, FastEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
D EX 15.1.1.0 [170/284160] via 47.1.1.4, 00:21:09, FastEthernet0/0
D*EX 0.0.0.0/0 [170/284160] via 47.1.1.4, 00:06:24, FastEthernet0/0
R8
R8#sh ip rout
Gateway of last resort is 48.1.1.4 to network 0.0.0.0
48.0.0.0/24 is subnetted, 1 subnets
C 48.1.1.0 is directly connected, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
B 5.5.5.5 [20/0] via 48.1.1.4, 00:21:24
8.0.0.0/32 is subnetted, 1 subnets
C 8.8.8.8 is directly connected, Loopback0
59.0.0.0/24 is subnetted, 1 subnets
B 59.1.1.0 [20/0] via 48.1.1.4, 00:21:24
15.0.0.0/24 is subnetted, 1 subnets
B 15.1.1.0 [20/0] via 48.1.1.4, 00:21:24
B* 0.0.0.0/0 [20/0] via 48.1.1.4, 00:07:08
R6
R6#sh ip rout
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
16.0.0.0/24 is subnetted, 1 subnets
C 16.1.1.0 is directly connected, FastEthernet0/0
6.0.0.0/32 is subnetted, 1 subnets
C 6.6.6.6 is directly connected, Loopback0
R6没有
需要pe上下发默认路由到R6
R1#config t
R1(config)#router ospf 16 vrf BLUE
R1(config-router)#default-information originate always
结果
R6#sh ip rout
16.0.0.0/24 is subnetted, 1 subnets
C 16.1.1.0 is directly connected, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O E2 5.5.5.5 [110/1] via 16.1.1.1, 00:10:09, FastEthernet0/0
6.0.0.0/32 is subnetted, 1 subnets
C 6.6.6.6 is directly connected, Loopback0
59.0.0.0/24 is subnetted, 1 subnets
O E2 59.1.1.0 [110/1] via 16.1.1.1, 00:10:09, FastEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
O E2 15.1.1.0 [110/1] via 16.1.1.1, 00:10:09, FastEthernet0/0
O*E2 0.0.0.0/0 [110/1] via 16.1.1.1, 00:01:08, FastEthernet0/0
测试
R6#ping 114.114.114.114
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 114.114.114.114, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 44/59/64 ms
R7#traceroute 8.8.8.8 so 7.7.7.7
Type escape sequence to abort.
Tracing the route to 8.8.8.8
1 47.1.1.4 72 msec 64 msec 60 msec
2 34.1.1.3 [MPLS: Labels 19/26 Exp 0] 120 msec 124 msec 120 msec
3 23.1.1.2 [MPLS: Labels 18/26 Exp 0] 120 msec 152 msec 120 msec
4 15.1.1.1 [MPLS: Label 26 Exp 0] 128 msec 120 msec 116 msec
5 15.1.1.5 124 msec 120 msec 116 msec
6 15.1.1.1 148 msec 152 msec 172 msec
7 12.1.1.2 [MPLS: Labels 19/23 Exp 0] 244 msec 236 msec 236 msec
8 23.1.1.3 [MPLS: Labels 17/23 Exp 0] 244 msec 236 msec 212 msec
9 48.1.1.4 [MPLS: Label 23 Exp 0] 180 msec 172 msec 216 msec
10 48.1.1.8 212 msec 156 msec 148 msec