R1與R2間EBGP,R4與R5間EBGP,R2與R4間IBGP,但因爲R3學不到相關的路由,形成路由黑洞。處理的方法主要如下幾個:redis
如下是路由器配置:ide
R1:oop
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.252
!
router bgp 100
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
neighbor 192.168.1.2 remote-as 200router
R5:ip
interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface FastEthernet0/1
ip address 192.168.1.14 255.255.255.252
speed auto
duplex auto
!
router bgp 300
bgp log-neighbor-changes
network 5.5.5.5 mask 255.255.255.255
neighbor 192.168.1.13 remote-as 200路由
一、IBGP全鏈接rem
R2:io
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.5 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.2 255.255.255.252
!
router ospf 1
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 200
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 4.4.4.4 remote-as 200
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
neighbor 192.168.1.1 remote-as 100ast
R3:cli
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.9 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.6 255.255.255.252
!
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 4.4.4.4 remote-as 200
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.13 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.10 255.255.255.252
!
router ospf 1
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 3.3.3.3 remote-as 200
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 192.168.1.14 remote-as 300
二、路由反射器
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.5 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.2 255.255.255.252
!
router ospf 1
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 200
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 192.168.1.1 remote-as 100
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.9 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.6 255.255.255.252
!
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 route-reflector-client
neighbor 4.4.4.4 remote-as 200
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 route-reflector-client
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.13 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.10 255.255.255.252
!
router ospf 1
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 200
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 192.168.1.14 remote-as 300
三、BGP邦連
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.5 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.2 255.255.255.252
!
router ospf 1
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
!
router bgp 65530
bgp router-id 2.2.2.2
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65531
neighbor 3.3.3.3 remote-as 65531
neighbor 3.3.3.3 ebgp-multihop 255
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 192.168.1.1 remote-as 100
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.9 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.6 255.255.255.252
!
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 65531
bgp router-id 3.3.3.3
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65530 65532
neighbor 2.2.2.2 remote-as 65530
neighbor 2.2.2.2 ebgp-multihop 255
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 4.4.4.4 remote-as 65532
neighbor 4.4.4.4 ebgp-multihop 255
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.13 255.255.255.252
speed auto
duplex auto
!
interface FastEthernet0/1
ip address 192.168.1.10 255.255.255.252
!
router ospf 1
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 65532
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65531
neighbor 3.3.3.3 remote-as 65531
neighbor 3.3.3.3 ebgp-multihop 255
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 192.168.1.14 remote-as 300
四、配置MPLS
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.5 255.255.255.252
mpls ip
!
interface FastEthernet0/1
ip address 192.168.1.2 255.255.255.252
!
router ospf 1
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 4.4.4.4 remote-as 200
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
neighbor 192.168.1.1 remote-as 100
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.9 255.255.255.252
mpls ip
!
interface FastEthernet0/1
ip address 192.168.1.6 255.255.255.252
mpls ip
!
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
network 192.168.1.8 0.0.0.3 area 0
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.13 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.10 255.255.255.252
mpls ip
!
router ospf 1
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 192.168.1.14 remote-as 300
五、BGP路由重分發到IGP(不建議)
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.5 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.2 255.255.255.252
!
router ospf 1
router-id 2.2.2.2
redistribute bgp 200 subnets
network 2.2.2.2 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 4.4.4.4 remote-as 200
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
neighbor 192.168.1.1 remote-as 100
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.9 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.6 255.255.255.252
!
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 192.168.1.4 0.0.0.3 area 0
network 192.168.1.8 0.0.0.3 area 0
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.13 255.255.255.252
!
interface FastEthernet0/1
ip address 192.168.1.10 255.255.255.252
!
router ospf 1
router-id 4.4.4.4
redistribute bgp 200 subnets
network 4.4.4.4 0.0.0.0 area 0
network 192.168.1.8 0.0.0.3 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 192.168.1.14 remote-as 300
說明: 由於水平分割的抑制,BGP路由器從IBGP鄰居收的路由不會再傳遞給IBGP鄰居,這是爲了防止環路的產生。即便R2與R三、R3與R4創建了鄰居關係,在沒有其餘設置的狀況下,R3也不會將R2傳遞來的路由傳遞給R4,一樣R3也不會將R4傳遞過來的路由給R2。