라우팅 프로토콜은 Metric을 사용해 패킷의 최상의 경로를 결정하고 cost가 낮을수록 더 좋은 경로를 뜻한다.
Cost는 인터페이스의 대역폼에 반비례하며, 대역폭이 높으면 cost가 낮다.
Cost = reference bandwidth(참조 대역폭) / interface bandwidth(인터페이스 대역폭)
default reference bandwidth : (100,000,000)
Cost = 100,000,000 bps / interface bandwidth
Cost는 정수여야만 한다.
만약 정수보다 낮은 값이 계산된다면 가장 근접한 정수로 올림
Cost 계산 표
Interface Type | Reference Bandwidth in bps / Default Bandwidth in bps | Cost |
---|---|---|
10 Gigabit Ethernet (10Gbps) | 100,000,000 / 10,000,000,000 | 0.01 = 1 |
Gigabit Ethernet (1 Gbps) | 100,000,000 / 1,000,000,000 | 0.1 = 1 |
Fast Ethernet (100Mbps) | 100,000,000 / 100,000,000 | 1 |
Ethernet (10Mbps) | 100,000,000 / 10,000,000 | 1 |
Cost의 값을 변경하기 위해서는 Reference Bandwidth를 임의로 변경하면 된다.
auto-cost reference-bandwidth
ip ospf cost
ip ospf cost [value]
R1(config)# interface g0/0/1
R1(config-if)# ip ospf cost 30
R1(config-if)# interface lo0
R1(config-if)# ip ospf cost 10
R1(config-if)# end
R1#
R1# show ip ospf interface g0/0/0
...(생략)
Timer intervals Configured, Hell0 10, Dead 40
...(생략)
R1# show ip ospf neighbor
~ Dead Time ~
~ 00:00:35 ~
~ 00:00:31 ~
Router(config-if)# ip ospf hello-interval [seconds]
Router(config-if)# ip ospf dead-interval [sencond]
R1(config)# interface g0/0/0
R1(config-if)# ip ospf hello-interval 5
R1(config-if)# ip ospf dead-interval 20
R1(config-if)#
...(생략)
Neighbor Down: Dead timer expired
R1(config-if)# end
R1#
ip route 0.0.0.0 0.0.0.0 [next-hop-address | exit=intf]
R2(config)# interface lo1
R2(config)# ip address 64.100.0.1 255.255.255.252
R2(config-if)# exit
R2(config)# ip route 0.0.0.0 0.0.0.0 loopback 1
%Default route without gateway, if not a point-to-point interface, may impact performance
R2(config)# router ospf 10
R2(config-router)# default-information originate
R2(config-router)# end
R2#
show ip route
R2# show ip route | begin Gateway
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
S* 0.0.0.0/0 is directly connected, Loopback1
10.0.0.0/8 is variably subnetted, 9 subnets, 3 masks
(output omitted)
R1# show ip route | begin Gateway
Gateway of last resort is 10.1.1.6 to network 0.0.0.0
O*E2 0.0.0.0/0 [110/1] via 10.1.1.6, 00:11:08, GigabitEthernet0/0/0
10.0.0.0/8 is variably subnetted, 9 subnets, 3 masks
(output omitted)