2017年5月5日金曜日

OSPF Loopbackのオリジナルプレフィックス広告

◾️OSPF Loopbackのオリジナルプレフィックス広告

 【課題】
  ・R2のLoopbackアドレス(192.168.200.1/24)をエリア0へ広告する。
   ただし、広告ルートのプレフィックスは/32ではなくオリジナルプレフィックスにて
   広告する事。
  
 【補足】
   OSPF上のLoopbackアドレスではデフォルトでは/32で経路広告される仕様です。
   ※デフォルトではOSPFネットワークタイプはLOOPBACKであり、例えLookback IPの
   プレフィックスが/24でも/32で広告される。

◾️検証環境図



①検証環境 事前設定確認


(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

(2)R2のLoopback200のインターフェース状態を確認する。
 設定上は192.168.200.1/24で設定されている事を確認する。

R2#show run int loopback 200

Building configuration...

Current configuration : 87 bytes
!
interface Loopback200
 ip address 192.168.200.1 255.255.255.0      //プレフィックス/24で設定されている
 ip ospf 1 area 0
end


R2#show ip ospf interface brief 

Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo200        1     0               192.168.200.1/24   1     LOOP  0/0
Et0/1        1     0               192.168.12.2/24    10    BDR   1/1
Et0/0        1     0               192.168.23.2/24    10    BDR   1/1


R2#show ip ospf interface loopback 200

Loopback200 is up, line protocol is up 
  Internet Address 192.168.200.1/24, Area 0, Attached via Interface Enable
  Process ID 1, Router ID 2.2.2.2, Network Type LOOPBACK, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Enabled by interface config, including secondary ip addresses
  Loopback interface is treated as a stub Host
※ネットワークタイプがLOOPBACKになっている。IPアドレスは/24になっている。


R2#sh ip ospf database router 


            OSPF Router with ID (2.2.2.2) (Process ID 1)

Router Link States (Area 0)

  LS age: 727
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 2.2.2.2
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000009
  Checksum: 0xE4C2
  Length: 72
  Number of Links: 4

    Link connected to: a Stub Network
     (Link ID) Network/subnet number: 192.168.200.1
     (Link Data) Network Mask: 255.255.255.255     //  /24ではなく/32になっている。
      Number of MTID metrics: 0
       TOS 0 Metrics: 1

(3)R4にてR2のLoopback200(192.168.200.0/24)の経路を確認する。
 /32になっている事を確認する。

R4#sh ip route | section 192.168.200.0

      192.168.200.0/32 is subnetted, 1 subnets
O        192.168.200.1 [110/21] via 192.168.34.3, 00:03:53, Ethernet0/1
                       [110/21] via 192.168.14.1, 00:03:53, Ethernet0/0


③設定変更1(ospfネットワークタイプを変更する。)


(1)R2にてネットワークタイプをLOOPBACKからpoint-to-pointへ変更する。

R2(config)#int loopback 200

R2(config-if)#ip ospf network point-to-point 

(2)R2にて設定確認する。
R2#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo200        1     0               192.168.200.1/24   1     P2P   0/0
Et0/1        1     0               192.168.12.2/24    10    BDR   1/1
Et0/0        1     0               192.168.23.2/24    10    BDR   1/1


R2#show ip ospf interface loopback 200

Loopback200 is up, line protocol is up 
  Internet Address 192.168.200.1/24, Area 0, Attached via Interface Enable
  Process ID 1, Router ID 2.2.2.2, Network Type POINT_TO_POINT, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Enabled by interface config, including secondary ip addresses
  Transmit Delay is 1 sec, State POINT_TO_POINT
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Index 4/4, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 0
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 0, Adjacent neighbor count is 0 
  Suppress hello for 0 neighbor(s)


R2#sh ip ospf database router                


            OSPF Router with ID (2.2.2.2) (Process ID 1)

Router Link States (Area 0)

  LS age: 1088
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 1.1.1.1
  Advertising Router: 1.1.1.1
  LS Seq Number: 80000008
  Checksum: 0x52B9
  Length: 60
  Number of Links: 3


    Link connected to: a Stub Network

     (Link ID) Network/subnet number: 192.168.200.0
     (Link Data) Network Mask: 255.255.255.0        //  /32になっている。
      Number of MTID metrics: 0
       TOS 0 Metrics: 1

(3)R4にてR2のLoopback200(192.168.200.0/24)の経路を確認する。
 /24(オリジナルプレフィックス)になっている事を確認する。

R4#sh ip route | section 192.168.200.0

O     192.168.200.0/24 [110/21] via 192.168.34.3, 00:03:42, Ethernet0/1
                       [110/21] via 192.168.14.1, 00:03:42, Ethernet0/0

OSPF ルート広告手法

◾️OSPF ルート広告手法

 【課題】
  ・R1,R2,R3のLoopbackアドレスをOSPFネットワークへ広告する。
    ※ただし、それぞれ異なる方法でルート広告する事
  
  【補足】
   OSPFネットワークにて経路広告する際、3つの手法がある。
   ①ルータコンフィグレーションモードでnetworkコマンドで設定する方法
   ②IFモードでip ospf xx area コマンドで設定する方法
   ③ルータコンフィグレーションモードでredistributeコマンドで設定する方法
   ※今回は以下の前提で設定する。
    R1ではnetworkコマンドにてルート広告
    R2ではip ospf xx area コマンドにてルート広告
    R3ではredistributeコマンドにてルート広告

◾️検証環境図















①検証環境 事前設定確認

(1)OSPFネイバー確認

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

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2         254   FULL/BDR        00:00:39    192.168.1.2     Ethernet0/0
3.3.3.3           0   FULL/DROTHER    00:00:38    192.168.1.3     Ethernet0/0


R2#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1         255   FULL/DR         00:00:35    192.168.1.1     Ethernet0/1
3.3.3.3           0   FULL/DROTHER    00:00:34    192.168.1.3     Ethernet0/1


R3#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1         255   FULL/DR         00:00:34    192.168.1.1     Ethernet0/2
2.2.2.2         254   FULL/BDR        00:00:33    192.168.1.2     Ethernet0/2

(2)OSPFエリア設定確認
 全てエリア0に属している事を確認する。
R1#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Et0/0        1     0               192.168.1.1/24     10    DR    2/2

R2#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Et0/1        1     0               192.168.1.2/24     10    BDR   2/2

R3#show ip ospf interface brief 
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Et0/2        1     0               192.168.1.3/24     10    DROTH 2/2


②設定変更1(ルータコンフィグレーションモードでnetworkコマンドで設定する方法)

(1)R1のLoopbackアドレスをnetworkコマンドにて広告する。
R1(config)#router ospf 1
R1(config-router)#network 1.1.1.1 255.255.255.255 area 0

(2)R2,R3のルーティングテーブルを確認し、R1のLoopbackアドレス経路が広告されている事を確認する
R2#sh ip route | include 1.1.1.1
O        1.1.1.1 [110/11] via 192.168.1.1, 00:03:54, Ethernet0/1

R3#sh ip route | include 1.1.1.1
O        1.1.1.1 [110/11] via 192.168.1.1, 00:03:37, Ethernet0/2

R2#sh ip route 1.1.1.1          
Routing entry for 1.1.1.1/32
  Known via "ospf 1", distance 110, metric 11, type intra area
  Last update from 192.168.1.1 on Ethernet0/1, 00:04:10 ago
  Routing Descriptor Blocks:
  * 192.168.1.1, from 1.1.1.1, 00:04:10 ago, via Ethernet0/1
      Route metric is 11, traffic share count is 1

R3#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
  Known via "ospf 1", distance 110, metric 11, type intra area
  Last update from 192.168.1.1 on Ethernet0/2, 00:04:15 ago
  Routing Descriptor Blocks:
  * 192.168.1.1, from 1.1.1.1, 00:04:15 ago, via Ethernet0/2
      Route metric is 11, traffic share count is 1


③設定変更2(IFモードでip ospf xx area コマンドで設定する方法)



(1)R2のLoopbackアドレスをip ospf xx areaコマンドにて広告する。
R2(config)#interface loopback 0
R2(config-if)#ip ospf 1 area 0

(2)R1,R3のルーティングテーブルを確認し、R2のLoopbackアドレス経路が広告されている事を確認する
R1#sh ip route | include 2.2.2.2
O        2.2.2.2 [110/11] via 192.168.1.2, 00:00:42, Ethernet0/0


R3#sh ip route | include 2.2.2.2
O        2.2.2.2 [110/11] via 192.168.1.2, 00:00:48, Ethernet0/2


R1#sh ip route 2.2.2.2
Routing entry for 2.2.2.2/32
  Known via "ospf 1", distance 110, metric 11, type intra area
  Last update from 192.168.1.2 on Ethernet0/0, 00:01:11 ago
  Routing Descriptor Blocks:
  * 192.168.1.2, from 2.2.2.2, 00:01:11 ago, via Ethernet0/0
      Route metric is 11, traffic share count is 1


R3#sh ip route 2.2.2.2                                         
Routing entry for 2.2.2.2/32
  Known via "ospf 1", distance 110, metric 11, type intra area
  Last update from 192.168.1.2 on Ethernet0/2, 00:02:29 ago
  Routing Descriptor Blocks:
  * 192.168.1.2, from 2.2.2.2, 00:02:29 ago, via Ethernet0/2
      Route metric is 11, traffic share count is 1



④設定変更3(R3ではredistributeコマンドにてルート広告)



(1)R3のLoopbackアドレスをredistributeコマンドにて広告する。
 ※シードメトリック値はそのまま(コスト加算せずに※metric-type2)伝搬させる事。
R3(config)#route-map Loopback_to_ospf permit 10
R3(config-route-map)#match interface loopback 0
R3(config)#router ospf 1
R3(config-router)#redistribute connected subnets route-map Loopback_to_ospf
//metric-typeはデフォルトで2です。
//subnetはサブネットワークをOSPFへ再配布したい際に設定するオプション設定です。

(2)R1,R2のルーティングテーブルを確認し、R2のLoopbackアドレス経路が広告されている事を確認する
R1#sh ip route | include 3.3.3.3
O E2     3.3.3.3 [110/20] via 192.168.1.3, 00:04:22, Ethernet0/0


R2#sh ip route | include 3.3.3.3
O E2     3.3.3.3 [110/20] via 192.168.1.3, 00:04:37, Ethernet0/1


R1#sh ip route 3.3.3.3  
Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10
  Last update from 192.168.1.3 on Ethernet0/0, 00:05:19 ago
  Routing Descriptor Blocks:
  * 192.168.1.3, from 3.3.3.3, 00:05:19 ago, via Ethernet0/0
      Route metric is 20, traffic share count is 1


R2#sh ip route 3.3.3.3 
Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10
  Last update from 192.168.1.3 on Ethernet0/1, 00:05:23 ago
  Routing Descriptor Blocks:
  * 192.168.1.3, from 3.3.3.3, 00:05:23 ago, via Ethernet0/1
      Route metric is 20, traffic share count is 1

(3)R1,R2のOSPFデータベースを確認する。
R1#show ip ospf database external 3.3.3.3

            OSPF Router with ID (1.1.1.1) (Process ID 1)

Type-5 AS External Link States

  Routing Bit Set on this LSA in topology Base with MTID 0
  LS age: 441
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 3.3.3.3 (External Network Number )
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0x385
  Length: 36
  Network Mask: /32
Metric Type: 2 (Larger than any link state path)
MTID: 0 
Metric: 20 
Forward Address: 0.0.0.0
External Route Tag: 0


⑤設定変更4(R3ではredistributeコマンドにてルート広告)


 ※シードメトリック値にコスト値を加算(metric-type1)伝搬させる事。
R3(config)#route-map Loopback_to_ospf permit 10
R3(config-route-map)#match interface loopback 0
R3(config)#router ospf 1
R3(config-router)#redistribute connected subnets route-map Loopback_to_ospf metric-type 1

(2)R1,R2のルーティングテーブルを確認し、R2のLoopbackアドレス経路が広告されている事を確認する
※R1-R3及びR2-R3間のOSPFコスト10が加算される。

R1#sh ip route | include 3.3.3.3         
E1     3.3.3.3 [110/30] via 192.168.1.3, 00:00:20, Ethernet0/0



R2#sh ip route | include 3.3.3.3 
E1     3.3.3.3 [110/30] via 192.168.1.3, 00:02:18, Ethernet0/1



R1#sh ip route 3.3.3.3
Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 30type extern 1
  Last update from 192.168.1.3 on Ethernet0/0, 00:08:19 ago
  Routing Descriptor Blocks:
  * 192.168.1.3, from 3.3.3.3, 00:08:19 ago, via Ethernet0/0

      Route metric is 30, traffic share count is 1



R2#sh ip route 3.3.3.3
Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 30, type extern 1
  Last update from 192.168.1.3 on Ethernet0/1, 00:08:28 ago
  Routing Descriptor Blocks:
  * 192.168.1.3, from 3.3.3.3, 00:08:28 ago, via Ethernet0/1

      Route metric is 30, traffic share count is 1



R1#show ip ospf database external 3.3.3.3

            OSPF Router with ID (1.1.1.1) (Process ID 1)

Type-5 AS External Link States

  Routing Bit Set on this LSA in topology Base with MTID 0
  LS age: 334
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 3.3.3.3 (External Network Number )
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000002
  Checksum: 0x7D8A
  Length: 36
  Network Mask: /32
Metric Type: 1 (Comparable directly to link state metric)
MTID: 0 
Metric: 20     //再配布時のメトリック値
Forward Address: 0.0.0.0

External Route Tag: 0