BGP - [Part 14] - LOCAL PREFERENCE ATTRIBUTES - INTERVIEW QUESTIONS

Question - 1 Explain BGP Local -Preference attribute.

  • Local preference is a Well-known and discretionary attribute.Local Preference is locally to Autonomous System, means it is globally within Autonomous System.
  • It advertise into the local Autonomous System only, so it is sent to all IBGP routers in an AS, cannot be exchanged between EBGP routers.
  • We can use local preference to select the outbound external BGP path. It will tell the Autonomous System about which path will exit the Autonomous System to reach a certain network.
  • Always a path with highest Local Preference will be preferred.
  • It is a numeric  32-bit number value, and can range from 0 to 4294967295. By default local preference value is 100 and it can be changed manually. 
  • You can be changed Local Preference via command bgp default local-preference [Local Preference value] or in a  route-map using the command set local-preference [Local Preference value].

Question - 2 How can we configure Local-Preference attribute ?


  • Router1 Configuration
Router1#show running-config
interface Loopback1
 ip address 1.1.1.1 255.255.255.0
!
interface Loopback1
 ip address 5.5.5.5 255.255.255.0
!
interface Ethernet1/0
 ip address 192.167.26.1 255.255.255.0
 half-duplex
!
interface Ethernet2/0
 ip address 192.167.23.1 255.255.255.0
 half-duplex
!
router bgp 10
 no synchronization
 bgp log-neighbor-changes
 network 1.1.1.0 mask 255.255.255.0
 neighbor 192.167.23.2 remote-as 20
 neighbor 192.167.26.3 remote-as 20
 no auto-summary
  • Router2 Configuration
Router2#show running-config
interface Loopback1
 ip address 2.2.2.2 255.255.255.0
!
interface Ethernet1/0
 ip address 192.167.24.2 255.255.255.0
 half-duplex
!
interface Ethernet2/0
 ip address 192.167.23.2 255.255.255.0
 half-duplex
!
router bgp 20
 no synchronization
 bgp log-neighbor-changes
 neighbor 192.167.23.1 remote-as 10
 neighbor 192.167.24.4 remote-as 20
 no auto-summary
!
no ip http server
no ip http secure-server
!
ip route 3.3.3.0 255.255.255.0 192.167.24.4
ip route 4.4.4.0 255.255.255.0 192.167.24.4
ip route 192.167.25.0 255.255.255.0 192.167.24.4

  • Router3 Configuration
Router3#show running-config
interface Loopback1
 ip address 3.3.3.3 255.255.255.0
!
interface Ethernet1/0
 ip address 192.167.26.3 255.255.255.0
 half-duplex
!
interface Ethernet2/0
 ip address 192.167.25.3 255.255.255.0
 half-duplex
!
router bgp 20
 no synchronization
 bgp log-neighbor-changes
 neighbor 192.167.25.4 remote-as 20
 neighbor 192.167.26.1 remote-as 10
 no auto-summary
!
no ip http server
no ip http secure-server
!
ip route 2.2.2.0 255.255.255.0 192.167.25.4
ip route 4.4.4.0 255.255.255.0 192.167.25.4
ip route 192.167.24.0 255.255.255.0 192.167.25.4
  • Router4 Configuration
Router4#show running-config
interface Loopback1
 ip address 4.4.4.4 255.255.255.0
!
interface Ethernet1/0
 ip address 192.167.24.4 255.255.255.0
 half-duplex
!
interface Ethernet2/0
 ip address 192.167.25.4 255.255.255.0
 half-duplex
!
router bgp 20
 no synchronization
 bgp log-neighbor-changes
 neighbor 192.167.24.2 remote-as 20
 neighbor 192.167.25.3 remote-as 20
 no auto-summary
!
no ip http server
no ip http secure-server
!
ip route 2.2.2.0 255.255.255.0 192.167.24.2
ip route 3.3.3.0 255.255.255.0 192.167.25.3
ip route 192.167.23.0 255.255.255.0 192.167.24.2
ip route 192.167.26.0 255.255.255.0 192.167.25.3

Output - 
So you can see in this output Router4 is using 192.167.23.1(Router2) to reach network 1.1.1.0/24 and 5.5.5.0/24 


Now we will change the local-preference value, by default  local preference value is 100, and you can change this value via command bgp default local-preference.

Router3#configure terminal
Router3(config)#router bgp 20
Router3(config-router)#bgp default local-preference 500

Output - 
Now you can see in this output, now Router4 is using 192.167.26.1(Router3) to reach network 1.1.1.0/24 and 5.5.5.0/24 because the local preference 500 is greater than 100 


Question - 3 How can we configure Local-Preference attribute via Route-Map ?

Now clean up the previous local-preference configuration

Router3#configure terminal
Router3(config)#router bgp 20
Router3(config-router)#no bgp default local-preference 500

You can set the local preference via route-map also
Router3#configure terminal
Router3(config)#route-map LOCAL-PREF permit 20  -------------- Create the route-map
Router3(config-route-map)#set local-preference 600       -------------- Set the local preference
Router3(config-route-map)#exit
Router3(config)#router bgp 20
Router3(config-router)#neighbor 192.167.26.1 route-map LOCAL-PREF in  --------- now put the ip address of neighbor (for which you want to set the local-preference value - 600) in route map for inbound
Router3(config-router)#exit
Router3(config)#clear ip bgp * ------------- we will clear the BGP session to apply the changes

Output - 

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

We will set the local-preference 700 for all prefix to reach the 5.5.5.0/24, and we will set the local-preference 100 for all prefix to reach the 1.1.1.0/24

Router3#configure terminal
Router3(config)#access-list 1 permit 5.5.5.0 0.0.0.255
Router3(config)#route-map LOCAL-PREF permit 10
Router3(config-route-map)#match ip address 1
Router3(config-route-map)#set local-preference 700
Router3(config-route-map)#exit
Router3(config)#route-map LOCAL-PREF permit 20
Router3(config-route-map)#set local-preference 600
Router3(config-route-map)#exit
Router3(config)#router bgp 20
Router3(config-router)#neighbor 192.167.26.1 route-map LOCAL-PREF in
Router3(config-router)#exit
Router3(config)#clear ip bgp *

Output - 

Now Local-Preference is 100 for all prefix to reach 1.1.1.0/24 via next hop 192.167.23.1 , and Local-Preference is 700 for all prefix to reach 5.5.5.0/24 via next hop 192.167.26.1

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.