BGP and metrics (help with lab)

Answered Question
Jun 17th, 2009

Hi All,

I'm doing a lab and trying to get my head around BGP and metrics (MED).

In my lab I have 3 border routers and AS as shown below. I want R1 to be able to control which default route to use. R2 and R3 both send the default route to R1.

10.10.10.0/24

R1 (AS4854) --------------------- R2 (AS1221)

|

|

| 10.10.20.0/24

|

|

R3 (AS7474)

If for example I wanted to use R3 as the preferred default route, is it a matter of simply giving it a lower metric? So what I did was create a route-map and for routes received from R3, give it a metric of 100, and for routes received from R2, give it a metric of 200.

R1 config:

router bgp 4854

no synchronization

bgp log-neighbor-changes

network 172.16.1.0 mask 255.255.255.0

neighbor 10.10.10.2 remote-as 1221

neighbor 10.10.10.2 soft-reconfiguration inbound

neighbor 10.10.10.2 route-map BGP-IN-200 in

neighbor 10.10.20.2 remote-as 7474

neighbor 10.10.20.2 soft-reconfiguration inbound

neighbor 10.10.20.2 route-map BGP-IN-100 in

no auto-summary

!

route-map BGP-IN-100 permit 10

set metric 100

!

route-map BGP-IN-200 permit 10

set metric 200

I can see the metrics taking effect, but not sure why R3 (10.10.20.2) isn't the preferred default route when it has a lower metric.

R1#sh ip bgp 0.0.0.0 0.0.0.0 longer-prefixes

BGP table version is 5, local router ID is 172.16.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path

*> 0.0.0.0 10.10.10.2 200 0 1221 i

* 10.10.20.2 100 0 7474 i

*> 172.16.1.0/24 0.0.0.0 0 32768 i

*> 172.16.2.0/24 10.10.10.2 200 0 1221 i

*> 172.16.3.0/24 10.10.20.2 100 0 7474 i

R2 config:

router bgp 1221

no synchronization

bgp log-neighbor-changes

network 172.16.2.0 mask 255.255.255.0

neighbor 10.10.10.1 remote-as 4854

neighbor 10.10.10.1 default-originate

neighbor 10.10.10.1 soft-reconfiguration inbound

R3 config:

router bgp 7474

no synchronization

bgp log-neighbor-changes

network 172.16.3.0 mask 255.255.255.0

neighbor 10.10.20.1 remote-as 4854

neighbor 10.10.20.1 default-originate

neighbor 10.10.20.1 soft-reconfiguration inbound

Am I missing something here??? My understanding of metrics (MED) is probably totally wrong!

Thanks.

Andy

Correct Answer by thotsaphon about 7 years 8 months ago

Andy,

MED is used to be compared routes from the same AS. What happens when you add a "bgp always-compare-med" command on.

IMHO: You are going to force R1 to use R3 as a preferred router for a default route. It's an outbound policy. What you can do is to change Weight for routes coming from R3.

Hopes you're gonna love this link : http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094431.shtml

HTH,

Toshi

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
thotsaphon Wed, 06/17/2009 - 22:03

Andy,

MED is used to be compared routes from the same AS. What happens when you add a "bgp always-compare-med" command on.

IMHO: You are going to force R1 to use R3 as a preferred router for a default route. It's an outbound policy. What you can do is to change Weight for routes coming from R3.

Hopes you're gonna love this link : http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094431.shtml

HTH,

Toshi

asaykao73 Wed, 06/17/2009 - 22:15

Hi Toshi,

That worked great. I applied the command "bgp always-compare-med" and cleared bgp and can see better preference given to the route with the lower metric now.

R0#sh ip bgp 0.0.0.0 0.0.0.0 longer-prefixes

BGP table version is 5, local router ID is 172.16.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path

* 0.0.0.0 10.10.10.2 200 0 1221 i

*> 10.10.20.2 100 0 7474 i

*> 172.16.1.0/24 0.0.0.0 0 32768 i

*> 172.16.2.0/24 10.10.10.2 200 0 1221 i

*> 172.16.3.0/24 10.10.20.2 100 0 7474 i

Although it worked, I'll have a read of the doco you sent me. I've read the doco before but bgp doesn't really stick with me because I don't use it very often.

Many thanks.

Andy

asaykao73 Wed, 06/17/2009 - 23:43

Is there a way to control inbound traffic so that all traffic coming into R1 comes in from one AS (ISP) only??? Do we have control over this??

thotsaphon Thu, 06/18/2009 - 00:35

Andy,

I'm not sure that we can configure at the R1 to tell the other routers that you don't send me traffic.In your case R1 is connecting with 2 ASes.In case you've got the same routes from 2 ASes you can use "Weight" to prefer routes coming from AS you want. In case of you lose routes/connections from that AS R1 still send to the other AS.

F.e. R1 prefers R3

!

ip as-path access-list 1 permit _1221$

ip as-path access-list 2 permit _7474$

!

route-map WEIGHT1000 permit 10

match as-path 1

set weight 1000

!

route-map WEIGHT1000 permit 20

!

!

route-map WEIGHT5000 permit 10

match as-path 2

set weight 5000

!

route-map WEIGHT5000 permit 10

!

router bgp 4854

neighbor 10.10.10.2 route-map WEIGHT1000 in

neighbor 10.10.20.2 route-map WEIGHT5000 in

HTH,

Toshi

Actions

This Discussion