Saturday 1 December 2018

What is BGP Local Preference (Local_Pref)? How to configure?




 BGP Local preference (Local_Pref) Path attribute gives the router inside a single autonomous system a value that they can set per-route and advertise to all iBGP routers inside the autonomous system, so that all routers in the autonomous system agree about which routers is the best exit point for packet destined for that prefix.
Path with highest preference value is more desirable, by default Local_pref value is 100 and the range is 0 through 4,294,967,295. Local preference is well-known, discretionary attribute. It is advertised only to iBGP neighbors within an autonomous system.













lets see the configuration:-


Topology:





Goal:
  • configure the topology as per the diagram.
  • configure iBGP and eBGP peering using directly connected interfaces.
  • advertise all the networks as per the topology.
  • configure router 1 exit point for autonomous system of 65111.
  • make sure router 2 reaches the network via router 1.


R1#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
FastEthernet0/0        10.1.1.1        YES manual up                    up
Serial3/0              1.1.1.1         YES manual up                    up
Serial3/3              4.1.1.2         YES manual up                    up
Loopback0              11.0.0.1        YES manual up                    up
Loopback1              11.0.1.1        YES manual up                    up
Loopback2              11.0.2.1        YES manual up                    up
Loopback3              11.0.3.1        YES manual up                    up


R2#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
FastEthernet0/0        20.1.1.1        YES manual up                    up
Serial3/0                     1.1.1.2         YES manual up                    up
Serial3/1                     2.1.1.1         YES manual up                    up
Loopback0              12.0.0.1        YES manual up                    up
Loopback1              12.0.1.1        YES manual up                    up
Loopback2              12.0.2.1        YES manual up                    up
Loopback3              12.0.3.1        YES manual up                    up

R3#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
FastEthernet0/0        30.1.1.1        YES manual up                    up
Serial3/1              2.1.1.2         YES manual up                    up
Serial3/2              3.1.1.1         YES manual up                    up
Loopback0              13.0.0.1        YES manual up                    up
Loopback1              13.0.1.1        YES manual up                    up
Loopback2              13.0.2.1        YES manual up                    up
Loopback3              13.0.3.1        YES manual up                    up


R4#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
FastEthernet0/0        40.1.1.1        YES manual up                    up
Serial3/2                    3.1.1.2         YES manual up                    up
Serial3/3                    4.1.1.1         YES manual up                    up
Loopback0              14.0.0.1        YES manual up                    up
Loopback1              14.0.1.1        YES manual up                    up
Loopback2              14.0.2.1        YES manual up                    up
Loopback3              14.0.3.1        YES manual up                    up


R1(config)#router bgp 65111
R1(config-router)#neighbor 1.1.1.2 remote-as 65111
R1(config-router)#neighbor 4.1.1.1 remote-as 65444
R1(config-router)#neighbor 1.1.1.2 next-hop-self
R1(config-router)#network 10.0.0.0
R1(config-router)#network 1.0.0.0
R1(config-router)#network 4.0.0.0
R1(config-router)#network 11.0.0.0 mask 255.255.255.0
R1(config-router)#no auto-summary
R1(config-router)#no synchronization


R2(config)#router bgp 65111
R2(config-router)#neighbor 1.1.1.1 remote-as 65111
R2(config-router)#neighbor 2.1.1.2 remote-as 65333
R2(config-router)#neighbor 1.1.1.1 next-hop-self
R2(config-router)#network 20.0.0.
R2(config-router)#network 20.0.0.0
R2(config-router)#network 2.0.0.0
R2(config-router)#network 1.0.0.0
R2(config-router)#network 12.0.0.0 mask 255.255.255.0
R2(config-router)#no auto-summary
R2(config-router)#no synchronization


R3(config)#router bgp 65333
R3(config-router)#neighbor 2.1.1.1 remote-as 65111
R3(config-router)#neighbor 3.1.1.2  remote-as 65444
R3(config-router)#network 30.0.0.0
R3(config-router)#network 3.0.0.0
R3(config-router)#network 2.0.0.0
R3(config-router)#network 13.0.0.0 mask 255.255.255.0
R3(config-router)#no synchronization
R3(config-router)#no auto-summary


R4(config)#router bgp 65444
R4(config-router)#neighbor 3.1.1.1 remote-as 65333
R4(config-router)#neighbor 4.1.1.2 remote-as 65111
R4(config-router)#network 40.0.0.0
R4(config-router)#network 4.0.0.0
R4(config-router)#network 14.0.0.0 mask 255.255.255.0
R4(config-router)#network 3.0.0.0
R4(config-router)#no synchronization
R4(config-router)#no auto-summary


