BGP - [Part 13] - WEIGHT ATTRIBUTES - INTERVIEW QUESTIONS

Question - 1 Explain BGP weight attribute.

  • It is Cisco proprietary attribute, so you will be find this in only Cisco devices.
  • Weight attribute is locally on the router, it cannot be propagate to any BGP peers 
  • It is used in the BGP path selection process, if there is more than one route available to the same destination
  • It is a numeric value and always set by a router. We can use this attribute for outbound traffic.
  • Range of value for Weight is 0 to 65535.
  • The default value for weight is 0 for all routes which are not originated by the local router. 
  • The default value for weight is 32768 for all routes which are originated by the local router.
  • Always a path with the highest weight will be preferred.
  • You can be changed weight per neighbor via command neighbor [neighbor ip address]  weight [0-65535] or in a  route-map using the command set weight [0-65535]

Question - 2 which commands we can use to set weight ?

You can set weight manually via Command in three ways:-
  • By neighbor command
neighbor [neighbor ip address] weight [0-65535]

Router1#configure terminal
Router1(config)#router bgp 10
Router1(config-router)#neighbor 192.167.26.3 weight 400---------- you can configure weight per neighbor by using the weight command
  • By AS-Path Access-Lists -
ip as-path access-list [access-list-number] [permit | deny] as-regular-expression 

neighbor [ip-address] filter-list [access-list-number] weight [0-65535]

Router1(config)# ip as-path access-list 1 permit ^10$
Router1(config)# router bgp 10
Router1(config-router)# neighbour 192.167.26.3 filter-list 1 weight 400
  • By Route Maps
You can set weight path attribute via route-map command - 
Router1#configure terminal
Router1(config)#route-map WEIGHTPOLICY permit 10----- create the route map for the network for which you want to set the weight path attribute 400 for all prefix
Router1(config-route-map)#set weight 400--------------------------  set weight 400 for all prefix to reach the destination network
Router1(config-route-map)#exit
Router1(config)#router bgp 10
Router1(config-router)#neighbor 192.167.26.3 route-map WEIGHTPOLICY in ----- now put the ip address of neighbor (from where you will reach destination network with path attribute value 400 ) in route map for inbound 
Router1(config-router)#exit
Router1#clear ip bgp *

You can also set weight path attribute for certain route only via route-map command - 

Router1#configure terminal
Router1(config)#router bgp 10
Router1(config-router)#no neighbor 192.167.26.3 weight 400 ---  remove the previous weight configuration
Router1(config-router)#exit

Router1(config)#access-list 1 permit 2.2.2.0 0.0.0.255-------------  create an access list and permit the network with wildcard mask for which you want to set the weight path attribute 400 for all prefix

Router1(config)#route-map WEIGHTPOLICY permit 10 ------  create the route map for the network for which you want to set the weight path attribute 400 for all prefix
Router1(config-route-map)#match ip address 1 --------------------  1 is access list number
Router1(config-route-map)#set weight 400 -------------------------- set weight 400 for all prefix to reach 2.2.2.0
Router1(config-route-map)#exit
Router1(config)#route-map WEIGHTPOLICY permit 20---------- create the route map for the network for which you want to set the weight path attribute 0 for all prefix
Router1(config-route-map)#set weight 0---------------------------------- set weight 0 for all prefix to reach another network except 2.2.2.0
Router1(config-route-map)#exit

Router1(config)#router bgp 10
Router1(config-router)#neighbor 192.167.26.3 route-map WEIGHTPOLICY  in ------ now put the ip address of neighbor (from where you will reach destination network with path attribute value 400 ) in route map for inbound 
Router1(config-router)#exit
Router1(config)#exit

Note - Check the below question for better understanding

Question - 3 How can we configure weight attribute ?


You can see in below picture, there are three routers Router1,  Router2 and  Router3.  Router1 in Autonomous System 10,  Router2 and  Router3 are in Autonomous System 20 

  • Configuration - 
