How to Configure BGP Local Preference Attribute

Hi Rene,

Is there any lesson on Route-map?

Thanks

Hi Bhargavi,

There is no lesson dedicated to explain route-map. But as explained previously to you in another ticket, route-map command is normally used to route redistribution and/or filtering.

If you want to have more information of route-map, I can refer you to Cisco website: Explanation of Route-map

Hi Rene,

I always get confused with the in and out direction. Would you please explain more about the when i should use direction in and when i should use out?

Thank you in advance.

Hi Helen,

It really depends on what you are trying to change, first of all, keep in mind that inbound/outbound is from the router’s perspective.

Local preference is something we change for OUR autonomous system so we have to apply it to prefixes that we receive. This means we’ll have to do it inbound.

AS Path prepending is something we want to do when we send it to a neighbor, so it has to be outbound. The same for MED…it is advertised to a neighbor.

Rene

please can you explain the route-map if we set it as out ?

Hussein,
I assume you are referring to this:
R3(config-router)#neighbor 192.168.13.1 route-map LOCALPREF in

If you switched the route-map LOCALPREF in to be route-map LOCALPREF out, then the route-map would no longer be doing anything. Essentially, this would cause R3 no longer to advertise a non-default Local Preference to R4.

The neighbor where the route-map statement being applied, is R1. R1 is in a different ASN than R3. As you may recall, the Local-Preference attribute is only sent to iBGP neighbors, so attempting to set the Local Preference attribute for an EBGP neighbor would result in no action.

2 Likes

19 posts were merged into an existing topic: How to Configure BGP Local Preference Attribute

yes, I kind of have the same question. Why do we have to use a protocol like OSPF on top of BGP? faster convergence ? looking for more of a real world kinda answer please

thank you

Hello Christopher.

IGP routing protocols are internal gateway protocols. They are designed for Autonomous Systems, that is, enterprise networks with the number of routers reaching several dozen. Even larger networks internally can be configured with IGPs if segregated into areas or separate autonomous systems. In general, IGPs have been designed to converge more efficiently for such networks than BGP.

It basically comes down to convergence time. OSPF, EIGRP and IS-IS as IGPs are designed to converge much faster than BGP would if employed within an enterprise network. Even tweaking BGP timers will not result in as good a performance as an IGP.

I hope this has been helpful!

Laz

I really want to clarify the use of “in” instead of “out” on the route-map.

The goal is to influence the routing decision from R4, right?

So why do you apply the route-map IN on R3 from R4? Should it not be IN on R4 from R3, or OUT from R3 to R4?

Hello Chris

BGP exchanges information between routers just like any other dynamic routing protocol. What the neighbor 192.168.13.1 route-map LOCALPREF in command is saying is any route information that is coming IN from the neighbour 192.168.13.1 should have a local preference set to 700 before sending it on and advertising it to any other BGP routers. If we used the neighbor 192.168.13.1 route-map LOCALPREF out command, this would define a local-preference of 700 to any BGP routes advertised from R3 to R4. The in and out keywords indicate the direction of the routing updates and not the direction of the actual traffic that will be sent/received.

I hope this has been helpful!

Laz

1 Like

I’m a little confused about when to use the next-hop self command. In this lesson I was looking at the example configurations and I noticed you used next-hop-self between when peering between R2 and R4 but not R3. I thought you would need the next-hop-self command between R2 and R3 b/c R4 was between them?

Thanks
Travis

Hi Travis,

Did you see this example?

You need next-hop-self for your iBGP neighbors when they don’t know how to reach the next hop of an eBGP neighbor. Another option is advertising the external network in iBGP.

In this example, R4 is the router with “issues” because R4 doesn’t know about 192.168.12.0/24 and 192.168.13.0/24. It will be able to learn 1.1.1.0/24 but can’t install it since it doesn’t know how to reach the next hop.

You could advertise these two networks but if you don’t, we can change the next hop for R4 on R2/R3. That’s what we do with the next-hop-self command. R2 and R3 change the next hop IP address to their own IP addresses that are known to R4.

Does this make sense?

Rene

1 Like

Thanks Rene. I want to know if there is any command to check the path attributes attached to a prefix which is received from a neighbor. “show ip bgp X.X.X.X” shows all the path attributes, which includes the one which the router also added. Is there any way we can check only attributes which we received from a neighbor.

Hello Kuldeep

The show ip bgp command has multiple filters that you can add. The following shows the command and all its options. I’ve taken a screenshot to retain the formatting:

image

This command and all of the details of the filters that can be used can be found at the following link.


You can also use output modifiers to further specify the data that you want to include. If you want to show the path attributes that are specific to a single next hop router ID, you can use the “|” output modifier with the keyword “include” and the router ID you want to include. For example

