拓扑如下:
路由器角色分为CE和PE,P。
骨干网基础打底(PE和P)
IGP(OSPF / IS-IS)全网可达
Loopback 可达
MPLS/LDP 在骨干接口启用
配置如下:
PE1配置信息
interface Loopback0 ip address 10.10.10.1 255.255.255.255 ip ospf 100 area 0 interface FastEthernet0/1 ip address 10.10.12.1 255.255.255.0 ip ospf 100 area 0 mpls ip
PE2配置信息
interface Loopback0 ip address 10.10.10.2 255.255.255.255 ip ospf 100 area 0!interface FastEthernet0/0 ip address 10.10.23.3 255.255.255.0 ip ospf 100 area 0 mpls ip
P1配置信息
interface Loopback0 ip address 10.10.20.1 255.255.255.255 ip ospf 100 area 0!interface FastEthernet0/0 ip address 10.10.12.2 255.255.255.0 ip ospf 100 area 0 duplex auto speed auto mpls ip !interface FastEthernet0/1 ip address 10.10.23.2 255.255.255.0 ip ospf 100 area 0 duplex auto speed auto mpls ip!
配置PE 上创建 VRF,+BGP
PE1配置VRF
##定义了VRF 名称,有两个定义VRF方式,ip vrf 123 只支持ipv4,还有示例中的一种,其实vrf definition 123 rd 100:1 ! address-family ipv4 route-target export 100:1 route-target import 100:1 exit-address-family! vrf definition 124 rd 200:1 ! address-family ipv4 route-target export 200:1 route-target import 200:1 exit-address-family ##物理接口关联VRF,配置IP interface FastEthernet0/0 vrf forwarding 123 ip address 192.168.1.1 255.255.255.0 ip ospf 123 area 0 duplex auto speed auto!interface FastEthernet1/0 vrf forwarding 124 ip address 192.168.1.1 255.255.255.0 ip ospf 124 area 0 duplex auto speed auto mpls ip##启用VRF的IGP路由协议,将BGP vpnv4路由重温发到IGP router ospf 123 vrf 123 redistribute bgp 100 subnets!router ospf 124 vrf 124 redistribute bgp 100 subnets!##启用BGP,启用VPNv4地址簇router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.2 remote-as 100 neighbor 10.10.10.2 update-source Loopback0 ! address-family vpnv4 neighbor 10.10.10.2 activate neighbor 10.10.10.2 send-community extended exit-address-family !##VRF123启用BGP address-family ipv4 vrf 123 redistribute ospf 123 exit-address-family ! ##VRF124启用BGP address-family ipv4 vrf 124 redistribute ospf 124 exit-address-family
PE2配置VRF+BGP
vrf definition 123 rd 100:1 ! address-family ipv4 route-target export 100:1 route-target import 100:1 exit-address-family! vrf definition 124 rd 200:1 ! address-family ipv4 route-target export 200:1 route-target import 200:1 exit-address-family!interface FastEthernet0/1 vrf forwarding 123 ip address 192.168.2.1 255.255.255.0 ip ospf 123 area 0 duplex auto speed auto!interface FastEthernet1/0 vrf forwarding 124 ip address 192.168.2.1 255.255.255.0 ip ospf 124 area 0 duplex auto speed auto router ospf 123 vrf 123 redistribute bgp 100 subnets!router ospf 124 vrf 124 redistribute bgp 100 subnets!router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.1 remote-as 100 neighbor 10.10.10.1 update-source Loopback0 ! address-family vpnv4 neighbor 10.10.10.1 activate neighbor 10.10.10.1 send-community extended exit-address-family ! address-family ipv4 vrf 123 redistribute ospf 123 exit-address-family ! address-family ipv4 vrf 124 redistribute ospf 124 exit-address-family
CE配置IGP,其他CE都是同样的配置
interface Loopback0 ip address 192.168.100.2 255.255.255.0 ip ospf 100 area 0!interface FastEthernet0/0 ip address 192.168.1.2 255.255.255.0 ip ospf 100 area 0 duplex auto speed auto
测试通信:
排错技巧
route-target是通过BGP通告到其他PE的重要属性查看vrf相关路由的命令show ip route vrf 123show ip bgp all在PE上执行ping vrf 123 192.168.1.1测试骨干网链路的命令:traceroute mpls ipv4 10.10.10.2/32 source 10.10.10.1