[Theoretical Explanation] The third principle of BGP route selection: preference is given to locally generated BGP paths; and there are three ways of locally generated BGP: 1. issued by network command 2. generated by aggregate command aggregation 3. redistributed by redistribute command Posted in.
So who should choose when the same path is generated in multiple ways? The principle given by CISCO is this:
Local paths that are sourced by the network or redistribute commands are preferred over local aggregates that are sourced by the aggregate-address command.
[Decomposition experiment 1]
验证the local path from the network command is prefer to the local path from the aggregate command
基本配置:
R1:
interface Loopback0
ip address 1.1.0.1 255.255.255.0 secondary
ip address 1.1.1.1 255.255.255.0
!
interface f0/0
ip address 12.1.1.1 255.255.255.0
!
router bgp 12
no synchronization
bgp router-id 1.1.1.1
network 1.1.0.0 mask 255.255.252.0
network 1.1.0.0 mask 255.255.255.0
aggregate-address 1.1.0.0 255.255.252.0
neighbor 12.1.1.2 remote-as 12
no auto-summary
!
ip classless
ip route 1.1.0.0 255.255.252.0 Null0
R2:
interface f0/0
ip address 12.1.1.2 255.255.255.0
!
router bgp 12
no synchronization
bgp router-id 2.2.2.2
neighbor 12.1.1.1 remote-as 12
no auto-summary
View the BGP routing table on R1
R1#sh ip bg
BGP table version is 5, 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 &am p;nb sp; Metric LocPrf Weight Path
*> 1.1.0.0/24 0.0.0.0 0 32768 i
*> 1.1.0.0/22 0.0.0.0 0 32768 i
* 0.0.0.0 32768 i
R1#sh ip bg 1.1.0.0 255.255.252.0
BGP routing table entry for 1.1.0.0/22, version 5
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Advertised to non peer-group peers:
12.1.1.2
Local
0.0.0.0 from 0.0.0.0 (1.1.1.1)
Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
Local, (aggregated by 12 1.1.1.1)
0.0.0.0 from 0.0.0.0 (1.1.1.1)
Origin IGP, localpref 100, weight 32768, valid, aggregated, local, atomic-aggregate
You can see that the entries issued by the network command are selected first, which proves that: network> aggregate-address
[分解实验2]验证the local path from the redistribute command is prefer to the local path from the aggregate command
Delete the netwok command on R1 and reissue the static entry BGP table
R1(config)#router bg 12
R1(config-router)#no network 1.1.0.0 mask 255.255.252.0
R1(config-router)#redistribute connected static
This way you can see the final effect is as follows
R1#sh ip bg
BGP table version is 10, 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 &am p;nb sp; Metric LocPrf Weight Path
*> 1.1.0.0/24 0.0.0.0 0 32768 i
*> 1.1.0.0/22 0.0.0.0 0 32768 ?
* 0.0.0.0 32768 i
R1#sh ip bg 1.1.0.0 255.255.252.0
BGP routing table entry for 1.1.0.0/22, version 8
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Advertised to non peer-group peers:
12.1.1.2
Local
0.0.0.0 from 0.0.0.0 (1.1.1.1)
Origin incomplete, metric 0, localpref 100, weight 32768, valid, sourced, best
Local, (aggregated by 12 1.1.1.1)
0.0.0.0 from 0.0.0.0 (1.1.1.1)
Origin IGP, localpref 100, weight 32768, valid, aggregated, local, atomic-aggregate
This shows that redistribute> aggregate-address
In summary: network / redistribute> aggregate-address
Note: When originating from local at the same time, there is no need to compare network and redistribute. The two cannot coexist. As in the above experiment, R1 does not delete the network and republishes static. Redistribute has no effect. I will add a reply to this question as soon as possible