show ip bgp X.X.X.X | include 2.2.2.2

which will display all line containing the router ID 2.2.2.2.

I hope this has been helpful!

Laz

Hello Rene,

I had by mistakely added the network 192.168.12.0/24 and 192.168.13.0/24 in ospf on R2 and R3. I configured the Local pref on R3 to be 200.

On R4, when I do : sh ip bgp, I only see it from 3.3.3.3 and not from 2.2.2.2, see below:

R4#sh ip bgp
Network Next Hop Metric LocPrf Weight Path
*>i 1.1.1.0/24 3.3.3.3 0 200 0 1 i
R4#

When I corrected my error and removed the below ospf commands:

no network 192.168.12.0 0.0.0.255 area 0 from R2
no network 192.168.13.0 0.0.0.255 area 0 from R3

Then I again did sh ip bgp on R4 and I got it correct:

R4#sh ip bgp
Network Next Hop Metric LocPrf Weight Path
*>i 1.1.1.0/24 3.3.3.3 0 200 0 1 i

i 2.2.2.2 0 100 0 1 i
R4#

Just want to understand why?

Hello Viral

Hmm, that’s interesting. The inclusion of those networks in OSPF on R2 and R3 should have no bearing on the way BGP learns about the route to 1.1.1.0/24. Unless R2 or R3 created a network relationship with R1 via these network inclusions, it shouldn’t make a difference. Did you by any chance enable OSPF on R1 as well? Are you sure was BGP converged when you checked out the BGP table? Let us know and we can revisit the question.

I hope this has been helpful!

Laz

(It seems you posted the same message twice, so I’ve deleted one of your posts, just so you know.)

i had configured the same topology and it looks like the following on my R4 router

R4#show ip bgp
BGP table version is 4, 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, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 * i 1.1.1.0/24       3.3.3.3                  0    100      0 100 i
 *>i                  2.2.2.2                  0    100      0 100 i
 *>i 3.3.3.0/24       3.3.3.3                  0    100      0 i
 r>i 192.168.34.0     3.3.3.3                  0    100      0 i
R4#
R4#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

why cant i ping 1.1.1.1 , when the best route to 1.1.1.1 is via 2.2.2.2 (R2) ?

if i set the local pref on R3 to 600 by using bgp default local-preference 600, and then doing clear ip bgp it pings as mentioned below from r4

R4#show ip bgp
BGP table version is 10, 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, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i 1.1.1.0/24       3.3.3.3                  0    600      0 100 i
 * i                  2.2.2.2                  0    100      0 100 i
 *>i 3.3.3.0/24       3.3.3.3                  0    600      0 i
 r>i 192.168.34.0     3.3.3.3                  0    600      0 i

R4#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/97/132 ms

Hi Atif,

To solve a question like this, you need to think about the source and destination address in the ping packet from R4.

The destination is 1.1.1.1 and we have a route for that. What is the source?

R4#show ip route 2.2.2.2
Routing entry for 2.2.2.2/32
  Known via "ospf 1", distance 110, metric 2, type intra area
  Last update from 192.168.24.2 on GigabitEthernet0/1, 00:13:25 ago
  Routing Descriptor Blocks:
  * 192.168.24.2, from 2.2.2.2, 00:13:25 ago, via GigabitEthernet0/1
      Route metric is 2, traffic share count is 1

2.2.2.2 is our next hop and we use GigabitEthernet0/1 to reach it, that’s the 192.168.24.0/24 subnet. This means that R4 uses 192.168.24.4 as its source address.

R2 has a route to 1.1.1.1 so we know that the packet from R4 makes it to R1. Does R1 know about 192.168.24.0/24 ? Let’s find out:

R1#show ip route 192.168.24.0
% Network not in table

R1 doesn’t know 192.168.24.0/24. To fix this, you could advertise this network in BGP on R2 or R4:

R4(config)#router bgp 2
R4(config-router)#network 192.168.24.0

R1 now learns it:

R1#show ip route 192.168.24.0
Routing entry for 192.168.24.0/24
  Known via "bgp 1", distance 20, metric 0
  Tag 2, type external
  Last update from 192.168.12.2 00:00:25 ago
  Routing Descriptor Blocks:
  * 192.168.12.2, from 192.168.12.2, 00:00:25 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 2
      MPLS label: none

And the ping will work:

R4#ping 1.1.1.1 repeat 1
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 8/8/8 ms

Rene

1 Like

Hi Rene and staff,
can we use Local Pref in the case below with only one peer relation between R1 et R2 to force traffic on one link only (just a school case)
Image21
I can configure static routes between loop0 to bring up the peer relation
But how can i apply a route-map to BGP neighbor as it is in the lesson ?

Thanks