R2 mpls label range 200 299 ! interface Loopback0 ip address 2.2.2.2 255.255.255.255 ip ospf 1 area 0 ! interface Ethernet0/0 no ip address shutdown ! interface Ethernet0/1 ip address 192.168.23.2 255.255.255.0 ip ospf 1 area 0 mpls ip ================================== R3 mpls label range 300 399 ! interface Loopback0 ip address 3.3.3.3 255.255.255.255 ip ospf 1 area 0 ! interface Ethernet0/0 ip address 192.168.23.3 255.255.255.0 ip ospf 1 area 0 mpls ip ! interface Ethernet0/1 ip address 192.168.34.3 255.255.255.0 ip ospf 1 area 0 mpls ip ================================== R4 mpls label range 400 499 ! interface Loopback0 ip address 4.4.4.4 255.255.255.255 ip ospf 1 area 0 ! interface Ethernet0/0 ip address 192.168.34.4 255.255.255.0 ip ospf 1 area 0 mpls ip ! interface Ethernet0/1 ip address 192.168.45.4 255.255.255.0 ip ospf 1 area 0 mpls ip ================================== R5 mpls label range 500 599 ! interface Loopback0 ip address 5.5.5.5 255.255.255.255 ip ospf 1 area 0 ! interface Ethernet0/0 ip address 192.168.45.5 255.255.255.0 ip ospf 1 area 0 mpls ip
R2#sh ip bgp vpnv4 all summary BGP router identifier 1.1.1.1, local AS number 200 BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 5.5.5.5 4 200 5 5 1 0 0 00:01:51 0
分配给客户连接的VRF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
R2 ip vrf Blue rd 100:123 route-target export 200:5 route-target import 200:2 interface Ethernet0/0 ip vrf forwarding Blue ip address 192.168.12.2 255.255.255.0 ====================================== R5 ip vrf Blue rd 100:123 route-target export 200:2 route-target import 200:5 interface Ethernet0/1 ip vrf forwarding Blue ip address 192.168.56.5 255.255.255.0
R1 interface Loopback0 ip address 1.1.1.1 255.255.255.0 ip ospf 1 area 0 ! interface Ethernet0/0 ip address 192.168.12.1 255.255.255.0 ip ospf 1 area 0 ============================= R2 interface Ethernet0/0 ip ospf 2 area 0 ============================== R5 interface Ethernet0/1 ip ospf 2 area 0 ================================= interface Loopback0 ip address 6.6.6.6 255.255.255.0 ip ospf 1 area 0 ! interface Ethernet0/0 ip address 192.168.56.6 255.255.255.0 ip ospf 1 area 0
将vrf路由注入bgp vpnv4
1 2 3 4 5 6 7 8 9 10 11 12 13
R2 router bgp 200 address-family ipv4 vrf Blue redistribute ospf 2 match internal external 1 external 2 router ospf 2 vrf Blue redistribute bgp 200 subnets ========================== R5 router bgp 200 address-family ipv4 vrf Blue redistribute ospf 2 match internal external 1 external 2 router ospf 2 vrf Blue redistribute bgp 200 subnets
最终检查
路由条目的传递
1 2 3 4 5 6 7 8 9 10
R1#sh ip route 1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 1.1.1.0/24 is directly connected, Loopback0 L 1.1.1.1/32 is directly connected, Loopback0 6.0.0.0/32 is subnetted, 1 subnets O IA 6.6.6.6 [110/21] via 192.168.12.2, 00:01:54, Ethernet0/0 192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.12.0/24 is directly connected, Ethernet0/0 L 192.168.12.1/32 is directly connected, Ethernet0/0 O IA 192.168.56.0/24 [110/11] via 192.168.12.2, 00:01:54, Ethernet0/0
数据流量的转发
1 2 3 4 5
R1#ping 6.6.6.6 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms