Saturday, August 9, 2014

Lab 14 - BGP Best path selection - MED

    The BGP Best path selection algorithm for BGP looks at several path attributes and evaluates them in the following order of preference:

    1. Highest Weight
    2. Highest Local preference
    3. Locally originated
    4. Shortest AS_Path
    5. Origin; prefer IGP, before EGP, before Incomplete
    6. Lowest MED
    7. eBGP paths over iBGP paths
    8. Lowest IGP metric to the next hop
    9. For eBGP prefixes prefer first received route
    10. Lowest router ID
    11. Shortest cluster list length
    12. Lowest neighbor address

    In this lab we will look at the BGP MED attribute and how to use it for traffic engineering purposes. The MED attribute is an optional non-transitive attribute. It is essentially a hint to a neighbor about the preferred path into an autonomous system.

    Tasks:
    -Establish eBGP peering between R1, R2, R3, and R4
    -Establish iBGP peering between R3 and R2.
    -Advertise the loopbacks on R1 and R4 into BGP
    -Ensure traffic entering from AS 10 that originates in AS 30 enters AS 20
    via R2 using the MED attribute only to accomplish this.


    Topology



    GNS3 Files: Link

    Solution

    Let's being by complete our initial tasks of establishing our peering.

    R1(config)#router bgp 10
    R1(config-router)#neighbor 192.168.12.2 remote-as 20
    R1(config-router)#neighbor 192.168.13.3 remote-as 20

    R2(config)#router bgp 20
    R2(config-router)#neighbor 192.168.12.1 remote-as 10
    R2(config-router)#neighbor 192.168.23.3 remote-as 20
    R2(config-router)#neighbor 192.168.24.4 remote-as 30

    R3(config)#router bgp 20
    R3(config-router)#neighbor 192.168.13.1 remote-as 10
    R3(config-router)#neighbor 192.168.34.4 remote-as 30

    R4(config)#router bgp 30
    R4(config-router)#neighbor 192.168.24.2 remote-as 20
    R4(config-router)#neighbor 192.168.34.3 remote-as 20

    With that in place and confirmed by using the show ip bgp summary command, it's important to confirm what you have configured is working, we advertise our loopback addresses as requested in the lab.

    R1(config-router)#network 1.1.1.0 mask 255.255.255.0

    R4(config-router)#network 4.4.4.0 mask 255.255.255.0

    The next task requires that we control how AS 30 traffic leaving AS 10 enters AS 20 by using just the MED attribute. This attribute is only evaluated if all other higher priority attributes are of equal value, see the list above for those attributes. Since no specific criteria was given to how we accomplish setting the MED the easiest method is to just use the set command in a route-map and apply this outbound to the neighbor statement for the path we do not want traffic going over because the lower MED is preferred. So we want to set the MED higher to make the alternative paths more preferred.

    R3(config)#route-map SET_MED permit
    R3(config-route-map)#set metric 1000
    R3(config-route-map)#exit

    R3(config-router)#neighbor 192.168.13.1 route-map SET_MED out

    R1(config-router)#do sh ip bgp
    <snip>
         Network          Next Hop            Metric LocPrf Weight Path
     *>  1.1.1.0/24       0.0.0.0                  0         32768 i
     *   4.4.4.0/24       192.168.12.2                           0 20 30 i
     *>                   192.168.13.3                           0 20 30 i

    R1#clear ip bgp * soft
    <snip>
         Network          Next Hop            Metric LocPrf Weight Path
     *>  1.1.1.0/24       0.0.0.0                  0         32768 i
     *>  4.4.4.0/24       192.168.12.2                           0 20 30 i
     *                    192.168.13.3          1000             0 20 30 i

    R1#traceroute 4.4.4.4 source 1.1.1.1
    Type escape sequence to abort.
    Tracing the route to 4.4.4.4
    VRF info: (vrf in name/id, vrf out name/id)
      1 192.168.12.2 36 msec 36 msec 60 msec
      2 192.168.24.4 60 msec *  72 msec

    Pretty straight forward…and we are done.

    The GNS3 files include the base configuration as well as the final solution discussed here.

    Sources:

No comments:

Post a Comment