Weight Attribute

 

The weight attribute is a Cisco-defined attribute. This attribute uses weight to select a best path. The weight is assigned
locally to the router. The value only makes sense to the specific router. The value is not propagated or carried through any
of the route updates. A weight can be a number from 0 to 65,535.

Paths that the router originates have a weight of 32,768 by default, and other paths have a weight of 0.

Routes with a higher weight value have preference when multiple routes to the same destination exist.

Look at the example in this section.

RTA has learned about network 175.10.0.0 from AS4.
RTA propagates the update to RTC.
RTB has also learned about network 175.10.0.0 from AS4.
RTB propagates the update to RTC.
RTC now has two ways to reach 175.10.0.0 and has to decide which way to go.

If you set the weight of the updates on RTC that come from RTA so that the weight is greater than the weight of updates
that come from RTB, you force RTC to use RTA as a next hop to reach 175.10.0.0.

Multiple methods achieve this weight set:

  • Use the neighbor command.
    • neighbor{ip-address | peer-group}weight weight
  • Use AS_PATH access lists.
    • ipas-pathaccess-list access-list-number {permit|deny} as-regular-expression neighbor ip-address filter-list access-list-number weightweight
      !
      !— The route to 175.10.0.0 from RTA has a 200 weight.
       
  • Use route maps.
  • RTC#
  • router bgp 300
  • neighbor 1.1.1.1 remote-as 100
  • neighbor 1.1.1.1 weight 200
  • !
  • !— The route to 175.10.0.0 from RTB has a 100 weight.
  • neighbor 2.2.2.2 remote-as 200
  • neighbor 2.2.2.2 weight 100

RTA, which has a higher weight value, has preference as the next hop.

!
!

You can achieve the same outcome with IP AS_PATH and filter lists.

RTC#

router bgp 300

neighbor 1.1.1.1 remote-as 100

neighbor 1.1.1.1 filter-list 5 weight 200

neighbor 2.2.2.2 remote-as 200

neighbor 2.2.2.2 filter-list 6 weight 100

!— This only permits path 100.

ip as-path access-list 5 permit ^100$

ip as-path access-list 6 permit ^200$

!
! 

You also can achieve the same outcome with the use of route maps.

RTC#

router bgp 300

neighbor 1.1.1.1 remote-as 100

neighbor 1.1.1.1 route-map setweightin in

neighbor 2.2.2.2 remote-as 200

neighbor 2.2.2.2 route-map setweightin in

…

ip as-path access-list 5 permit ^100$

 !

route-map setweightin permit 10

match as-path 5

set weight 200

!— Anything that applies to access list 5, such as packets from AS100, has weight 200.

 

route-map setweightin permit 20

set weight 100

!— Anything else has weight 100.

 

Local Preference Attribute

 

Local preference is an indication to the AS about which path has preference to exit the AS in order to reach a certain network.
A path with a higher local preference is preferred more. The default value for local preference is 100.

 

Unlike the weight attribute, which is only relevant to the local router, local preference is an attribute that routers exchange in the same AS.

You set local preference with the issue of the bgp default local-preference value command.
You can also set local preference with route-maps, as the example in this section demonstrates:

 

The bgp default local-preference command sets the local preference on the updates out of the router that go to peers
in the same AS. In the diagram in this section, 

AS256 receives updates about 170.10.0.0 from two different sides of the organization. Local preference helps you determine
which way to exit AS256 in order to reach that network. 

Assume that RTD is the exit point preference. This configuration sets the local preference for updates that come from 
AS300 
to 200 and for updates that come from AS100 to 150:

RTC#

router bgp 256

neighbor 1.1.1.1 remote-as 100

neighbor 128.213.11.2 remote-as 256

bgp default local-preference 150

RTD#

router bgp 256

neighbor 3.3.3.4 remote-as 300

neighbor 128.213.11.1 remote-as 256

bgp default local-preference 200

In this configuration,

RTC sets the local preference of all updates to 150.
The same RTD sets the local preference of all updates to 200.

There is an exchange of local preference within AS256.

Therefore, both RTC and RTD realize that network 170.10.0.0 has a higher local preference when updates come from AS300 rather than from AS100. All traffic in AS256 that has that network as a destination transmits with RTD as an exit point.

The use of route maps provides more flexibility.

In the example in this section,

All updates that RTD receives are tagged with local preference 200 when the updates reach RTD. Updates that come from AS34 also are tagged with the local preference of 200. This tag can be unnecessary. For this reason, you can use route maps to specify the specific updates that need to be tagged with a specific local preference.

Here is an example:

RTD#

router bgp 256

neighbor 3.3.3.4 remote-as 300

neighbor 3.3.3.4 route-map setlocalin in

neighbor 128.213.11.1 remote-as 256

….

ip as-path access-list 7 permit ^300$

…

 

route-map setlocalin permit 10

match as-path 7

set local-preference 200

 

route-map setlocalin permit 20

set local-preference 150

With this configuration, any update that comes from AS300 has a local preference of 200. Any other updates, such as updates that come from AS34, have a value of 150.