Prerequisites: CCNP level skills.
Topology
Note!
All routers are configured as per topology diagram (pic. 1) and loopback advertised into BGP.
Pic. 1 - Topology Diagram.Icons designed by: Andrzej Szoblik - http://www.newo.pl
Task 1
On R2 and R4 advertise 10.1.24.0/24 into BGP. R2 should advertise this prefix towards R3 with metric 500.
Task 2
Ensure R3 prefers R1 towards 10.1.24.0/24. Do not modify any attributes to accomplish this.
Lab Solution
Task 1
On R2 and R4 advertise 10.1.24.0/24 into BGP. R2 should advertise this prefix towards R3 with metric 500.
R2 Configuration:
!
ip prefix-list LINK_R2_R4 seq 5 permit 10.1.24.0/24
!
!
route-map SET_MED permit 10
match ip address prefix-list LINK_R2_R4
set metric 500
!
route-map SET_MED permit 999
!
match ip address prefix-list LINK_R2_R4
set metric 500
!
route-map SET_MED permit 999
!
router bgp 20
no synchronization
bgp router-id 172.16.102.2
bgp log-neighbor-changes
network 10.1.24.0 mask 255.255.255.0
network 172.16.102.0 mask 255.255.255.0
neighbor 10.1.23.3 remote-as 13
neighbor 10.1.23.3 route-map SET_MED out
neighbor 10.1.24.4 remote-as 40
no auto-summary
no synchronization
bgp router-id 172.16.102.2
bgp log-neighbor-changes
network 10.1.24.0 mask 255.255.255.0
network 172.16.102.0 mask 255.255.255.0
neighbor 10.1.23.3 remote-as 13
neighbor 10.1.23.3 route-map SET_MED out
neighbor 10.1.24.4 remote-as 40
no auto-summary
!
R4 Configuration:
!
router bgp 40
no synchronization
bgp router-id 172.16.104.4
bgp log-neighbor-changes
network 10.1.24.0 mask 255.255.255.0
network 172.16.104.0 mask 255.255.255.0
network 172.16.144.0 mask 255.255.255.0
neighbor 10.1.14.1 remote-as 13
neighbor 10.1.24.2 remote-as 20
no synchronization
bgp router-id 172.16.104.4
bgp log-neighbor-changes
network 10.1.24.0 mask 255.255.255.0
network 172.16.104.0 mask 255.255.255.0
network 172.16.144.0 mask 255.255.255.0
neighbor 10.1.14.1 remote-as 13
neighbor 10.1.24.2 remote-as 20
!
Pic. 2 - Prefix Details on R3.
Notice!Metric (MED) is disregarded in comparison since the two paths come from different autonomous systems. R3 prefers External to Internal path.
Task 2
Ensure R3 prefers R1 towards 10.1.24.0/24. Do not modify any attributes to accomplish this.
R3 Configuration:
!
router bgp 13
no synchronization
bgp router-id 172.16.103.3
bgp always-compare-med
bgp log-neighbor-changes
network 172.16.103.0 mask 255.255.255.0
neighbor 10.1.13.1 remote-as 13
neighbor 10.1.13.1 next-hop-self
neighbor 10.1.23.2 remote-as 20
neighbor 10.1.35.5 remote-as 50
no auto-summary
no synchronization
bgp router-id 172.16.103.3
bgp always-compare-med
bgp log-neighbor-changes
network 172.16.103.0 mask 255.255.255.0
neighbor 10.1.13.1 remote-as 13
neighbor 10.1.13.1 next-hop-self
neighbor 10.1.23.2 remote-as 20
neighbor 10.1.35.5 remote-as 50
no auto-summary
!
Notice!
For the change to take effect I had to 'clear ip bgp *'
Pic. 3 - Prefix Details on R3.
Note!
MED is now compared and R3 chooses R1 (internal) path over external.
Enabling the bgp deterministic-med command ensures the comparison of the MED variable when choosing routes advertised by different peers in the same autonomous system.
Enabling the bgp always-compare-med command ensures the comparison of the MED for paths from neighbors in different autonomous systems. The bgp always-compare-med command is useful when multiple service providers or enterprises agree on a uniform policy for setting MED. Thus, for network X, if Internet Service Provider A (ISP A) sets the MED to 10, and ISP B sets the MED to 20, both ISPs agree that ISP A has the better performing path to X.
Notice!
The bgp deterministic-med and bgp always-compare-med commands are not enabled by default. Also, the two commands are separate; enabling one does not automatically enable the other.