As part of its path selection process, BGP makes use of the locally originated attribute, among other BGP attributes. Prefixes that were added to the BGP table by the local router are known as locally originated prefixes. Redistribution, aggregation, or the network command can do this.
When BGP learns a prefix from another BGP router, it likes the ones it comes up with on its own. The next hop shows up as 0.0.0.0, which lets you tell which prefixes are local.
First, weight and local preference are looked at to find the best BGP path. Third on the list are Locally originated prefixes. We check the fourth attribute, the AS path length, if locally generated prefixes are not the one that breaks the tie.
Configuration
We’ll employ the following topology:
Each of our two autonomous systems (AS) houses a BGP router. On the loopback 0 interface of both routers, we set the 1.1.1.1/32 prefix. R2 advertise 1.1.1.1/32, but R1 has not done so yet.
Take a look at R1’s BGP table:
R1#show ip bgp
BGP table version is 2, local router ID is 192.168.120.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 192.168.120.2 0 0 200 i
The information about 1.1.1.1/32 is acquired by R1 from R2, and given that this is the only path, it is the most beneficial path. To install 1.1.1.1/32 in the BGP table, let’s configure R1 as follows:
R1(config)#router bgp 1
R1(config-router)#network 1.1.1.1 mask 255.255.255.255
Take a look at how this changes the BGP table:
R1#show ip bgp
BGP table version is 4, local router ID is 192.168.120.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
* 192.168.120.2 0 0 200 i
At this point, R1 chooses the path that originated locally. Due to the fact that the following hop is 0.0.0.0, you are able to identify it. It is important to note that R1 chose this particular path since the weight is set to 32768. The first tiebreaker is going to be this.