BGP Always compare MED


Scenario:

You are the senior networking engineer working for a huge comic book provider. Your network (AS 100) is connected to 2 different service providers and normally all traffic is being sent to your main ISP which is AS 300. However there is a certain network that is being sent to AS 200 which is your backup ISP. All traffic should be sent towards AS300, is this a cheap trick from your backup ISP to make more money? Or is there something else going on? Time for justice!

Goal:

  • All IP addresses are preconfigured as specified in the topology picture.
  • Configure EBGP between AS 100 and AS 200.
  • Configure EBGP between AS 100 and AS 300, make sure you have a neighbor relationship between router Spiderman and Superman as well as between router Spiderman and Ironman.
  • Configure IBGP within AS 300.
  • Make sure all neighbor relationships are working, advertise the correct networks in BGP to achieve full connectivity.
  • Router Batman AND Superman have the same IP address on the loopback1 interface, advertise this in BGP on both routers.
  • Ensure you can ping the 1.2.3.4 address from router Spiderman.
  • Take a look at the BGP table with ‘show ip bgp’ on router Spiderman.
  • Which path is being used for the 1.2.3.4 network?
  • Configure router Ironman and Superman so they send a MED of 50 for the 1.2.3.4 network towards router Spiderman.
  • Configure router Batman so it sends a MED of 150 for the 1.2.3.4 network towards router Spiderman.
  • Check router Spiderman with ‘show ip bgp’ to see the changes you just made, if not do a ‘clear ip bgp *’
  • Even though the MED from AS 300 is better, why is traffic towards 1.2.3.4 still being sent towards AS 200?
  • Configure router Spiderman so traffic towards 1.2.3.4 is sent towards AS 300, the only attribute you are allowed to change is MED.

It took me 1000s of hours reading books and doing labs, making mistakes over and over again until I mastered all the protocols for CCNP.

Would you like to be a master of networking too? In a short time without having to read 900 page books or google the answers to your questions and browsing through forums?

I collected all my knowledge and created a single ebook for you that has everything you need to know to become a master of CCNP.

You will learn all the secrets about BGP, attributes and more.

Does this sound interesting to you? Take a look here and let me show you how to Master CCNP ROUTE!

IOS:

c3640-jk9s-mz.124-16.bin

Topology:

BGP Always Compare MED

Video Solution:

Configuration Files

You need to register to download the GNS3 topology file. (Registration is free!)

Once you are logged in you will find the configuration files right here.

Opt In Image
Do you want your CCNA or CCNP Certificate?

The How to Master series helps you to understand complex topics like spanning-tree, VLANs, trunks, OSPF, EIGRP, BGP and more.

Written by RenΓ© Molenaar - CCIE #41726

You May Also Like

About the Author: Rene Molenaar

RenΓ© - CCIE #41726 is the creator of GNS3Vault.com where he shares CCNA, CCNP and CCIE R&S labs. He also blogs about networking on http://networklessons.com