R1#show ip bgp
BGP table version is 14, local router ID is 11.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found


     Network          Next Hop            Metric LocPrf Weight Path
 * i 1.0.0.0          1.1.1.2                  0    100      0 i
 *>                   0.0.0.0                  0         32768 i
 *>i 2.0.0.0          1.1.1.2                  0    100      0 i
 *>  3.0.0.0          4.1.1.1                  0             0 65444 i
 * i                  1.1.1.2                  0    100      0 65333 i
 *   4.0.0.0          4.1.1.1                  0             0 65444 i
 *>                   0.0.0.0                  0         32768 i
 *>  10.0.0.0         0.0.0.0                  0         32768 i
 *>  11.0.0.0/24      0.0.0.0                  0         32768 i
 *>i 12.0.0.0/24      1.1.1.2                  0    100      0 i
 *   13.0.0.0/24      4.1.1.1                                0 65444 65333 i
 *>i                  1.1.1.2                  0    100      0 65333 i
 *>  14.0.0.0/24      4.1.1.1                  0             0 65444 i
 *>i 20.0.0.0         1.1.1.2                  0    100      0 i
 *   30.0.0.0         4.1.1.1                                0 65444 65333 i
     Network          Next Hop            Metric LocPrf Weight Path
 *>i                  1.1.1.2                  0    100      0 65333 i
 *>  40.0.0.0         4.1.1.1                  0             0 65444 i


R2#show ip bgp
BGP table version is 14, local router ID is 12.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf     Weight Path
 *>  1.0.0.0          0.0.0.0                  0                         32768   i
 * i                  1.1.1.1                       0            100         0         i
 *   2.0.0.0          2.1.1.2                   0                           0        65333   i
 *>                   0.0.0.0                      0                        32768    i
 * i 3.0.0.0          1.1.1.1                   0             100        0        65444 i
 *>                   2.1.1.2                      0                           0        65333    i
 *>i 4.0.0.0          1.1.1.1                  0             100        0         i
 *>i 10.0.0.0         1.1.1.1                 0            100         0         i
 *>i 11.0.0.0/24      1.1.1.1                0           100         0         i
 *>  12.0.0.0/24      0.0.0.0               0                       32768     i
 *>  13.0.0.0/24      2.1.1.2                  0                       0          65333 i
 *   14.0.0.0/24      2.1.1.2                                             0         65333 65444 i
 *>i                  1.1.1.1                  0                  100      0          65444 i
 *>  20.0.0.0         0.0.0.0                  0                      32768 i
     Network          Next Hop            Metric     LocPrf       Weight    Path
 *>  30.0.0.0         2.1.1.2                  0                                0           65333 i
 *   40.0.0.0         2.1.1.2                                                     0           65333 65444 i
 *>i                  1.1.1.1                  0                   100            0           65444 i



R1#show ip route bgp
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set


B     2.0.0.0/8 [200/0] via 1.1.1.2, 00:36:56
B     3.0.0.0/8 [20/0] via 4.1.1.1, 00:32:47
      12.0.0.0/24 is subnetted, 1 subnets
B        12.0.0.0 [200/0] via 1.1.1.2, 00:36:43
      13.0.0.0/24 is subnetted, 1 subnets
B        13.0.0.0 [200/0] via 1.1.1.2, 00:34:45
      14.0.0.0/24 is subnetted, 1 subnets
B        14.0.0.0 [20/0] via 4.1.1.1, 00:33:18
B     20.0.0.0/8 [200/0] via 1.1.1.2, 00:36:56
B     30.0.0.0/8 [200/0] via 1.1.1.2, 00:35:16
B     40.0.0.0/8 [20/0] via 4.1.1.1, 00:33:48



R1#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
  1 1.1.1.2 32 msec 36 msec 8 msec
  2 2.1.1.2 36 msec 64 msec 64 msec

R1#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 1.1.1.2 12 msec 60 msec 24 msec
  2 2.1.1.2 44 msec 52 msec 60 msec

R2#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
  1 2.1.1.2 288 msec 60 msec 28 msec

R2#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 2.1.1.2 76 msec 72 msec 60 msec


(To reach 30.1.1.1, 13.0.0.1 network router 1 and router 2 using 2.1.1.2 path because it has fewer numbers of an autonomous system. but as per our requirement, we need a router to use the 4.1.1.1 interface to reach all the networks, to manipulate the path we use local_pref)

