07 July, 2013

BGP ALWAYS COMPARE MED

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.


batman(config)#router bgp 200
batman(config-router)#neighbor 192.168.12.1 remote-as 100

ironman#conf ter
ironman(config)#router bgp 300
ironman(config-router)#neighbor 192.168.13.1 remote-as 100
ironman(config-router)#neighbor 192.168.34.4 remote-as 300

superman#configure terminal
superman(config)#router bgp 300
superman(config-router)#neighbor 192.168.34.3 remote-as 300
superman(config-router)#neighbor 192.168.14.1 remote-as 100
*Mar  1 00:13:38.751: %BGP-5-ADJCHANGE: neighbor 192.168.34.3 Up


spiderman#configure terminal
spiderman(config)#router bgp 100
spiderman(config-router)#neighbor 192.168.12.2 remote-as 200
spiderman(config-router)#neighbor 192.168.13.3 remote-as 300
spiderman(config-router)#neighbor 192.168.14.4 remote-as 300
*Mar  1 00:10:13.655: %BGP-5-ADJCHANGE: neighbor 192.168.12.2 Up
*Mar  1 00:12:11.971: %BGP-5-ADJCHANGE: neighbor 192.168.13.3 Up
*Mar  1 00:14:21.431: %BGP-5-ADJCHANGE: neighbor 192.168.14.4 Up

spiderman(config-router)#do show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.12.2    4   200      13      13        1    0    0 00:10:06        0
192.168.13.3    4   300      11      12        1    0    0 00:08:07        0
192.168.14.4    4   300       9       9        1    0    0 00:05:58        0

superman(config-router)#do show ip bgp summary
BGP router identifier 4.4.4.4, local AS number 300
BGP table version is 1, main routing table version 1
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.14.1    4   100      10      10        1    0    0 00:06:28        0
192.168.34.3    4   300      10      10        1    0    0 00:06:34        0

Advertise Networks

batman(config-router)#network 2.2.2.0 mask 255.255.255.0
batman(config-router)#network 192.168.12.0 mask 255.255.255.0

superman(config-router)#network 4.4.4.0 mask 255.255.255.0
superman(config-router)#network 192.168.14.0 mask 255.255.255.0
superman(config-router)#network 192.168.34.0 mask 255.255.255.0

ironman(config-router)#network 3.3.3.0 mask 255.255.255.0
ironman(config-router)#network 192.168.34.0 mask 255.255.255.0
ironman(config-router)#network 192.168.13.0 mask 255.255.255.0

spiderman(config-router)#network 1.1.1.0 mask 255.255.255.0
spiderman(config-router)#network 192.168.12.0 mask 255.255.255.0
spiderman(config-router)#network 192.168.13.0 mask 255.255.255.0
spiderman(config-router)#network 192.168.14.0 mask 255.255.255.0

batman#configure terminal
batman(config)#interface loopback 1
batman(config-if)#ip address 1.2.3.4 255.255.255.255
batman(config-if)#router bgp 200
batman(config-router)#network 1.2.3.4 mask 255.255.255.255

superman(config)#interface loopback 1
superman(config-if)#ip address 1.2.3.4 255.255.255.255
superman(config-if)#router bgp 300
superman(config-router)#network 1.2.3.4 mask 255.255.255.255

spiderman#show ip bgp 1.2.3.4
BGP routing table entry for 1.2.3.4/32, version 11
Paths: (3 available, best #3, table Default-IP-Routing-Table)
  Advertised to update-groups:
     1
  200
    192.168.12.2 from 192.168.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external
  300
    192.168.13.3 from 192.168.13.3 (3.3.3.3)
      Origin IGP, localpref 100, valid, external
  300
    192.168.14.4 from 192.168.14.4 (4.4.4.4)
      Origin IGP, metric 0, localpref 100, valid, external, best

spiderman#show ip bgp | be 1.2.3.4
*  1.2.3.4/32       192.168.12.2             0             0 200 i
*                   192.168.13.3                           0 300 i
*>                  192.168.14.4             0             0 300 i

Configure Route-Map

batman#configure terminal
batman(config)#access-list 1 permit 1.2.3.4
batman(config)#route-map MED permit 10
batman(config-route-map)#match ip address 1
batman(config-route-map)#set metric 150
batman(config-route-map)#exit
batman(config)#route-map MED permit 20
batman(config-route-map)#exit
batman(config)#router bgp 200
batman(config-router)#neighbor 192.168.12.1 route-map MED out

superman#configure terminal
superman(config)#access-list 1 permit 1.2.3.4
superman(config)#route-map MED permit 10
superman(config-route-map)#match ip address 1
superman(config-route-map)#set metric 50
superman(config-route-map)#exit
superman(config)#route-map MED permit 20
superman(config-route-map)#exit
superman(config)#router bgp 300
superman(config-router)#neighbor 192.168.14.1 route-map MED out
superman(config-router)#exit

ironman#configure terminal
ironman(config)#access-list 1 permit 1.2.3.4
ironman(config)#route-map MED permit 10
ironman(config-route-map)#match ip address 1
ironman(config-route-map)#set metric 50
ironman(config-route-map)#exit
ironman(config)#route-map MED permit 20
ironman(config-route-map)#exit
ironman(config)#router bgp 300
ironman(config-router)#neighbor 192.168.13.1 route-map MED out
ironman(config-router)#exit

spiderman#clear ip bgp *

spiderman#show ip bgp | be 1.2.3.4
*  1.2.3.4/32       192.168.13.3            50             0 300 i
*                   192.168.14.4            50             0 300 i
*>                  192.168.12.2           150             0 200 i

Its Use Mad Metric To The Best Path

spiderman#configure terminal
spiderman(config)#router bgp 100
spiderman(config-router)#bgp always-compare-med

spiderman(config-router)#do clear ip bgp *
*Mar  1 00:56:27.611: %BGP-5-ADJCHANGE: neighbor 192.168.12.2 Down User reset
*Mar  1 00:56:27.615: %BGP-5-ADJCHANGE: neighbor 192.168.13.3 Down User reset
*Mar  1 00:56:27.615: %BGP-5-ADJCHANGE: neighbor 192.168.14.4 Down User reset
*Mar  1 00:56:28.443: %BGP-5-ADJCHANGE: neighbor 192.168.12.2 Up
*Mar  1 00:56:28.835: %BGP-5-ADJCHANGE: neighbor 192.168.14.4 Up
*Mar  1 00:56:29.135: %BGP-5-ADJCHANGE: neighbor 192.168.13.3 Up

spiderman(config-router)#do show ip bgp | be 1.2.3.4
*> 1.2.3.4/32       192.168.13.3            50             0 300 i
*                   192.168.14.4            50             0 300 i
*                   192.168.12.2           150             0 200 i

##########################################################################################################