Router1
Router1#show running-config
!
interface Ethernet1/0
 ip address 192.167.26.1 255.255.255.0
 half-duplex
!
interface Ethernet2/0
 ip address 192.167.24.1 255.255.255.0
 half-duplex
!
router bgp 10
 no synchronization
 bgp log-neighbor-changes
 neighbor 192.167.24.2 remote-as 20
 neighbor 192.167.26.3 remote-as 20
 no auto-summary

Router2
Router2#show running-config
!
interface Loopback1
 ip address 1.1.1.1 255.255.255.0
!
interface Loopback2
 ip address 2.2.2.2 255.255.255.0
!
interface Ethernet2/1
 ip address 192.167.26.2 255.255.255.0
 half-duplex
!
router bgp 20
 no synchronization
 bgp log-neighbor-changes
 network 1.1.1.0 mask 255.255.255.0
 network 2.2.2.0 mask 255.255.255.0
 neighbor 192.167.24.1 remote-as 10
 neighbor 192.167.26.3 remote-as 20
 no auto-summary

Router3 
Router3#show running-config
!
interface Loopback1
 ip address 1.1.1.1 255.255.255.0
!
interface Loopback2
 ip address 2.2.2.2 255.255.255.0
!
interface Ethernet1/0
 ip address 192.167.26.3 255.255.255.0
 half-duplex
!
interface Ethernet2/1
 ip address 192.167.25.3 255.255.255.0
 half-duplex
!
router bgp 20
 no synchronization
 bgp log-neighbor-changes
 network 1.1.1.0 mask 255.255.255.0
 network 2.2.2.0 mask 255.255.255.0
 neighbor 192.167.25.2 remote-as 20
 neighbor 192.167.26.1 remote-as 10
 no auto-summary

no check the output-


By default Router1  selected to use 192.167.24.2 as the next hop for both 1.1.1.0/24 and 2.2.2.0/24 network. All the BGP attribute are the same. 

now we will change this behavior, we are going to change weight attribute value
Router1#configure terminal
Router1(config)#router bgp 10
Router1(config-router)#neighbor 192.167.26.3 weight 400

Router1#clear ip bgp *------------- we will clear the BGP session to apply the changes

now check the output

Now you can see that 192.168.13.3 has been selected as the next hop for both prefix, because now the weight is 400 

Question - 4 How can we change the weight for certain prefix only ?

We will set the weight 400 for all prefix to reach the 2.2.2.0/24,
and we will set the weight 0 for all prefix to reach the 1.1.1.0/24

Router1#configure terminal
Router1(config)#router bgp 10
Router1(config-router)#no neighbor 192.167.26.3 weight 400
Router1(config-router)#exit

Router1(config)#access-list 1 permit 2.2.2.0 0.0.0.255

Router1(config)#route-map WEIGHTPOLICY permit 10
Router1(config-route-map)#match ip address 1
Router1(config-route-map)#set weight 400
Router1(config-route-map)#exit
Router1(config)#route-map WEIGHTPOLICY permit 20
Router1(config-route-map)#set weight 0
Router1(config-route-map)#exit

Router1(config)#router bgp 10
Router1(config-router)#neighbor 192.167.26.3 route-map WEIGHTPOLICY  in
Router1(config-router)#exit
Router1(config)#exit

Router1#clear ip bgp *

Now check the weight


Now weight is 400 for all prefix to reach 2.2.2.0/24 via next hop 192.167.26.3 , and weight is 0 for all prefix to reach 1.1.1.0/24 via next hop 192.167.24.2 
SHARE

Anubhav Upadhyay

Hello and welcome to networktopic Blog. My name is Anubhav. I am a Senior Network Egineer. I have created this blog specially to serve interview questions and answer on Network Routing and Switching, I will try my best to serve correct and updated networking knowledge for you as per my corporate experience.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

If you like my posts then please comment and if you don’t like then please suggest me to improve, and if you have any query related to post then please text me through the comment box or mail me on upadhyayambition@gmail.com , I will try my best to solve your queries as soon as possible.