BGP Attribute Locally Originated

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.

Don’t confuse originated with origin, as explained in the origin code lesson.

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:

Bgp As1 As2 R1 R2 Two Loopbacks Topology

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!


Forum Replies

  1. 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.

  2. 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

Ask a question or join the discussion by visiting our Community Forum