1. 程式人生 > 實用技巧 >BGP路由反射器

BGP路由反射器

當一個as中包含的ibgp對等體太多時,配置全互聯就比較麻煩,這時候可以起路由反射器。將一個路由器配置成路由反射器(RR),其他的ibgp路由器當做客戶,這些客戶只與RR建立對等體關係,而不是與另外的每個路由器對等。(可以大大的減少配置)
反躲規則:
1)如果路由是從非客戶過來則反躲給客戶,不會給非客戶;
2)如果路由是從客戶過來,會反射給客戶和非客戶;
3)如果路由是從EBGP鄰居過來,反射給客戶和非客戶。

!
hostname R1
!
router ospf 1
router-id 1.1.1.1
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
no synchronization
bgp log-neighbor-changes
network 172.16.1.0 mask 255.255.255.0
network 172.16.2.0 mask 255.255.255.0
network 172.16.3.0 mask 255.255.255.0
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 route-reflector-client

neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 update-source Loopback0
no auto-summary
!
hostname R2
!
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
no synchronization
bgp log-neighbor-changes
network 172.16.1.0 mask 255.255.255.0
network 172.16.4.0 mask 255.255.255.0
network 172.16.5.0 mask 255.255.255.0
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 route-reflector-client
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 route-reflector-client
neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 update-source Loopback0
no auto-summary
!
hostname R3
!
router ospf 1
router-id 3.3.3.3
log-adjacency-changes
passive-interface Serial1/0
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 172.16.6.5 remote-as 200
no auto-summary
!
hostname R4
!
router ospf 1
router-id 4.4.4.4
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
no auto-summary

!
hostname R5
!
router bgp 200
no synchronization
bgp log-neighbor-changes
network 172.16.6.0 mask 255.255.255.0
network 192.168.1.0
network 192.168.2.0
neighbor 172.16.6.3 remote-as 100
no auto-summary

R4#show ip bgp
BGP table version is 25, 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
r i172.16.1.0/24 2.2.2.2 0 100 0 i
r>i 1.1.1.1 0 100 0 i
r i172.16.2.0/24 1.1.1.1 0 100 0 i
r>i 1.1.1.1 0 100 0 i
r i172.16.3.0/24 1.1.1.1 0 100 0 i
r>i 1.1.1.1 0 100 0 i
r>i172.16.4.0/24 2.2.2.2 0 100 0 i
r>i172.16.5.0/24 2.2.2.2 0 100 0 i
r i172.16.6.0/24 172.16.6.5 0 100 0 200 i
r>i 172.16.6.5 0 100 0 200 i
*>i192.168.1.0 172.16.6.5 0 100 0 200 i
* i 172.16.6.5 0 100 0 200 i
*>i192.168.2.0 172.16.6.5 0 100 0 200 i
* i 172.16.6.5 0 100 0 200 i
R4#show ip bgp 192.168.1.0
BGP routing table entry for 192.168.1.0/24, version 24
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
200
172.16.6.5 (metric 192) from 1.1.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, internal, best
Originator: 3.3.3.3, Cluster list: 1.1.1.1
200
172.16.6.5 (metric 192) from 2.2.2.2 (2.2.2.2)
Origin IGP, metric 0, localpref 100, valid, internal
Originator: 3.3.3.3, Cluster list: 2.2.2.2
為了節省開銷,當在同一個區域時,兩 個RR中通過指定同一個cluster-id,可以節省記憶體存放學過來的路由條目,因為預設情況下,一個RR就是一個cluster,這個兩 個RR之間相互發放路由,就多出一倍,如果將兩 個RR同指定為一個cluster後,就可以減少開銷 R1(config-router)#bgp cluster-id 1
R2(config-router)#bgp cluster-id 1
在沒有指定之前:
R1#show ip bgp
BGP table version is 35, 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
* i172.16.1.0/24 2.2.2.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 172.16.2.0/24 0.0.0.0 0 32768 i
*> 172.16.3.0/24 0.0.0.0 0 32768 i
r>i172.16.4.0/24 2.2.2.2 0 100 0 i
r>i172.16.5.0/24 2.2.2.2 0 100 0 i
r i172.16.6.0/24 172.16.6.5 0 100 0 200 i
r>i 172.16.6.5 0 100 0 200 i
* i192.168.1.0 172.16.6.5 0 100 0 200 i
*>i 172.16.6.5 0 100 0 200 i
* i192.168.2.0 172.16.6.5 0 100 0 200 i
*>i 172.16.6.5 0 100 0 200 i

R2#show ip bgp
BGP table version is 26, local router ID is 2.2.2.2
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
* i172.16.1.0/24 1.1.1.1 0 100 0 i
*> 0.0.0.0 0 32768 i
r>i172.16.2.0/24 1.1.1.1 0 100 0 i
r>i172.16.3.0/24 1.1.1.1 0 100 0 i
*> 172.16.4.0/24 0.0.0.0 0 32768 i
*> 172.16.5.0/24 0.0.0.0 0 32768 i
r i172.16.6.0/24 172.16.6.5 0 100 0 200 i
r>i 172.16.6.5 0 100 0 200 i
* i192.168.1.0 172.16.6.5 0 100 0 200 i
*>i 172.16.6.5 0 100 0 200 i
* i192.168.2.0 172.16.6.5 0 100 0 200 i
*>i 172.16.6.5 0 100 0 200 i
指定之後: R1#show ip bgp
BGP table version is 35, 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
* i172.16.1.0/24 2.2.2.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 172.16.2.0/24 0.0.0.0 0 32768 i
*> 172.16.3.0/24 0.0.0.0 0 32768 i
r>i172.16.4.0/24 2.2.2.2 0 100 0 i
r>i172.16.5.0/24 2.2.2.2 0 100 0 i
r>i172.16.6.0/24 172.16.6.5 0 100 0 200 i
*>i192.168.1.0 172.16.6.5 0 100 0 200 i
*>i192.168.2.0 172.16.6.5 0 100 0 200 i

R2#show ip bgp
BGP table version is 26, local router ID is 2.2.2.2
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
* i172.16.1.0/24 1.1.1.1 0 100 0 i
*> 0.0.0.0 0 32768 i
r>i172.16.2.0/24 1.1.1.1 0 100 0 i
r>i172.16.3.0/24 1.1.1.1 0 100 0 i
*> 172.16.4.0/24 0.0.0.0 0 32768 i
*> 172.16.5.0/24 0.0.0.0 0 32768 i
r>i172.16.6.0/24 172.16.6.5 0 100 0 200 i
*>i192.168.1.0 172.16.6.5 0 100 0 200 i
*>i192.168.2.0 172.16.6.5 0 100 0 200 i
在R4上看到:
R4#show ip bgp 192.168.1.0
BGP routing table entry for 192.168.1.0/24, version 33
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
200
172.16.6.5 (metric 192) from 1.1.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, internal, best
Originator: 3.3.3.3, Cluster list: 0.0.0.1
200
172.16.6.5 (metric 192) from 2.2.2.2 (2.2.2.2)
Origin IGP, metric 0, localpref 100, valid, internal
Originator: 3.3.3.3, Cluster list: 0.0.0.1