实验说明:
n redistribute ospf 1— Assigns a metric of 0 to OSPF routes.
 
n redistribute ospf 1 metric 5— Assigns a metric of 5 to OSPF routes.
 
n redistribute ospf 1 metric 5
     redistribute static
     default-metric 10— Assigns a metric of 5 to OSPF routes and a metric of    10 to static routes.
 
 
实验拓朴:
 
 BGP  default-metric metric 实验_路由交换
 
 

 

 

实验配置:
R1R2 EBGP邻居关系 R2 R3OSPF邻居关系.
 
R2 BGP中通告路由 ,配置default-metric
n  network 通告
Lo0 2.2.2.2/32  默认 metric
Lo1 22.22.22.22/32  并加 route-map 设置 metric
n  重分布通告
Redistribute ospf 1  + route-map 精确匹配 3.3.3.3/32   默认 metric
Redistribute static  设置 metric  (静态路由 33.33.33.33/32)
 
R1配置:
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Serial1/1
 ip address 10.1.12.1 255.255.255.0
!        
router bgp 1
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor 10.1.12.2 remote-as 2
 no auto-summary
!
 
R2配置:
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Serial1/0
 ip address 10.1.12.2 255.255.255.0
!
interface Serial1/1
 ip address 10.1.23.2 255.255.255.0
!
router ospf 1
 router-id 2.2.2.2
 log-adjacency-changes
 network 10.1.23.0 0.0.0.255 area 0
!
router bgp 2
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 network 2.2.2.2 mask 255.255.255.255
 network 22.22.22.22 mask 255.255.255.255 route-map metric
 redistribute static metric 200
 redistribute ospf 1 route-map ospf
 neighbor 10.1.12.1 remote-as 1
 default-metric 100
 no auto-summary
!
ip classless
ip route 33.33.33.33 255.255.255.255 Serial1/1
no ip http server
!        
!
ip prefix-list 1 seq 5 permit 3.3.3.3/32
route-map metric permit 10
 set metric 300
!
route-map ospf permit 10
 match ip address prefix-list 1
!
 
R3配置
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface Loopback1
 ip address 33.33.33.33 255.255.255.255
!
interface Serial1/0
 ip address 10.1.23.3 255.255.255.0
!
router ospf 1
 router-id 3.3.3.3
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 10.1.23.0 0.0.0.255 area 0
!
 
实验现象:
R1#sh ip bgp
BGP table version is 26, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 2.2.2.2/32       10.1.12.2                0             0 2 i
*> 3.3.3.3/32       10.1.12.2              100             0 2 ?
*> 22.22.22.22/32   10.1.12.2              300             0 2 i
*> 33.33.33.33/32   10.1.12.2              200             0 2 ?
R1#
 
R2#sh ip bgp
BGP table version is 5, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 2.2.2.2/32       0.0.0.0                  0         32768 i
*> 3.3.3.3/32       10.1.23.3              100         32768 ?
*> 22.22.22.22/32   0.0.0.0                300         32768 i
*> 33.33.33.33/32   0.0.0.0                200         32768 ?
R2#
 
 
实验结论:
default-metric 命令作用:
1. 只作用于重分布路由时.
  因为 2.2.2.2/32 路由 metric 仍为 0 ,命令未生效 3.3.3.3/32  metric 值被default-metric 命令改为 100.
2. 当重分布路由时,手工指定的 metric (例如redistribute static metric 200, + route-map 设置 metric值同样效果) 会优先于default-metric .