# How to Configure BGP Local Preference Attribute

**URL:** <https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953>\
**Category:** Lessons Discussion\
**Created:** [December 24, 2016, 6:34pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953 "2016-12-24T18:34:24Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [September 2, 2019, 6:41am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/83 "2019-09-02T06:41:55Z")

</div>

Hello Sims

With the above configuration using the “IN” keyword, any BGP routes that are recieved from that neighbor will have a local preference set to 700. In other words, if the 192.168.13.1 neighbor sends R3 a prefix to 1.1.1.0/24, R3 will set the LOCALPREF to 700 before installing it in its BGP table.

If you used the “OUT” keyword, then this route-map will be applied to prefixes that are sent from R3 to the 192.168.13.1 neighbor. For example, if R3 sends the 2.2.2.0/24 prefix to the 192.168.13.1 neighbor, it will adjust the LOCALPREF of that prefix to 700 before sending it to its neighbor.

Remember that the “IN” and “OUT” keywords apply to the exchange of BGP information and not to the actual user traffic that is being exchanged.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![sims](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/c6cbf5/32.png) [@sims](https://forum.networklessons.com/u/sims)\
**Post date:** [September 2, 2019, 12:03pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/84 "2019-09-02T12:03:41Z")

</div>

Hi,

```
R2(config)#router bgp 2
R2(config-router)#neighbor 4.4.4.4 remote-as 2
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0

```

why bgp does not form neighbourship if I am not adding “neighbor 4.4.4.4 update-source loopback 0”  
Thanks

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [September 4, 2019, 6:01am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/85 "2019-09-04T06:01:04Z")

</div>

Hello Sims

By default, for a BGP neighbor relationship to be established, the source IP address of BGP packets must be the same as the `neighbor ip-address` set on the neighboring router. By default, the packet’s source IP address for BGP is the outgoing interface. This is also called the “best local address”. In your example above, if you don’t issue the `update-source` command, this results in a BGP neighor relationship that is attempting to be created using 4.4.4.4 as the IP address of the local BGP peer, and 192.168.23.2 as the source of the BGP packets. This is an incorrect configuration and will not function until you redefine the source interface that BGP will be using. This is why once you issue the update-source command, the BGP peering takes place successfully.

If you used the 192.168.23.2 address in the `neighbor` command, then the `update-source` command would not be needed because both the source address and the exit interface would have the same IP address.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![sims](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/c6cbf5/32.png) [@sims](https://forum.networklessons.com/u/sims)\
**Post date:** [September 4, 2019, 6:32pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/86 "2019-09-04T18:32:12Z")

</div>

Hi,

> [@lagapidis](#):
>
> If you used the “OUT” keyword, then this route-map will be applied to prefixes that are sent from R3 to the 192.168.13.1 neighbor. For example, if R3 sends the 2.2.2.0/24 prefix to the 192.168.13.1 neighbor, it will adjust the LOCALPREF of that prefix to 700 before sending it to its neighbor.

local prefernce is available only in the AS ,so what is the point of using OUT ?  
Please give an example with sh ip bgp command

Thanks

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [September 5, 2019, 4:51am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/87 "2019-09-05T04:51:39Z")

</div>

Hello Sims

Yes you are correct, the example I gave would not change anything because R1 and R3 are eBGP peers, and LOCALPREF is not exchanged between eBGP routers. The logic however remains the same. You can apply the example I gave to an iBGP peering, where R3 could have the LOCALPREF adjusted for any prefixes that are sent to R4. For example take a look at the following :

```
R3(config)#route-map LOCALPREF permit 10
R3(config-route-map)#set local-preference 700

R3(config)#router bgp 2
R3(config-router)#neighbor 192.168.34.4 route-map LOCALPREF out

```

With the above configuration, any external routes (such as that to 1.1.1.0/24 for example) that are shared by R3 to R4 will have the route-map applied, which means the LOCALPREF would be adjusted to 700, causing R4 to prefer to reach 1.1.1.0/24 via R2.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![tsirgogik](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/tsirgogik/32/1899_2.png) [@tsirgogik](https://forum.networklessons.com/u/tsirgogik)\
**Post date:** [September 13, 2019, 1:15pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/88 "2019-09-13T13:15:09Z")

</div>

Hello,

I have a setup very similar topology to the one in the course. The only difference with the topology in the local preference course is that I have R4 in the place of R3 and vice versa. In addition, I have used loopback intefaces to form the peerings both for eBGP and iBGP with all the pre-requisites (static route, update source loopback , ebgp-multihop for the eBGP peers) , and the equivalent (ospf and so on) for the iBGP peers.

This is where my question comes in place,

I advertise 2 prefixes from R1, that is 1.1.1.1/32 and 10.10.10.10/32

In the R4, both show with next hop 1.1.1.1

 ![BGP-LOCAPREF-TOPOLOGY](https://cdn-forum.networklessons.com/uploads/default/original/2X/4/4351bb3979c0b01a612381c3a61697f857c7b0e0.jpeg)

Below the output from show ip bgp in the R4 router.

 ![SH_IP_BGP_R4](https://cdn-forum.networklessons.com/uploads/default/original/2X/4/4af48a7d256f81f343236b5495d2c2606be86768.jpeg)

and in the R3,

 ![SH_IP_BGP_R3](https://cdn-forum.networklessons.com/uploads/default/original/2X/7/7d5a155864f6d9d5e5157e8e7ca7444ebd123be7.jpeg)

So in my case, it appears that both prefixes use R2 loopback to reach R3.

What if I want to advertise 1.1.1.1/32 from R2 loopback and 10.10.10.10/32 from R4 loopback, while keeping the loopback peerings as they are ?

The problem in my case is that in R4, both prefixes appear to have the same next-hop.

Thank you in advance for recommendations,

Konstantinos

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [September 15, 2019, 3:02pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/89 "2019-09-15T15:02:56Z")

</div>

Hello Konstantinos

The local preference attribute applied in this lesson is applied to all routes that are learned from a particular neighbor. However, it is possible to selectively choose which routes the local preference attribute will be applied to. You can add a match statement to the route-map that will specify the particular path that you would like to add. So for your example above, you can add a route-map to R2 that will increase the local preference of the route to 1.1.1.1 that is advertised from R2 to R3. The result would be that R3 would have R2 as the next hop for only this route while 10.10.10.10 would maintain a next hop of R4.

There are other ways to adjust this as well using other attributes assigned in route maps. These attributes include Weight and AS Path Length, both of which can be further researched below:

> **[How to Configure BGP Weight Attribute](https://networklessons.com/bgp/how-to-configure-bgp-weight-attribute)**
>
> BGP Weight attribute is Cisco Proprietary and used to influence BGP Path Selection. In this lesson, you will learn how to configure it.

> **[How to configure BGP AS Path Prepending](https://networklessons.com/bgp/how-to-configure-bgp-as-path-prepending)**
>
> AS Path Prepending is a common BGP technique to influence path selection. In this lesson, you will learn how to configure AS Path prepending.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![monsterunni835](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/monsterunni835/32/2456_2.png) [@monsterunni835](https://forum.networklessons.com/u/monsterunni835)\
**Post date:** [March 14, 2020, 7:14pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/91 "2020-03-14T19:14:04Z")

</div>

![LP & RR](https://cdn-forum.networklessons.com/uploads/default/original/2X/7/711cbcc0816b45b0fea3431b6bc9626f5c7bfa9c.jpeg)

Hello Rene/Las,  
On above i have pasted my topology with necessary configuration. The prefix 1.1.1.1/32 is coming from R1 and get injects in to AS -2 with local preference configured on R3.

You can use local preference to choose the outbound external BGP path.  
Local preference is sent to all internal BGP routers in your autonomous system.  
Default value is 100.  
The path with the highest local preference is preferred.

The second line is very confusing and my question is also to know about the LP propagation between the routers participating in AS-2.  
Adding my observations once configured the LP policy on R3 router is mentioned below.

1. Before implementing LP configurations ,R2 can able to advertise the same route 1.1.1.1/32 towards R4.
2. After LP configured,only the highest LP tagged route will be there in R4’s BGP table which never allows R2 to advertise the same route towards neighbor belongs to same AS -2.

Why it is like that ? Which bgp message is using for that attribute propagation to inform all i-BGP neighbors about this preferred exit entry?

And i think because of this we won’t receive two routes from different path in bgp table of R4 right? Can be a reason to block maximum path configuration for load sharing using two paths?

```
Network Next Hop Metric LocPrf Weight Path
* i 1.1.1.1/32 3.3.3.3 0 100 0 1 ?
*>i 2.2.2.2 0 100 0 1 ?

```

* * *

This is pre LP implementation Maximum path because we have two path in BGP table achieved load balancing.

```
Network Next Hop Metric LocPrf Weight Path
*mi 1.1.1.1/32 3.3.3.3 0 100 0 1 ?
*>i 2.2.2.2 0 100 0 1 ?

   1.0.0.0/32 is subnetted, 1 subnets
B 1.1.1.1 [200/0] via 3.3.3.3, 00:00:39
                 [200/0] via 2.2.2.2, 00:00:39
B 192.168.13.0/24 [200/0] via 3.3.3.3, 00:00:39
                 [200/0] via 2.2.2.2, 00:00:39
Router#

```

Let me add few more points here below  
R2#show ip bgp neighbors 192.168.12.1 received-routes

```
 Network Next Hop Metric LocPrf Weight Path

```

- 1.1.1.1/32 192.168.12.1 0 0 1 ? ----------------\> Received routes but not advertising from here towards 4.4.4.4 (R4) after higher LP has implemented on R3.

R2#show ip bgp neighbors 4.4.4.4 advertised-routes

```
 Network Next Hop Metric LocPrf Weight Path

```

\*\> 22.22.22.22/32 192.168.12.1 0 0 1 ? ------------\> blank for 1.1.1.1/32  
r\> 192.168.12.0 192.168.12.1 0 0 1 ?  
\*\> 192.168.13.0 192.168.12.1 0 0 1 ?

My question is why 1.1.1.1/32 is valid route only in R2 …On what basis R2 took decision to keep 1.1.1.1/32 as valid route not best .If it becomes best it is supposed to advertise from here right?  
On what basis R2 took that decision to keep 1.1.1.1/32 as valid only .So i think we need to know the BGP propagation of LP attribute using which type of messages in AS-2.  
Correct me if i am wrong in my understanding.

Regards  
Unni

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [March 15, 2020, 8:19am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/92 "2020-03-15T08:19:40Z")

</div>

Hello Unni

I labbed this up to try to replicate your results. It is true that before implementing LP, you find that R4 indeed has both routes to reach 1.1.1.1 via R2 and R3. Here is the BGP table I get for this:

```
     Network Next Hop Metric LocPrf Weight Path
 * i 1.1.1.0/24 3.3.3.3 0 100 0 1 i
 *>i 2.2.2.2 0 100 0 1 i

```

And the routing table routes traffic to 1.1.1.1 via R2:

```
R4#show ip route

  1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [200/0] via 2.2.2.2, 00:01:08

```

Now if we add the local preference configuration on R3, this changes on R4:

```
R4#show ip bgp
     Network Next Hop Metric LocPrf Weight Path
 *>i 1.1.1.0/24 3.3.3.3 0 600 0 1 i
 * i 2.2.2.2 0 100 0 1 i

```

And the routing table changes accordingly:

```
R4#show ip route

  1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [200/0] via 3.3.3.3, 00:01:01

```

> [@monsterunni835](#):
>
> After LP configured,only the highest LP tagged route will be there in R4’s BGP table which never allows R2 to advertise the same route towards neighbor belongs to same AS -2.

As you can see here, the BGP table of R4 still has the advertised route to 1.1.1.1 via R2, but with a local preference of 100 while that of R3 has a local preference of 600. So both routes **are indeed advertised to R4** , but only the best is installed in the routing table.

Now in your output of the routing table above, where local pref is the same value, you have both routes in the routing table, because you have increased the maximum paths.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![monsterunni835](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/monsterunni835/32/2456_2.png) [@monsterunni835](https://forum.networklessons.com/u/monsterunni835)\
**Post date:** [March 15, 2020, 8:22am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/93 "2020-03-15T08:22:47Z")

</div>

[quote=“monsterunni835, post:91, topic:953”]  
Let me add few more points here below  
R2#show ip bgp neighbors 192.168.12.1 received-routes

```auto
 Network Next Hop Metric LocPrf Weight Path

```

- 1.1.1.1/32 192.168.12.1 0 0 1 ? ----------------\> Received routes but not advertising from here towards 4.4.4.4 (R4) after higher LP has implemented on R3.

R2#show ip bgp neighbors 4.4.4.4 advertised-routes

```auto
 Network Next Hop Metric LocPrf Weight Path

```

\*\> 22.22.22.22/32 192.168.12.1 0 0 1 ? ------------\> blank for 1.1.1.1/32  
r\> 192.168.12.0 192.168.12.1 0 0 1 ?  
\*\> 192.168.13.0 192.168.12.1 0 0 1 ?

My question is why 1.1.1.1/32 is valid route only in R2 …On what basis R2 took decision to keep 1.1.1.1/32 as valid route not best .If it becomes best it is supposed to advertise from here right?  
On what basis R2 took that decision to keep 1.1.1.1/32 as valid only .So i think we need to know the BGP propagation of LP attribute using which type of messages in AS-2.  
Correct me if i am wrong in my understanding.

Regards  
Unni

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [March 16, 2020, 8:38am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/94 "2020-03-16T08:38:52Z")

</div>

Hello Unni

> [@monsterunni835](#):
>
> So i think we need to know the BGP propagation of LP attribute using which type of messages in AS-2.

First of all, keep in mind that all iBGP routers in an area must be configured with full mesh neighborship, that is, all BGP routers must be neighbors with all other BGP routers in the AS. (Unless you configure a route reflector, but that’s another lesson…) This means that if you change the Local Pref of a particular router or destination, this information will be learned by all other iBGP routers in the AS.

Having said that, R2 learns about the path to 1.1.1.0/24 via two sources: eBGP and iBGP. For this reason, both are placed in the BGP table of R2. However, because Local Pref is configured to force traffic destined to 1.1.1.0/24 via R3, the best path that is chosen by R2 is via R3.

So R2 learns about 1.1.1.0/24 via R1, but because a “preferred” route exists via R3 due to LP configuration, this is the path that is shared with R4.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![lugg15](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lugg15/32/4077_2.png) [@lugg15](https://forum.networklessons.com/u/lugg15)\
**Post date:** [March 28, 2020, 6:59am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/95 "2020-03-28T06:59:48Z")

</div>

Hello Team,

I have the following topology:

 ![topology](https://cdn-forum.networklessons.com/uploads/default/original/2X/9/96004e11a0efd45805c54a4b55ba7636a230d584.png)

**R1** on **AS 100** advertising the **172.16.x.x** prefixes.  
Transit **AS 200** and **AS 300**.  
iBGP full-mesh on **AS 400** between **R4** , **R6** and **R5**.

On **R4** , we are receiving the 172.16.x.x prefixes from **R2** and **R6**.  
On **R6** , we are receiving the 172.16.x.x prefixes from **R3** and **R4**.  
On **R4** , set local preference to **172.16.0.0/24** to **150**.  
On **R6** , set local preference to **172.24.0.0/24** to **150**.

**R4** detects that the **172.24.0.0/24** from **R6** has a **higher local preference** than the path from **R2 (AS 200)**. **R4** marks the path **R6** as the **best path** for the prefix and sends a route withdrawals to **R5** and **R6** for the path from **R2**.

**R6** detects that the **172.16.0.0/2** 4 from **R4** has a **higher local preference** than the path from **R3 (AS 300)**. **R6** selects the path from **R4** as the **best path** for the prefix and sends route withdrawals to **R4** and **R5** for the path from **R3**.

In summary:  
**R4** and **R5** receive **R6’s withdrawal** for the **172.16.0.0/24** prefix and remove it from the BGP table.  
**R5** and **R6** receive **R4’s withdrawal** for the **172.24.0.0/24** prefix and remove it from the BGP table.

On **R4** ’s BGP table I only see one path to **172.16.0.0/24** via **R2**.  
The path through **R6** was removed it from the BGP table.  
On **R6** ’s BGP table I only see one path to **172.24.0.0/24** via **R3**.  
The path through **R4** was removed it from the BGP table.

My questions are:

- why sending a prefix withdrawal message?
- why not keeping both paths to the prefix?
- Do the routers keep the alternate path (not-best-path) in a backup table in case either R4 or R6 routers crashes?
- What would happen if R3 fails and the path through R4 was previously removed it from the BGP table? How BGP will converge?

Regards,

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [March 30, 2020, 6:12am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/96 "2020-03-30T06:12:51Z")

</div>

Hello Luis

Your topology and your explanation is very comprehensive, thank you for your clarity!

> [@lugg15](#):
>
> - why sending a prefix withdrawal message?

BGP routers will advertise only the best route to a particular destination. If a better route is found, they will actually send a withdrawal message to remove the old advertisement.

So using R6 as an example:

- Without any local preference configuration, R6 has two routes to the 172.16.0.0/24 network: via R3 and R4. The best route is via R3, therefore, it advertises this route to R4
- Once the local preference for this route on R4 was increased to 150, R6 learned of the better route from R4, and changed its BGP table accordingly, making R4 the best route
- Because R3 is no longer the best path, R6 sends a withdrawal to R4 removing the previous best path, and replacing it with its current best path.

> [@lugg15](#):
>
> - why not keeping both paths to the prefix?

This is the default behaviour of BGP. However, you can change this behaviour, and you can see how this is done in the following lesson:

> **[BGP Additional Paths](https://networklessons.com/bgp/bgp-additional-paths)**
>
> BGP additional paths let your iBGP routers advertise multiple additional paths next to the best path. This allows you to use load balancing and multipath.

> [@lugg15](#):
>
> Do the routers keep the alternate path (not-best-path) in a backup table in case either R4 or R6 routers crashes?

This can be configured using the above mentioned feature called BGP additional paths.

> [@lugg15](#):
>
> - What would happen if R3 fails and the path through R4 was previously removed it from the BGP table? How BGP will converge?

If there is a failure in some link, then it will take some time for BGP to re-converge. If the next hop IP address of some route fails, then the [BGP Next Hop Address Tracking](https://networklessons.com/bgp/bgp-next-hop-address-tracking) feature kicks in, and BGP routes begin to be withdrawn, resulting in BGP peers sharing their revised routes.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![dakshinaeswar](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@dakshinaeswar](https://forum.networklessons.com/u/dakshinaeswar)\
**Post date:** [April 22, 2020, 5:08pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/97 "2020-04-22T17:08:06Z")

</div>

Hi, I have a question . when checking the `show ip bgp` in router 4, we can see it prefers Router 2 path for reaching to network 1.1.1.0/24 in As1 . We are changing the local preference value in Router 3 and configuring route map LOCALPREF in. My questions would be,

R2 , R3 and R4 are in same AS. if we set local preference value for the As it will be shared within AS. Going by this fact, why cant we set the local preference value in Router 4 itself ? This is where we are checking by giving command `show ip bgp` and seeing it is preferring router 2 for reaching the network 1.1.1.0/24.

If we set the local preference value in Router 4 , cant we write the route map like the below

```
router bgp 2
neighbor 192.168.13.1 route-map LOCALPREF out
!
route-map LOCALPREF permit 10
 set local-preference 700

```

Also please explain what happens here if we apply  
`neighbor 192.168.13.1 route-map LOCALPREF out`

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [April 23, 2020, 11:47am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/98 "2020-04-23T11:47:43Z")

</div>

Hello Dakshinamurthy

> [@dakshinaeswar](#):
>
> Going by this fact, why cant we set the local preference value in Router 4 itself ?

The local pref can be configured in two ways. Either using the `bgp default local-preference` command, or using route maps. In the first case, you must configure this command in the router that is advertising the route, or the router that is on the edge of the AS, specifically, either R2 or R3 in our topology. Applying the `bgp default local-preference` command on R4 will not affect the way R4 reaches the 1.1.1.0/24 network.

When using route maps however, yes, you could configure the change in local pref in R4.

> [@dakshinaeswar](#):
>
> If we set the local preference value in Router 4 , cant we write the route map like the below
> 
> ```
> router bgp 2
> neighbor 192.168.13.1 route-map LOCALPREF out
> !
> route-map LOCALPREF permit 10
> set local-preference 700
> 
> ```

I am assuming that the above commands are applied to R4, correct? If so, your route map is correct, but its application on the neighbor must be modified. In your configuration above, you are applying it to a peering between R4 and R1, (an eBGP peering) but such a peering does not exist. Actually, you would have to implement the route map on the BGP peering between R3 and R4. Specifically, you would apply it like so on R4:

`R4(config-router)#neighbor 3.3.3.3 route-map LOCALPREF in`

In this way, all advertisements **sent from R3** (with an ID of 3.3.3.3) **that are incoming** (hence the keyword “`in`”) will get a local preference value of 700 in R4’s BGP table. I labbed it up and confirmed this.

> [@dakshinaeswar](#):
>
> Also please explain what happens here if we apply  
> “neighbor 192.168.13.1 route-map LOCALPREF out”

If you applied the above on R4, then what you are saying is that all BGP routes that are **advertised to** (hence the “`out`” keyword) **R1** (the 192.168.13.1 neighbor) are to be advertised with a local pref of 700 (or whatever the route map assigns).

BUT, there are two problems with this. First, R4 does not have a peering with R1, so if you applied this, nothing would happen. Second, R4 does not actually have a path to any other AS’es so there is no meaning to having R4 advertise routes with a higher local pref. Remember, the local pref essentially indicates the preferred exit point from the current AS for a particular route.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![dakshinaeswar](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@dakshinaeswar](https://forum.networklessons.com/u/dakshinaeswar)\
**Post date:** [April 23, 2020, 12:53pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/99 "2020-04-23T12:53:25Z")

</div>

Thank you Laz, So can we say BGP Local preference is also one of that attributes that can be used to influence the incoming traffic ?

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [April 24, 2020, 9:15am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/100 "2020-04-24T09:15:04Z")

</div>

Hello Dakshinamurthy

It depends on what you mean by incoming traffic. You see, the “in” and “out” keywords used in the route maps do not refer to the direction of user traffic, but to **the direction of exchanged BGP updates**.

So for the following command applied to R4:

`R4(config-router)#neighbor 192.168.13.1 route-map LOCALPREF out`

the result is, any BGP update containing a route that is sent from R4 to neighbor 192.168.13.1 (R3) will have the LOCALPREF route-map applied to it. BGP updates **from R4 to R3 are considered outbound from the point of R4**. So if the route-map changes the local preference to, say, 500, then such a command will make all routes shared by R4 with R3 will have their localpref changed to 500.

> [@dakshinaeswar](#):
>
> So can we say BGP Local preference is also one of that attributes that can be used to influence the incoming traffic ?

If we’re talking about user traffic, then no. LocalPref will only affect **the choice of path to exit the local AS for a particular prefix**. If you have two or more eBGP routers within your AS, and they both have a route to the same prefix via eBGP, the local pref can be used to prefer one over the other.

Inbound traffic can be influenced using MED or AS-PATH prepending, but even so you do not have ultimate control over incoming routing, only your ISP can do that. For more info about influencing incoming traffic, take a look at the following post:

> [@How to configure BGP MED Attribute](https://forum.networklessons.com/t/how-to-configure-bgp-med-attribute/956/29):
>
> Hello Rawaz. If I understand correctly, your scenario involves a dual homed BGP topology and you want to know how to control, or at least influence, inbound traffic, correct? Because inbound traffic is essentially sent to you, you do not have the ultimate control of how traffic enters your AS. Your ISP may have outbound policies that will always override all of your attempts to influence inbound traffic. However, you do have the option of influencing inbound traffic. There are several ways …

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![yuriviniciusff](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/yuriviniciusff/32/2837_2.png) [@yuriviniciusff](https://forum.networklessons.com/u/yuriviniciusff)\
**Post date:** [July 6, 2020, 1:57am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/101 "2020-07-06T01:57:26Z")

</div>

Hello, there follows a question of BGP of an internet sim that I was practicing.

I suspect that something is wrong with that!

 ![questao bgp forum NL](https://cdn-forum.networklessons.com/uploads/default/original/2X/5/581ab6eb3eeccd5b7a0fd612d59b419a3b526ec1.jpeg)

**1st answer\>** On router A, set the default location preference to 50.

#this case would influence the entire traffic output of the AS100 to go through routerB and not specifically the prefix 10.10.25.0/24

**-2nd answer\>** On router B, configure a route map for 10.10.25.0/24 with the local preference of 150 linked to neighbor 192.168.30.2.

# the filter applied to the neighbor (192.168.30.2) does not make sense.  
because in the IN sense it does not match the route-map to the prefix (10.10.25.0/24)  
in the out direction it has no effect because the session is EBGP.

**-3rd answer\>** On router B set the default location preference to 150

#this case would influence the entire output of the AS100 and not specifically the prefix 10.10.25.0/24

**4th answer\>** In router B set the default metric to 150

# has no effect on the proposed question

makes sense??

---

<div class="post-metadata">

**Author:** ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)\
**Post date:** [July 7, 2020, 8:56am UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/102 "2020-07-07T08:56:26Z")

</div>

Hello Yuri

You are correct in your explanation of answers A, C, and D. However, answer B is the correct answer to the question.

> [@yuriviniciusff](#):
>
> # the filter applied to the neighbor (192.168.30.2) does not make sense.  
> because in the IN sense it does not match the route-map to the prefix (10.10.25.0/24)  
> in the out direction it has no effect because the session is EBGP.

Keep in mind that the question is only asking about **outgoing traffic** , so it only affects traffic in the direction from AS 100 to AS 200. Local preference can only affect outgoing traffic, and this is the goal of the scenario. Local preference essentially tells an AS the most appropriate exit point for traffic.

So by creating a route map where traffic originating from 10.10.25.0/24 will have a higher local preference via router B to router F, you are essentially moving that 20% of the traffic from one link to the other, thus more evenly distributing the traffic between the links. The result is the A-E link will have 45% traffic and the B-F link will have 40%.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

**Author:** ![yuriviniciusff](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/yuriviniciusff/32/2837_2.png) [@yuriviniciusff](https://forum.networklessons.com/u/yuriviniciusff)\
**Post date:** [July 7, 2020, 2:13pm UTC](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953/103 "2020-07-07T14:13:03Z")

</div>

Hi @lagapidis

Answer B asks to “match” only in the prefix 10.10.25.0/24 which is behind router C by placing a local preference 150 and tying to the neighbor ebgp.

```
ip prefix-list rota10-25 seq 5 permit 10.10.25.0/24
!
route-map route10-25 permit 10
match ip address prefix-list rota10-25
set local-preference 150
!

```

and then apply to the neighbor (192.168.30.2)  
applying in the IN or OUT direction has no result for the proposal of the statement.

the local preference in B would affect all traffic from the AS 100 out of the B-F point-to-point.

[Previous page](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953.md?page=4)

[Next page](https://forum.networklessons.com/t/how-to-configure-bgp-local-preference-attribute/953.md?page=6)
