R1、R5路由器用动态路由协议OSPF来宣告路由;R2、R4建立BGP邻居,连接R1、R5、R6、R7的接口启动vrf空间,配置MPLS-×××,生成×××V4下的BGP表;R2、R3、R4用MPLS防止路由黑洞,R2、R4通过双向重发布是全网获得所有路由;R6、R7启动BGP,保持和R2、R4相同的route-target值,可以使全网互通。
配置如下:
**R1: **
interface Loopback0
ip address 192.168.1.1 255.255.255.0
interface Serial1/1
ip address 192.168.2.1 255.255.255.0
router ospf 1
router-id 192.168.1.1
log-adjacency-changes
network 192.168.1.1 0.0.0.0 area 0
network 192.168.2.1 0.0.0.0 area 0
R2:
ip vrf 6
rd 100:6
route-target export 1:1
route-target import 1:1
ip vrf eilm
rd 100:1
route-target export 1:1
route-target import 1:1
ip vrf forwarding
ip cef
mpls label range 200 299
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/0
ip vrf forwarding 6
ip address 26.1.1.2 255.255.255.0
duplex half
!
interface Serial1/0
ip vrf forwarding eilm
ip address 192.168.2.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 23.1.1.2 255.255.255.0
router eigrp 90
network 2.0.0.0
network 23.0.0.0
no auto-summary
!
router ospf 1 vrf eilm
router-id 2.2.2.2
log-adjacency-changes
redistribute bgp 1 subnets
network 192.168.2.2 0.0.0.0 area 0
!
router bgp 1
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 4.4.4.4 remote-as 1
neighbor 4.4.4.4 update-source Loopback0
no auto-summary
!
address-family vpnv4
neighbor 4.4.4.4 activate
neighbor 4.4.4.4 send-community both
exit-address-family
!
address-family ipv4 vrf eilm
redistribute ospf 1
no auto-summary
no synchronization
exit-address-family
!
address-family ipv4 vrf 6
neighbor 26.1.1.6 remote-as 6
neighbor 26.1.1.6 activate
no auto-summary
no synchronization
exit-address-family
R3:
ip cef
mpls label range 300 399
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Serial1/0
ip address 23.1.1.3 255.255.255.0
tag-switching ip
serial restart-delay 0
!
interface Serial1/1
ip address 34.1.1.3 255.255.255.0
router eigrp 90
network 3.0.0.0
network 23.0.0.0
network 34.0.0.0
no auto-summary
R4:
ip vrf 7 rd 100:7 route-target export 1:1 route-target import 1:1 ! ip vrf eason rd 100:5 route-target export 1:1 route-target import 1:1 ! ip cef mpls label range 400 499 interface Loopback0 ip address 4.4.4.4 255.255.255.0 ! interface FastEthernet0/0 ip vrf forwarding 7 ip address 47.1.1.4 255.255.255.0 duplex half ! interface Serial1/0 ip address 34.1.1.4 255.255.255.0 tag-switching ip serial restart-delay 0 ! interface Serial1/1 ip vrf forwarding eason ip address 192.168.3.1 255.255.255.0 router eigrp 90 network 4.0.0.0 network 34.0.0.0 no auto-summary ! router ospf 1 vrf eason router-id 4.4.4.4 log-adjacency-changes redistribute bgp 1 subnets network 192.168.3.1 0.0.0.0 area 0 ! router bgp 1 no synchronization bgp router-id 4.4.4.4 bgp log-neighbor-changes neighbor 2.2.2.2 remote-as 1 neighbor 2.2.2.2 update-source Loopback0 no auto-summary ! address-family vpnv4 neighbor 2.2.2.2 activate neighbor 2.2.2.2 send-community both exit-address-family ! address-family ipv4 vrf eason redistribute ospf 1 no auto-summary no synchronization exit-address-family ! address-family ipv4 vrf 7 neighbor 47.1.1.7 remote-as 7 neighbor 47.1.1.7 activate no auto-summary no synchronization exit-address-family R5: interface Loopback0 ip address 192.168.4.1 255.255.255.0 interface Serial1/0 ip address 192.168.3.2 255.255.255.0 router ospf 1 router-id 192.168.4.1 log-adjacency-changes network 192.168.3.2 0.0.0.0 area 0 network 192.168.4.1 0.0.0.0 area 0 R6:
interface Loopback0 ip address 6.6.6.6 255.255.255.0 ! interface FastEthernet0/0 ip address 26.1.1.6 255.255.255.0 router bgp 6 no synchronization bgp router-id 6.6.6.6 bgp log-neighbor-changes network 6.6.6.0 mask 255.255.255.0 neighbor 26.1.1.2 remote-as 1 no auto-summary R7: interface Loopback0 ip address 7.7.7.7 255.255.255.0 ! interface FastEthernet0/0 ip address 47.1.1.7 255.255.255.0 router bgp 7 no synchronization bgp router-id 7.7.7.7 bgp log-neighbor-changes network 7.7.7.0 mask 255.255.255.0 neighbor 47.1.1.4 remote-as 1 no auto-summary 实验结果:
BGP表