08 November 2014

BGP Local Preference Attribute

BGP attribute local preference is the second BGP attribute and it can be used to choose the exit path for an autonomous system. Here are the details:

Local preference is the second BGP attribute.
You can use local preference to choose the outbound external BGP path.
Local preference is sent to all internal BGP routers in your autonomous system.
Not exchanged between external BGP routers.
Local preference is a well-known and discretionary BGP attribute.
Default value is 100.
The path with the highest local preference is preferred

You can use local preference to configure your autonomous system to select a certain exit point. Instead of configuring weight on each router you can use local preference because it is exchanged on all internal BGP routers


Let me show you an example:


- bgp table before the use of route-map

CE# sh ip bgp | b Network         
    Network          Next Hop            Metric LocPrf Weight Path
 *>  150.0.0.0/24     80.0.0.1                 0             0 7 i
 *>  150.1.0.0/24     80.0.0.1                 0             0 7 i
 *>  150.2.0.0/24     80.0.0.1                 0             0 7 i
 *>  150.3.0.0/24     80.0.0.1                 0             0 7 i
 *>  188.0.0.0/24     0.0.0.0                  0         32768 i
 *   199.0.0.0        70.0.0.1                 0             0 3 i
 *>                   80.0.0.1                 0             0 7 i
 *>  210.0.0.0        70.0.0.1                 0             0 3 i
 *>  210.1.0.0        70.0.0.1                 0             0 3 i
 *>  210.2.0.0        70.0.0.1                 0             0 3 i
 *>  210.3.0.0        70.0.0.1                 0             0 3 i

- After the use of the route-map

CE# sh ip bgp | b Network
    Network          Next Hop            Metric LocPrf Weight Path
 *>  150.0.0.0/24     80.0.0.1                 0             0 7 i
 *>  150.1.0.0/24     80.0.0.1                 0             0 7 i
 *>  150.2.0.0/24     80.0.0.1                 0             0 7 i
 *>  150.3.0.0/24     80.0.0.1                 0             0 7 i
 *>  188.0.0.0/24     0.0.0.0                  0         32768 i
 *>  199.0.0.0        70.0.0.1                 0    101      0 3 i
 *                    80.0.0.1                 0             0 7 i
 *>  210.0.0.0        70.0.0.1                 0             0 3 i
 *>  210.1.0.0        70.0.0.1                 0             0 3 i
 *>  210.2.0.0        70.0.0.1                 0             0 3 i
 *>  210.3.0.0        70.0.0.1                 0             0 3 i

How easy is that? Here is the full relevant configuration:

CE# sh ip bgp 199.0.0.0
          
BGP routing table entry for 199.0.0.0/24, version 12
Paths: (2 available, best #1, table default)
  Not advertised to any peer
  Refresh Epoch 3
  3
    70.0.0.1 from 70.0.0.1 (70.0.0.1)
      Origin IGP, metric 0, localpref 101, valid, external, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 3
  7
    80.0.0.1 from 80.0.0.1 (80.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0

CE# sh run | s bgp
router bgp 1
 bgp log-neighbor-changes
 network 188.0.0.0 mask 255.255.255.0
 neighbor 70.0.0.1 remote-as 3
 neighbor 70.0.0.1 update-source Serial3/0
 neighbor 70.0.0.1 distribute-list 1 out
 neighbor 70.0.0.1 route-map Prefer70nei in
 neighbor 80.0.0.1 remote-as 7
 neighbor 80.0.0.1 update-source Serial2/0
 neighbor 80.0.0.1 distribute-list 1 out

CE# sh route-map Prefer70nei
route-map Prefer70nei, permit, sequence 10
  Match clauses:
    ip address (access-lists): 70 
  Set clauses:
    local-preference 101
  Policy routing matches: 0 packets, 0 bytes

route-map Prefer70nei, permit, sequence 20
  Match clauses:
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes

CE# sh access-lists
Standard IP access list 1
    10 permit 188.0.0.0, wildcard bits 0.0.0.255 (3 matches)
Standard IP access list 70
    10 permit 199.0.0.0, wildcard bits 0.0.0.255 (1 match)


biOos

No comments: