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.
R1 (AS4854) --------------------- R2 (AS1221)
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.
router bgp 4854
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
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
router bgp 1221
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
router bgp 7474
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!
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