2017年5月5日金曜日

OSPF コスト値変更

◾️OSPF コスト値変更

 【課題】
  ・R4からR2のLoopbackアドレスへ通信する際、R1経由に通信させる。
  
  【補足】
   OSPFのコスト値を変更する際、3つの手法がある。
   ①ip ospf costコマンドにて設定する方法
   ②bandwidthコマンドにて帯域幅にて設定する方法※100M/bandwidth
   ③auto-cost reference-bandwidthコマンドにてコスト計算式の分子を変更する方法

    ※デフォルトでは100M/bandwidth。尚、全ルータで設定する必要がある。

   今回は上記①②点別に検証を実施する。
   ※③はospfルータ全体に設定する必要があり。上記課題のようなcostによる通信制御
   は出来ない。


   >>オススメ記事:OSPF コストの計算式やコスト加算のタイミングを解説


◾️検証環境図





①検証環境 事前設定確認


(1)OSPFネイバー確認

 OSPFネイバーが正常に張れている事を確認する。
R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:30    192.168.12.2    Ethernet0/1
4.4.4.4           1   FULL/DR         00:00:34    192.168.14.4    Ethernet0/0


R2#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/BDR        00:00:33    192.168.12.1    Ethernet0/1
3.3.3.3           1   FULL/DR         00:00:38    192.168.23.3    Ethernet0/0


R3#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
4.4.4.4           1   FULL/DR         00:00:36    192.168.34.4    Ethernet0/1
2.2.2.2           1   FULL/BDR        00:00:33    192.168.23.2    Ethernet0/0


R4#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/BDR        00:00:34    192.168.34.3    Ethernet0/1
1.1.1.1           1   FULL/BDR        00:00:37    192.168.14.1    Ethernet0/0


R4#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo0          1     0               4.4.4.4/32         1     LOOP  0/0
Et0/1        1     0               192.168.34.4/24    10    DR    1/1
Et0/0        1     0               192.168.14.4/24    10    DR    1/1  //Et0/0のcostを変更

(2)事前ルーティング確認


R4#show ip route | se 2.2.2.2     
O        2.2.2.2 [110/21] via 192.168.34.3, 00:18:17, Ethernet0/1
                 [110/21] via 192.168.14.1, 00:18:17, Ethernet0/0


R4#sh ip route 2.2.2.2
Routing entry for 2.2.2.2/32
  Known via "ospf 1", distance 110, metric 21, type intra area
  Last update from 192.168.14.1 on Ethernet0/0, 00:19:38 ago
  Routing Descriptor Blocks:
  * 192.168.34.3, from 2.2.2.2, 00:19:38 ago, via Ethernet0/1
      Route metric is 21, traffic share count is 1
    192.168.14.1, from 2.2.2.2, 00:19:38 ago, via Ethernet0/0

      Route metric is 21, traffic share count is 1
※現在はR1経由 /R4経由で等コストロードバランシング

R4#traceroute 2.2.2.2
Type escape sequence to abort.
Tracing the route to 2.2.2.2
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.14.1 9 msec
    192.168.34.3 7 msec
    192.168.14.1 7 msec
  2 192.168.23.2 9 msec
    192.168.12.2 12 msec

    192.168.23.2 8 msec

②設定変更1(ip ospf costコマンドにて設定する方法)


(1)R4にてコスト値を変更する。
R4(config)#int e0/0
R4(config-if)#ip ospf cost 1
(2)R4にてコスト値が変更されている事を確認する。
R4#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo0          1     0               4.4.4.4/32         1     LOOP  0/0
Et0/1        1     0               192.168.34.4/24    10    DR    1/1
Et0/0        1     0               192.168.14.4/24        DR    1/1


R4#show ip route | se 2.2.2.2
O        2.2.2.2 [110/12] via 192.168.14.1, 00:00:12, Ethernet0/0


