Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

How to use BGP Default Local Preference

User generated image
on the topology above , I have R1 and R6 on AS 1, R5 on AS3 , R2,R3,R4 on AS2

I would like to have Routers on AS1 (R1 and R6) Not take route through AS3 to reach routers inside AS2, instead I want AS1 routers to go straight to AS2 through R1 using BGP Default Local Preference command on R1

you can see in the config below on R1 :
bgp default local-preference 600


Below is the BGP route configuration on R1, R6, R3. As you can see R6 is going through AS3 to reach routers in AS2 instead of going straight to AS2 through R1

If you need more info , please feel free to ask.


Thank you

R1#sh run | beg router bgp
 bgp default local-preference 600
 network 1.1.1.0 mask 255.255.255.0
 neighbor 192.168.12.2 remote-as 2
 neighbor 192.168.16.6 remote-as 1

Open in new window


R6#sh run | beg router bgp
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 neighbor 192.168.16.1 remote-as 1
 neighbor 192.168.56.5 remote-as 3

Open in new window


R5#sh run | beg router bgp
router bgp 3
 network 5.5.5.0 mask 255.255.255.0
 neighbor 192.168.35.3 remote-as 2
 neighbor 192.168.56.6 remote-as 1

Open in new window


R1# sh ip bgp
BGP table version is 13, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       0.0.0.0                  0         32768 i
* i2.2.2.0/24       192.168.56.5             0    100      0 3 2 i
*>                  192.168.12.2             0             0 2 i
* i3.3.3.0/24       192.168.56.5             0    100      0 3 2 i
*>                  192.168.12.2                           0 2 i
* i4.4.4.0/24       192.168.56.5             0    100      0 3 2 i
*>                  192.168.12.2                           0 2 i
* i5.5.5.0/24       192.168.56.5             0    100      0 3 i
R1#

Open in new window


R6#sh ip bgp              
BGP table version is 6, local router ID is 192.168.56.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       192.168.16.1             0    600      0 i
* i2.2.2.0/24       192.168.12.2             0    600      0 2 i
*>                  192.168.56.5                           0 3 2 i
* i3.3.3.0/24       192.168.12.2             0    600      0 2 i
*>                  192.168.56.5                           0 3 2 i
* i4.4.4.0/24       192.168.12.2             0    600      0 2 i
*>                  192.168.56.5                           0 3 2 i
*> 5.5.5.0/24       192.168.56.5             0             0 3 i

Open in new window



R5# sh ip bgp             
BGP table version is 10, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       192.168.56.6                           0 1 i
*> 2.2.2.0/24       192.168.35.3                           0 2 i
*> 3.3.3.0/24       192.168.35.3             0             0 2 i
*> 4.4.4.0/24       192.168.35.3                           0 2 i
*> 5.5.5.0/24       0.0.0.0                  0         32768 i
R5#

Open in new window

Avatar of Predrag Jovic
Predrag Jovic
Flag of Poland image

Clear  bgp process after configuration local preference on R6 - bgp table on router R1 still did not get changed local preference values from R6.
clear bgp ipv4 unicast *    
           - or not to be disruptive
clear bgp ipv4 unicast  * soft

Remember that bgp protocol often requires reset (hard or soft) otherwise changes are not pushed to neighbors...
Avatar of jskfan

ASKER

bgp default local-preference 600 , is applied on R1
R6 got it in its BGP table, But it still going through R5 (AS3) to reach AS2 instead of through R1
Can you, please, paste configurations of all routers? In .txt files attached if possible.

I have tested scenario and it is working as expected once bgp is refreshed, so I guess there is some other issue.

Error in drawing - R5 loopback0 IP address is 1.1.1.1/24 in AS3 and according to your output R1 has local network *> 1.1.1.0/24       0.0.0.0                  0         32768 i
Avatar of jskfan

ASKER

Predrag,

I have attached text file with the configuration of all routers
Problem:
There is no route configured on R6 (static or dynamic) that is matching next hop advertised by R1, so R6 does not know how to reach next hop 192.168.12.2 that is advertised by R1.

Possible solutions
Configuring needed routes (here static route on R6)
R6#sh ip bgp
BGP table version is 7, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       192.168.16.1             0    600      0 i
*> 2.2.2.0/24       192.168.56.5                           0 3 2 i
* i                 192.168.12.2             0    600      0 2 i
*> 3.3.3.0/24       192.168.56.5                           0 3 2 i
* i                 192.168.12.2             0    600      0 2 i
*> 4.4.4.0/24       192.168.56.5                           0 3 2 i
* i                 192.168.12.2             0    600      0 2 i
*> 5.5.5.0/24       192.168.56.5             0             0 3 i
*> 6.6.6.0/24       0.0.0.0                  0         32768 i
!
ip route 192.168.12.2 255.255.255.255 192.168.16.1
!
R6#sh ip bgp
BGP table version is 10, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       192.168.16.1             0    600      0 i
*  2.2.2.0/24       192.168.56.5                           0 3 2 i
*>i                 192.168.12.2             0    600      0 2 i
*  3.3.3.0/24       192.168.56.5                           0 3 2 i
*>i                 192.168.12.2             0    600      0 2 i
*  4.4.4.0/24       192.168.56.5                           0 3 2 i
*>i                 192.168.12.2             0    600      0 2 i
*> 5.5.5.0/24       192.168.56.5             0             0 3 i
*> 6.6.6.0/24       0.0.0.0                  0         32768 i

