Lesson Contents
The locally originated attribute is one of the BGP attributes that BGP uses in its path selection. Locally originated prefixes are prefixes that the local router installed in the BGP table. This can be done with the network command, redistribution, or aggregation.
BGP prefers prefixes that it installs itself over prefixes it learns from other BGP routers. You can recognize locally originated prefixes because the next hop shows up as 0.0.0.0.
To determine the best BGP path, weight, and local preference are checked first. Locally originated prefixes are third on the list. If locally originated prefixes are not the tiebreaker, we check the fourth attribute, the AS path length.
In this lesson, we’ll see what it looks like in action. If you haven’t seen a BGP table before, you might want to check first the How to read a BGP table lesson.
Configuration
This is the topology I’ll use:
We have two BGP routers, each in its own autonomous system (AS). I configured the 12.12.12.12/32 prefix on the loopback 0 interface on both routers. R2 advertises 12.12.12.12/32, but R1 doesn’t (yet). These routers run Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.9(3)M6, RELEASE SOFTWARE (fc1)
Configurations
Want to take a look for yourself? Here, you will find the startup configuration of each device.
R1
hostname R1
!
ip cef
!
interface Loopback0
ip address 12.12.12.12 255.255.255.255
!
interface GigabitEthernet0/0
ip address 192.168.12.1 255.255.255.0
!
router bgp 1
bgp router-id 1.1.1.1
neighbor 192.168.12.2 remote-as 2
!
end
R2
hostname R2
!
ip cef
!
interface Loopback0
ip address 12.12.12.12 255.255.255.255
!
interface GigabitEthernet0/0
ip address 192.168.12.2 255.255.255.0
!
router bgp 2
bgp router-id 2.2.2.2
network 12.12.12.12 mask 255.255.255.255
neighbor 192.168.12.1 remote-as 1
!
end
Let’s have a look at the BGP table of R1:
R1#show ip bgp
BGP table version is 2, local router ID is 192.168.12.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
*> 12.12.12.12/32 192.168.12.2 0 0 2 i
R1 learns about 12.12.12.12/32 from R2, and because this is the only path, this is the best path. Let’s configure R1 to install 12.12.12.12/32 in the BGP table:
R1(config)#router bgp 1
R1(config-router)#network 12.12.12.12 mask 255.255.255.255
Let’s see how this influences the BGP table:
R1#show ip bgp
BGP table version is 4, local router ID is 192.168.12.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
*> 12.12.12.12/32 0.0.0.0 0 32768 i
* 192.168.12.2 0 0 2 i
R1 now selects its locally originated path. You can recognize it because the next hop is 0.0.0.0. However, R1 selected this path because the weight is set to 32768. This is the first tiebreaker.
To make sure weight isn’t used as a tiebreaker, I’ll use a route-map to set the weight of the path through R2 to 32768 as well:
R1(config)#ip access-list standard R2_L0
R1(config-std-nacl)#permit host 12.12.12.12
R1(config)#route-map SET_WEIGHT_INBOUND permit 10
R1(config-route-map)#match ip address R2_L0
R1(config-route-map)#set weight 32768
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map SET_WEIGHT_INBOUND in
Let’s reset the BGP neighbor adjacency:
R1#clear ip bgp *
Here’s what we have now:
R1#show ip bgp
BGP table version is 4, local router ID is 192.168.12.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
*> 12.12.12.12/32 0.0.0.0 0 32768 i
* 192.168.12.2 0 32768 2 i
The weight is now the same, so this is no longer used as a tiebreaker. The second attribute BGP checks is the local preference, which is empty for both paths. The third tiebreaker is locally originated, which is the reason why R1 prefers its own path.
Configurations
Want to take a look for yourself? Here you will find the final configuration of each device.
R1
hostname R1
!
ip cef
!
interface Loopback0
ip address 12.12.12.12 255.255.255.255
!
interface GigabitEthernet0/0
ip address 192.168.12.1 255.255.255.0
!
router bgp 1
bgp router-id 1.1.1.1
network 12.12.12.12 mask 255.255.255.255
neighbor 192.168.12.2 remote-as 2
neighbor 192.168.12.2 route-map SET_WEIGHT_INBOUND in
!
ip access-list standard R2_L0
permit 12.12.12.12
!
route-map SET_WEIGHT_INBOUND permit 10
match ip address R2_L0
set weight 32768
!
end
R2
hostname R2
!
ip cef
!
interface Loopback0
ip address 12.12.12.12 255.255.255.255
!
interface GigabitEthernet0/0
ip address 192.168.12.2 255.255.255.0
!
router bgp 2
bgp router-id 2.2.2.2
network 12.12.12.12 mask 255.255.255.255
neighbor 192.168.12.1 remote-as 1
!
end
Conclusion
You have learned how BGP uses locally originated prefixes as a tiebreaker in its best path selection process. You can recognize these because the next hop is always 0.0.0.0.
I hope you enjoyed this lesson. If you have any questions, feel free to leave a comment!
Hi
here you have created the route-map
SET_WEIGHT_INBOUND
, but seems like you missed to set the weight to 32768 under it, in the write up. Please check. looks like a small typo.Great content, thank you.
Hello Rajni
Yes, you are correct, thanks for pointing that out. I will let Rene know to make the correction.
Glad to hear tat you’re enjoying the content!
Laz
Thank you @rajni.genius1104 . I just fixed this.
Rene
Hi,
I have an observation regarding the following statement:
I created the following lab:
1.1.1.0/24—(R1)—OSPF—(R2)—iBGP----(R3)----1.1.1.0/24
Redistribution was used for 1.1.1.0/24 on R2 and the network command on R3. On R2, weight was modified to be the same, LocalPref of 100 remained the same. BGP selected the locally redistributed route over the one learned via the network command on R3, as expected.
However, the next hop was not 0.0.0.0 and is set the the IGP’s (OSPF) next hop. It seems next
... Continue reading in our forumHello Samir
First of all, you mention that:
I think you mean that redistribution was used on R1, correct?
Now assuming that is indeed correct, the next thing I’d like to point out is that the locally originated routes attribute refers to routes that have been originated on the local router. So the only router you will see 0.0.0.0 as a next hop is the router in which the
... Continue reading in our forumnetwork
command