R4#show ip route 2.2.2.2
Routing entry for 2.2.2.2/32
  Known via "ospf 1", distance 110, metric 12, type intra area
  Last update from 192.168.14.1 on Ethernet0/0, 00:03:32 ago
  Routing Descriptor Blocks:
  * 192.168.14.1, from 2.2.2.2, 00:03:32 ago, via Ethernet0/0
      Route metric is 12, traffic share count is 1

(3)R4からR2のLoopbackアドレス宛にtracerouteを実行する。
 R1経由で通信されることを確認する。
R4#traceroute 2.2.2.2
Type escape sequence to abort.
Tracing the route to 2.2.2.2
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.14.1 9 msec 5 msec 8 msec
  2 192.168.12.2 7 msec 9 msec 10 msec

③設定変更2(bandwidthコマンドにて帯域幅にて設定する方法)


(1)R4にてコスト値を変更する。
R4(config)#int e0/0      
R4(config-if)#bandwidth 100000

※ちなみに、帯域幅の設定はKbit単位で設定する必要があります。
R4(config)#int e0/0      
R4(config-if)#bandwidth ?   
  <1-10000000>   Bandwidth in kilobits

(2)R4にてコスト値が変更されている事を確認する。
R4#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo0          1     0               4.4.4.4/32         1     LOOP  0/0
Et0/1        1     0               192.168.34.4/24    10    DR    1/1
Et0/0        1     0               192.168.14.4/24    1     DR    1/1


R4#show ip route | se 2.2.2.2   
O        2.2.2.2 [110/12] via 192.168.14.1, 00:00:22, Ethernet0/0


R4#show ip route 2.2.2.2     
Routing entry for 2.2.2.2/32
  Known via "ospf 1", distance 110, metric 12, type intra area
  Last update from 192.168.14.1 on Ethernet0/0, 00:00:29 ago
  Routing Descriptor Blocks:
  * 192.168.14.1, from 2.2.2.2, 00:00:29 ago, via Ethernet0/0
      Route metric is 12, traffic share count is 1

(3)R4からR2のLoopbackアドレス宛にtracerouteを実行する。
 R1経由で通信されることを確認する。
R4#traceroute 2.2.2.2
Type escape sequence to abort.
Tracing the route to 2.2.2.2
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.14.1 10 msec 11 msec 10 msec
  2 192.168.12.2 10 msec 13 msec 8 msec

④設定変更2(auto-cost reference-bandwidthコマンドにてコスト計算式の分子を変更する方法)


(1)デフォルトの設定値を確認する。
R1#show run all | include auto-cost reference-bandwidth
 auto-cost reference-bandwidth 100
//デフォルトでは、分子100Mで設定されている。コスト=帯域幅/100M

※ちなみに、コスト計算で利用される帯域幅はMbit単位で設定する必要があります。
<注意>上記④の通り、IFモードで設定する帯域幅(bandwidth)はKbit単位です。
R1(config-router)#auto-cost reference-bandwidth ?
  <1-4294967>  The reference bandwidth in terms of Mbits per second

(2)コスト計算式の分母を変更する。
R1(config-router)#auto-cost reference-bandwidth 10
% OSPF: Reference bandwidth is changed. 
        Please ensure reference bandwidth is consistent across all routers.


R2(config-router)#auto-cost reference-bandwidth 10
% OSPF: Reference bandwidth is changed. 
        Please ensure reference bandwidth is consistent across all routers.

R3(config-router)#auto-cost reference-bandwidth 10
% OSPF: Reference bandwidth is changed. 
        Please ensure reference bandwidth is consistent across all routers.

R4(config-router)#auto-cost reference-bandwidth 10
% OSPF: Reference bandwidth is changed. 
        Please ensure reference bandwidth is consistent across all routers.


(3)R4にてコスト値が変更されている事を確認する。

R4#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo0          1     0               4.4.4.4/32             LOOP  0/0
Et0/1        1     0               192.168.34.4/24        DR    1/1
Et0/0        1     0               192.168.14.4/24        DR    1/1
※コストの計算式の分母が変わっている為、Et0/0のみでなくEt0/1も変わっている。