22 Comments

  1. thanks Rene. I just finished this lab. took me a while but I understand a few things as a result. this is my final Spiderman config.

    router bgp 100
    no synchronization
    bgp always-compare-med
    bgp log-neighbor-changes
    network 192.168.12.0
    network 192.168.13.0
    network 192.168.14.0
    neighbor 192.168.12.2 remote-as 200
    neighbor 192.168.13.3 remote-as 300
    neighbor 192.168.14.4 remote-as 300
    no auto-summary
    !

    and this is my final Batman config.
    router bgp 200
    no synchronization
    bgp log-neighbor-changes
    network 1.2.3.4 mask 255.255.255.255
    neighbor 192.168.12.1 remote-as 100
    neighbor 192.168.12.1 route-map policy1 out
    no auto-summary
    !
    access-list 1 permit 1.2.3.4 0.0.0.0
    !
    route-map policy1 permit 10
    match ip address 1
    set metric 150
    !

    Rene, are you able to help me explain why it prefers the path through Batman for the 1.2.3.4 network (if “bgp always-compare-med” is not added to Spiderman)?

    Still can’t figure out.

    thanks.

  2. Let me help you a bit…first of all these are the BGP attributes:

    W Weight (Highest)
    L Local_Pref (Highest)
    O Originate (local originate)
    AS As_Path (shortest)
    O Origin Code (IGP < EGP < Incomplete) M MED (lowest) P Paths (External Paths preferred Over Internal) R Router ID (lowest) By default MED is only compared when you have multiple links to the SAME AS. When you configure the "always compare MED" it'll compare MED even when it's from different AS'es. Walk through the attribute list and try to see why it prefers one route over another πŸ™‚

    1. Hi Rene,

      Can you please explain why Router Spiderman prefer Batman as the best path for 1.2.3.4 before adding always-compare-med on spiderman.

      After adding always-compare-med on spiderman and resetting BGP on the routers . It took Ironman as the bestpath for 1.2.3.4 and then after restting the BGP for couple of times it is considering superman as the best path for 1.2.3.4. The route for 1.2.3.4 on spiderman flapps after resetting the bgp.

      I went through the BGP attributes but I could not makeout by spiderman is taking Batman as the bestpath for 1.2.3.4.

      Please advice..

      I am new to BGP . Your labs are very useful to unsderstand the topics in detail.

  3. Very good πŸ™‚ Just walk down the BGP attribute list whenever you are in doubt and you’ll find the answer. Keep in mind that this list can change…an example of this is when you enable BGP Load-balancing. By default BGP only uses a single path but you can enable load balancing which means the list will change/shift πŸ˜‰

  4. Rene, would it benefit to set the ‘bgp determistic-med’ bgp subcommand? Your labs are great.

  5. Very nice, I was stopped at
    Network Next Hop Metric LocPrf Weight Path
    * 1.2.3.4/32 192.168.13.3 50 0 300 ?
    * 192.168.14.4 50 0 300 ?
    *> 192.168.12.2 150 0 200 ?

    WOW, better med and no best path :O
    These kind of think you won’t think it happen until you face them

  6. Sorry I cannot edit my comment so I asked to delete it, but I think, lower med is better . In my lab is going through Superman
    Superman – 50
    Batman – 150
    Ironman – 50

    After that I used “bgp always-compare-med” under router bgp 100 and nothing changed.

    And I guess that this “Configure router Spiderman so traffic towards 1.2.3.4 is sent towards AS 300, the only attribute you are allowed to change is MED.” is done with an incoming route map that enforces to change the MED received from Superman to be lower than 50 and all is done.

    Very interesting lab.

  7. First let me explain the difference between BGP deterministic-med and BGP always-compare med.

    BGP deterministic-med will make sure that MED variable will be compared when a route is advertised by different peers in the same AS.

    BGP always-compare will make sure that you compare MED for peers in different AS’es.

    If you want to influence the MED the best thing to do is create a route-map and match/set the prefix πŸ™‚

    Glad you guys like the labs!

  8. I wouldn’t have got the #bgp always-compare-med without the hint, in fact it did switch to AS300 when I reset Batman, but not Spiderman, I suppose in 30 mins time that would of changed.

    Nice route-map practice.;)

  9. Thanks, I remember glancing over the bgp always-compare-med and bgp deterministic-med in my studies. This lab definitely clears it up for me. πŸ˜€

  10. Please someone tell me what to do with this error! I think I’m using the right IOS!!!!!!!!!!!!
    Spiderman: error from server localhost:7200: 208-unable to find object ‘Spiderman’
    Batman: error from server localhost:7200: 208-unable to find object ‘Batman’
    Superman: error from server localhost:7200: 208-unable to find object ‘Superman’
    Ironman: error from server localhost:7200: 208-unable to find object ‘Ironman’
    Thanks

  11. Hello…for Ameen Shaik’s question…why does Spiderman prefers the path toward Batman…it comes down to comparing “R Router ID (lowest)” as Rene said in the BGP metric list …
    Batman has 2.2.2.2 and Ironman and Superman have 3.3.3.3 and 4.4.4.4

  12. Hi Rene

    Don’t understand why we need this step (below), when 1.2.3.4 is advertised from other AS’s.?

    Configure router Spiderman so traffic towards 1.2.3.4 is sent towards AS 300, the only attribute you are allowed to change is MED.

    On another note, it was lowest router-id that was influencing route via Ironman Vs Superman, right?

    Let me know.
    Great labs, for one of the Advance BGP title lab, i had stent 8 hours to resolve (90% tasks) πŸ™‚
    Thanks.

Comments are closed.