Preferred Route

Hi
I have a scenario as follows:

ip vrf vrf-A 
  rd 1:1 
  route-target  both 1:1 
  route-target import 1:2 

ip vrf vrf-B
  rd 1:2 
  route -target both 1:2 
  route-target  import 1:1 

int vlan111
 ip forwarding vrf vrf-A
 ip add 10.222.247.6 255.255.255.248
 no shut

int vlan222
 ip forwarding vrf vrf-B
 ip add 10.222.247.10 255.255.255.248
 no shut

router bgp 1 
 address-family ipv4 vrf  vrf-A
    redistribute connected
    redistribute static
 exit-address-family

router bgp 1 
 address-family ipv4 vrf  vrf-B
    redistribute connected
    redistribute static
 exit-address-family

!
ip route vrf  vrf-A 10.138.240.0  255.255.248.0  vlan111  10.222.247.2  
ip route vrf  vrf-B 10.138.246.0  255.255.255.0  vlan222  10.222.247.14 
!
========*====================================
> # show ip route vrf  vrf-A 10.138.246.0 255.255.255.0
> Routing Table:  **vrf-A**
> Routing entry for **10.138.246.0/24**
>   Known via **"bgp 1"**, **distance 20**, metric 0, type external
>   Last update from 10.137.247.9 on VlanY, 0d2h ago
>   Routing Descriptor Blocks:
>   * **10.222.247.9 ( vrf-B)**, from 0.0.0.0, 0d2h ago, via **Vlan222**
>       Route metric is 0, traffic share count is 1
>       AS Hops 0
>       MPLS label: none
>       MPLS Flags: NSF

vrf-A reaches the network 10.138.246.0 /24 only via VRF vrf-B (BGP), while there is a static route to summary subnet as mentioned above.

> ip route vrf vrf-A 10.138.240.0 255.255.248.0 vlan111 10.222.247.2

10.138.246.0/24 is included in the summary subnet 10.138.240.0 /21

when adding a static route to the specific network:

# ip route vrf vrf-A 10.138.246.0 255.255.255.0 vlan111 10.222.247.2

things become fine as following:

> # show ip  route  vrf  vrf-A  10.238.246.0  255.255.255.0
> Routing Table: **vrf-A**
> Routing entry for **10.138.246.0/24**
>   Known via **"static"**, distance 1, metric 0
>   Redistributing via bgp 1
>   Advertised by bgp 1
>   Routing Descriptor Blocks:
>   * **10.222.247.3, via Vlan111**
>       Route metric is 0, traffic share count is 1

ANY body have any idea why is that happening??

_

thanks,

  1. longest match
  2. best AD ( static = 1, eBGP = 20, iBGP=200)

So if there is a static summary route with mertic 1 and a specfic ibgp route with metric 200, it will still choose the longest match and this is the bgp route.

2 Likes

Thanks Lukas, now it’s clear,