cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2052
Views
30
Helpful
18
Replies

Set Route preference from two same redistributed routes from BGP

Mark1110
Level 1
Level 1

Hello,

Someone know how to Set Route preference from two same redistributed routes from BGP through different vrfs.

I have two ISPs and learning default route from them. I want ISP1's default route choose as a priority. 

I am having two vrfs for them 1) ISP1_VRF 2) ISP2_VRF

I am creating 3rd vrf  INTERNAL_VRF and created VASI interfaces to communicate with these different vrf.

Anything i can use for redistribute command so it choose ISP1's default route and use ISP2's default route for backup on INTERNAL_VRF's routing table?

-------------------------

router ospf 1 vrf INTERNAL_VRF
capability vrf-lite
area 0 authentication message-digest
redistribute bgp 512 subnets route-map ISP1-BGP-TO-OSPF

----------------------------------------------------------

ip prefix-list ISP1-BGP-TO-OSPF seq 10 permit 0.0.0.0/0
route-map ISP1-BGP-TO-OSPF permit 10
match ip address prefix-list ISP1-BGP-TO-OSPF

 

18 Replies 18

Hello,

You could try setting a tag during redistribution and then adding local preference on the tagged route you want to use as your primary

 

-David

Thank you @David Ruess. Do you have any reference i can use for configuration? 

Apologies, that may not work. But looking at your setup you could do metric types.

IN the OSPF redistribution it defaults to External Type 2 metric. You can change this to Type 1 which is more preferred. You set it for the route you want it to prefer and it should choose that path. See example below:

R1(config-router)#redistribute bgp 512 subnets route-map ISP1-BGP-TO-OSPF metric-type ?
1 Set OSPF External Type 1 metrics
2 Set OSPF External Type 2 metrics

Type 1 is preferred over type 2 all else being equal. You can make your primary Type 1 and your Secondary the default of Type 2. That way if your primary fails it will use the secondary.

-David

 

 

Actually I have 2 edge routers connected to 2 ISPs. One is primary and one is secondary. So, in total 4 default routes for that VRF. I want 1 ISP connected to primary want first priority. 2nd isp connected to primary want second priority. 1st ISP connected to secondary edge router 3rd priority and 2nd ISP connected to secondary edge router 4th Priority. so, wondering if i can use

Primary edge router

redistribute bgp 512 subnets metric  50 route-map ISP1-BGP-TO-OSPF  

redistribute bgp 512 subnets metric  60 route-map ISP2-BGP-TO-OSPF 

secondary edge router

redistribute bgp 512 subnets metric  70 route-map ISP1-BGP-TO-OSPF 

redistribute bgp 512 subnets metric  80 route-map ISP2-BGP-TO-OSPF 

 

 

 

Hi @Mark1110 ,

Thanks for the additional info. Bear in mind that only one best path will be selected on each edge router. You can use the approach I described to make sure ISP1 is selected as the best path on each edge router. If you then want to prioritize edge router 1 over edge router 2, you can redistribute the bgp route into ospf as an external type 2 (default behavior) and set a higher metric on the route redistributed on edge router 2. This will result in ISP1 always being preferred over ISP2 within each edge router and edge router 1 always being preferred over edge router 2.

Regards, 

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México

Thank you @Harold Ritter . I am scheduling change for 4th Feb. I will let you know once change is completed. Appreciate your help all of you. 

You are very welcome @Mark1110 and thanks for the feedback

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México

you can use import/export map
I will try run lab and check

Thank you @MHM Cisco World. can we use metric in redistribution or change ospf cost ?

Harold Ritter
Level 12
Level 12

Hi @Mark1110 ,

I presume you use the import/export functionality to get routes from ISP1_VRF and ISP2_VRF to the INTERNAL_VRF. If so, you can actually set the weight to 65535 on the BGP session to ISP1, so it will be preferred when imported into the VRF INTERNAL_VRF.

Regards,

 

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México

Thank you @Harold Ritter . Just want to understand, If i Put weight to BGP session to ISP1 and redistribute it to OSPF. will it show different metric compare to route from ISP2?

Hi @Mark1110 ,

The best path decision will be made by bgp before the default route get redistributed into ospf. So the default route from ISP1 will be selected as the best path and redistributed into ospf. If the default route from ISP1 disappears, the default route from ISP2 will be selected as the best path and redistributed into ospf. 

Regards,

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México

Hi @Mark1110 ,

> If i Put weight to BGP session to ISP1 and redistribute it to OSPF. will it show different metric > compare to route from ISP2?

No, the BGP weight will not propagated to ospf. It only serves for the BGP best path selection on each edge router. You still need to set the metric higher on edge router 2, so that edge router 1 is always preferred over edge router 2.

Regards,

Harold Ritter
Sr Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México

ip vrf INTER
rd 3:100
route-target import 1:100
route-target import 2:100
!
ip vrf ISP1
rd 1:100
export map commisp1export
route-target export 1:100
!
ip vrf ISP2
rd 2:100
export map commisp2export
route-target export 2:100
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
ip vrf forwarding ISP1
ip address 100.0.0.1 255.255.255.0
duplex full
!
interface FastEthernet1/0
ip vrf forwarding ISP2
ip address 110.0.0.1 255.255.255.0
speed auto
duplex auto
!
interface FastEthernet1/1
ip vrf forwarding INTER
ip address 10.0.0.1 255.255.255.0
speed auto
duplex auto
!
router ospf 10 vrf INTER
redistribute bgp 100 subnets route-map ospftag
network 10.0.0.0 0.0.0.255 area 0
!
router bgp 100
bgp router-id 1.1.1.1
bgp log-neighbor-changes
!
address-family ipv4 vrf ISP1
neighbor 100.0.0.2 remote-as 200
neighbor 100.0.0.2 activate
exit-address-family
!
address-family ipv4 vrf ISP2
neighbor 110.0.0.3 remote-as 300
neighbor 110.0.0.3 activate
exit-address-family
!
ip forward-protocol nd
!
ip bgp-community new-format
ip community-list 1 permit 100:200
ip community-list 2 permit 100:300
!
no ip http server
no ip http secure-server
!
route-map commisp2export permit 10
set community 100:300
!
route-map commisp1export permit 10
set community 100:200
!
route-map ospftag permit 10
match community 1
set metric 1000
!
route-map ospftag permit 20
match community 2
set metric 2000

 

 

 

R4#show ip ospf database external

OSPF Router with ID (10.0.0.4) (Process ID 10)

Type-5 AS External Link States

Routing Bit Set on this LSA in topology Base with MTID 0
LS age: 8
Options: (No TOS-capability, DC, Downward)
LS Type: AS External Link
Link State ID: 23.23.23.23 (External Network Number )
Advertising Router: 10.0.0.1
LS Seq Number: 80000002
Checksum: 0x8E1C
Length: 36
Network Mask: /32
Metric Type: 2 (Larger than any link state path)
MTID: 0
Metric: 1000
Forward Address: 0.0.0.0
External Route Tag: 3489661028


khjkhjkjhkhjkhj.png

 

Review Cisco Networking for a $25 gift card