Open in new window

or
configuring R1 with next
router bgp 1
 neighbor 192.168.16.6 next-hop-self
Avatar of jskfan

ASKER

Thanks Predrag. I will try it in the LAB later..

Just a Thought... If  I configure either static route on R6 :
ip route 192.168.12.2 255.255.255.255 192.168.16.1

OR

configuring R1 with next
router bgp 1
 neighbor 192.168.16.6 next-hop-self


Then I believe , I would not need to  configure on R1 : bgp default local-preference 600
That depends on what you are trying to achieve. It is lab, so ...
:)
Avatar of jskfan

ASKER

The Lab was to test this :
bgp default local-preference 600
Avatar of jskfan

ASKER

Predrag

I have removed : bgp default local-preference 600  from R1
and added :  neighbor 192.168.16.6 next-hop-self

now R6 prefers to go through R1 to get to AS 2

R6# sh ip bgp
BGP table version is 11, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       192.168.16.1             0    100      0 i
*>i2.2.2.0/24       192.168.16.1             0    100      0 2 i
*                   192.168.56.5                           0 3 2 i
*>i3.3.3.0/24       192.168.16.1             0    100      0 2 i
*                   192.168.56.5                           0 3 2 i
*>i4.4.4.0/24       192.168.16.1             0    100      0 2 i
*                   192.168.56.5                           0 3 2 i
*> 5.5.5.0/24       192.168.56.5             0             0 3 i
*> 6.6.6.0/24       0.0.0.0                  0         32768 i
R6#
 

Open in new window


so I still cannot determine the usage of the command :bgp default local-preference 600
Yes, you can. By using local preference make R6 preferred path for all routes on R1 (2.2.2.0/24, 3.3.3.0/24, 4.4.4.0/24). The point of lab is to do traffic engineering - make traffic flow in other direction by usage of local preference command.
 :)
Also, you should understand why currently R1 is preferred path from R6 to those networks.
BGP Best Path Selection Algorithm
Avatar of jskfan

ASKER

I understand..
but the output of show IP bgp on  R6, above  , is showing that R6 goes through R1 to reach AS 2.
This is due to Next-hop-self configured on R1 and not   bgp default local-preference 600, which has been removed anyway.

Unless if the topology above is not the right one to test  bgp default local-preference , I do not see how else I can test it
Any topology thet has 2 or more eBGP routers is right for testing local preference (sure and both eBGP routers have at  least 2 different paths to reach the same networks in remote As).
Now, when R6 and R1 are forwarding traffic to 2.2.2.0/24 network via 192.168.12.0/24 network (directly from R1 to R2), your task is to redirect traffic flow in opposite direction - via R5 router to reach 2.2.2.0/24 network (by usaging of local preference command in BGP).
Avatar of jskfan

ASKER

Now, when R6 and R1 are forwarding traffic to 2.2.2.0/24 network via 192.168.12.0/24 network (directly from R1 to R2), your task is to redirect traffic flow in opposite direction - via R5 router to reach 2.2.2.0/24 network (by usaging of local preference command in BGP).
So I will need to add "BGP Default Local Preference " on R6  ?
Yes. :)
Avatar of jskfan

ASKER

I got it working now , I have added Next-hop-self on both routers R1and R6, and put  back "bgp default local-preference 600" on R1


R1#sh run | beg router bgp
router bgp 1
 bgp default local-preference 600
 network 1.1.1.0 mask 255.255.255.0
 neighbor 192.168.12.2 remote-as 2
 neighbor 192.168.16.6 remote-as 1
 neighbor 192.168.16.6 next-hop-self

Open in new window


R6#sh run | beg router bgp
router bgp 1
 network 6.6.6.0 mask 255.255.255.0
 neighbor 1.1.1.1 remote-as 1
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 192.168.16.1 remote-as 1
 neighbor 192.168.56.5 remote-as 3
 no auto-summary

Open in new window


Now R6 prefers the path through R1 to reach AS2

** There is one ambiguous thing...I do not understand why I cannot reach loopback 5.5.5.5 from R1,R2,R4
R1#  ping 5.5.5.5

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Avatar of jskfan

ASKER

Oops for some reason --I accidentally removed the command  Next-hop-self  on R6..Now I put it back

Now R6  goes through R1 to reach AS 2, the only pending issue is I still cannot ping 5.5.5.5 from R1,R2,R4
ASKER CERTIFIED SOLUTION
Avatar of Predrag Jovic
Predrag Jovic
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

fixed now..Thank you very much
Actually, there is no need for routes that are pointing to 5.5.5.5, just there should be route to BGP advertised next hop (R3 and R6 - actual route that should be present in routing table depends on do you use next hop self or not). See details explanation above for next hop for R1, it is the same principle.