R1(config)#router bgp 65111
R1(config-router)#bgp default local-preference 5000
R1(config-router)#end

R1#clear ip bgp * soft

R1#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 4.1.1.1 8 msec 52 msec 28 msec
  2 3.1.1.1 [AS 65444] 80 msec 40 msec 64 msec

R1#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
  1 4.1.1.1 24 msec 60 msec 68 msec
  2 3.1.1.1 [AS 65444] 112 msec 72 msec 52 msec


R2#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 1.1.1.1 4 msec 44 msec 28 msec
  2 4.1.1.1 36 msec 60 msec 8 msec
  3 3.1.1.1 [AS 65444] 60 msec 52 msec 44 msec


R2#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
  1 1.1.1.1 8 msec 28 msec 36 msec
  2 4.1.1.1 64 msec 116 msec 64 msec
  3 3.1.1.1 [AS 65444] 72 msec 72 msec 52 msec

R1#show ip bgp
BGP table version is 21, local router ID is 11.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 * i 1.0.0.0          1.1.1.2                  0    100      0 i
 *>                   0.0.0.0                  0         32768 i
 *>i 2.0.0.0          1.1.1.2                  0    100      0 i
 *>  3.0.0.0          4.1.1.1                  0             0 65444 i
 *   4.0.0.0          4.1.1.1                  0             0 65444 i
 *>                   0.0.0.0                  0         32768 i
 *>  10.0.0.0         0.0.0.0                  0         32768 i
 *>  11.0.0.0/24      0.0.0.0                  0         32768 i
 *>i 12.0.0.0/24      1.1.1.2                  0    100      0 i
 *>  13.0.0.0/24      4.1.1.1                                0 65444 65333 i
 *>  14.0.0.0/24      4.1.1.1                  0             0 65444 i
 *>i 20.0.0.0         1.1.1.2                  0    100      0 i
 *>  30.0.0.0         4.1.1.1                                0 65444 65333 i
 *>  40.0.0.0         4.1.1.1                  0             0 65444 i


R2#show ip bgp
BGP table version is 22, local router ID is 12.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found


     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.0.0.0          0.0.0.0                  0         32768 i
 * i                  1.1.1.1                  0   5000      0 i
 *   2.0.0.0          2.1.1.2                  0             0 65333 i
 *>                   0.0.0.0                  0         32768 i
 *>i 3.0.0.0          1.1.1.1                  0   5000      0 65444 i
 *                    2.1.1.2                  0             0 65333 i
 *>i 4.0.0.0          1.1.1.1                  0   5000      0 i
 *>i 10.0.0.0         1.1.1.1                  0   5000      0 i
 *>i 11.0.0.0/24      1.1.1.1                  0   5000      0 i
 *>  12.0.0.0/24      0.0.0.0                  0         32768 i
 *>i 13.0.0.0/24      1.1.1.1                  0   5000      0 65444 65333 i
 *                    2.1.1.2                  0             0 65333 i
 *   14.0.0.0/24      2.1.1.2                                0 65333 65444 i
 *>i                  1.1.1.1                  0   5000      0 65444 i
     Network          Next Hop            Metric LocPrf Weight Path
 *>  20.0.0.0         0.0.0.0                  0         32768 i
 *>i 30.0.0.0         1.1.1.1                  0   5000      0 65444 65333 i
 *                    2.1.1.2                  0             0 65333 i
 *   40.0.0.0         2.1.1.2                                0 65333 65444 i
 *>i                  1.1.1.1                  0   5000      0 65444 i


R2#show ip bgp 30.1.1.1
BGP routing table entry for 30.0.0.0/8, version 17
Paths: (2 available, best #1, table default)
  Advertised to update-groups:
     3
  Refresh Epoch 2
  65444 65333
    1.1.1.1 from 1.1.1.1 (11.0.3.1)
      Origin IGP, metric 0, localpref 5000, valid, internal, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 1
  65333
    2.1.1.2 from 2.1.1.2 (13.0.3.1)
      Origin IGP, metric 0, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0



(you can also use route map for particular routes. comment below for route map)

 


 


Instagram

Facebook


Twitter



LINKEDIN








No comments:

What is Virtual Router Redundancy Protocol (VRRP)? How to configure Virtual Router Redundancy Protocol (VRRP)?

 Virtual Router Redundancy Protocol (VRRP) is a gateway redundancy networking protocol used to create a virtual gateway similar to HSRP . VR...