目的

異なるネットワークに所属している2台のPCをお互いに通信させます。
ルーティングプロトコルはOSPFを使用します。

接続構成

ospf10-05.png

コマンド

router ospf [プロセス番号](1~65535)
network [アドレス] [ワイルドカードビット] area [エリアID]

 

OSPFを設定します。

設定

R1の設定

R1(config)#int f0/0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no shut

 

R1(config-if)#int s0/0
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#no shut

 

R1(config)#router ospf 1
OSPFをプロセス番号1で起動(番号は1~65535の範囲で設定)
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 192.168.2.0 0.0.0.255 area 0
OSPFを有効にするインターフェースとエリアIDを設定

 

 

R2の設定

R2(config-if)#int s0/0
R2(config-if)#ip add 192.168.2.2 255.255.255.0
R2(config-if)#no shut

 

R2(config)#int f0/0
R2(config-if)#ip add 192.168.3.1 255.255.255.0
R2(config-if)#no shut

 

R2(config)#router ospf 1
OSPFをプロセス番号1で起動(番号は1~65535の範囲で設定)
R2(config-router)#network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0
OSPFを有効にするインターフェースとエリアIDを設定

 

 

PC-1の設定

PC-1> ip 192.168.1.100/24 192.168.1.1
Checking for duplicate address...
PC1 : 192.168.1.100 255.255.255.0 gateway 192.168.1.1

 

PC-1> save
Saving startup configuration to startup.vpc
. done

 

 

PC-2の設定

PC-2> ip 192.168.3.100/24 192.168.3.1
Checking for duplicate address...
PC1 : 192.168.3.100 255.255.255.0 gateway 192.168.3.1

 

PC-2> save
Saving startup configuration to startup.vpc
. done

設定確認

ルーティングプロトコルの確認

R1#sh ip protocols
Routing Protocol is "ospf 1" ①
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.2.1 ②
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
192.168.1.0 0.0.0.255 area 0 ③
192.168.2.0 0.0.0.255 area 0
Routing Information Sources:
Gateway Distance Last Update
192.168.3.1 110 00:16:33 ④
192.168.2.1 110 00:16:33
Distance: (default is 110)

 

①有効化されているルーティングプロトコルは 「OSPF」で、プロセスIDは「1」
②ルータIDは 「192.168.2.1」
※今回の設定例では明示的にルータIDやループバックインターフェースを設定していないため、物理インターフェースの最大のIPアドレスがルータIDになる。
③ルーティングするネットワークは、以下の2つ。
 ・192.168.1.0 0.0.0.255
 ・192.168.2.0 0.0.0.255
④エリア内でLSAを交換しているルータの情報は、「192.168.3.1」と「192.168.2.1」

 

ルーティングテーブルの確認

R1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, Serial0/0
O 192.168.3.0/24 [110/65] via 192.168.2.2, 00:22:02, Serial0/0 ①

 


O
ルートの情報源、OSPFのこと。その他は以下の通り。

コード 意味
O OSPFエリア内ルート
O IA OSPFエリア間ルート
O E1 OSPF外部ルートメトリックタイプ1
O E2 OSPF外部ルートメトリックタイプ2
O N1 OSPF NSSA 外部ルートメトリックタイプ1
O N2 OSPF NSSA 外部ルートメトリックタイプ2

 

192.168.3.0/24
リモートネットワーク

 

[110/65]
110は、アドミニストレーティブディスタンス
65は、メトリック(コスト)

 

via 192.168.2.2
ネクストホップ

 

00:22:02
更新後の時間。
OSPFはネットワークトポロジに変化があった場合にトリガーアップデートするのでアップデート後、22分02秒経過している。

 

Serial0/0
到達可能インターフェース(自分自身のインターフェースを指す)

 

 

OSPFの確認

R1#sh ip ospf
Routing Process "ospf 1" with ID 192.168.2.1 ①
Supports only single TOS(TOS0) routes
Supports opaque LSA
SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
External flood list length 0
Area BACKBONE(0) ②
Number of interfaces in this area is 2
Area has no authentication
SPF algorithm executed 3 times ③
Area ranges are
Number of LSA 2. Checksum Sum 0x00C646
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0

 

①ルーティングプロトコルは「OSPF」でプロセスIDは「1」、ルータIDは「192.168.2.1」
②Backboneエリア(エリア0)に2つのインターフェースが参加している
③SPF計算が3回実行された
※ネットワークの一部がフラッピングしていたり、適切なエリア設計がされていない時はSPF計算の回数が多くなる。そのため、SPF計算回数が多い時は、フラッピングの有無やエリア設計の見直しなどを検討する必要がある。

 

インターフェースの確認

OSPFの設定をしたら、必ず show ip ospf interface コマンドで意図したインターフェースでOSPFが有効になっているか確認して下さい。ワイルドカードマスクの設定を間違えると、意図したインターフェースでOSPFが有効になっていないことがあります。

R1#sh ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0 ①
Process ID 1, Router ID 192.168.2.1, Network Type BROADCAST, Cost: 1 ②
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.2.1, Interface address 192.168.1.1
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40 ③, Wait 40, Retransmit 5
Hello due in 00:00:08
Index 2/2, 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)

 

Serial0/0 is up, line protocol is up
Internet Address 192.168.2.1/24, Area 0 ④

 

Process ID 1, Router ID 192.168.2.1, Network Type POINT_TO_POINT, Cost: 64 ⑤
Transmit Delay is 1 sec, State POINT_TO_POINT,
Timer intervals configured, Hello 10, Dead 40 ⑥, Wait 40, Retransmit 5
Hello due in 00:00:03
Index 2/2, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 192.168.3.1
Suppress hello for 0 neighbor(s)
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0
Process ID 1, Router ID 192.168.2.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.2.1, Interface address 192.168.1.1
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:07
Index 1/1, 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)

 

①192.168.1.1/24(FastEthernet0/0)は 「Area 0」 に参加している

 

②プロセスIDは 「1」
 ルータIDは 「192.168.2.1」
 ネットワークタイプは 「BROADCAST」
 コストは 「64」

 

③ネイバー関係形成の条件であるHelloインターバルは10秒、Deadインターバルは40秒

 

④192.168.2.1/24(Serial0/0)は 「Area 0」 に参加している

 

⑤プロセスIDは 「1」
 ルータIDは 「192.168.2.1」
 ネットワークタイプは 「POINT_TO_POINT」
 コストは 「64」
 ※「POINT_TO_POINT」は、1対1の関係で、R2と接続されていることを表す。
  POINT_TO_POINTネットワークではDR/BDRは選定されない。
  そのため、DR/BDRの情報はありません。

 

⑥ネイバー関係形成の条件であるHelloインターバルは10秒、Deadインターバルは40秒

 

ネイバーテーブルの確認

R1#sh ip ospf neighbor

 

Neighbor ID Pri State Dead Time Address Interface
192.168.3.1 1 FULL/ - 00:00:38 192.168.2.2 Serial0/0 ①

 


Neighbor ID
192.168.3.1
R2のルータIDが表示されていることから、RouterAとRouterBはネイバー関係が形成できている。

 

State
FULL/-
ネイバーとのOSPFステータスを表す。
FULLはアジャセンシーを確立しリンクステートデータベースの交換が完了しているステータス。
「/」のあとは、マルチアクセスネットワークでのみ、DR、BDR、DROTHERのいずれかが表示される。ポイントツーポイントネットワークの場合、DR、BDRは選出されない。

 

もし、ネイバーが確立できていなければ、以下を確認して下さい。

  • network コマンドの設定
  • OSPFネットワークタイプ
  • Hello/Deadインターバル
  • スタブエリアの設定
  • 認証の設定

 

LSDBの確認

ネイバーからLSAを受信しているか確認する。

R1#sh ip ospf database

 

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

 

Router Link States (Area 0) ①

 

Link ID ADV Router Age Seq# Checksum Link count
192.168.2.1 192.168.2.1 1743 0x80000003 0x0049BF 3
192.168.3.1 192.168.3.1 1663 0x80000003 0x007E86 3

 

①LSAタイプ1 (ルータLSA)の情報の見出し。
Link IDやADV Routerの情報からLSAをやり取りしている。

 

動作確認

Pingの疎通テスト

PC-1からPC-2

PC-1> ping 192.168.3.100
192.168.3.100 icmp_seq=1 timeout
84 bytes from 192.168.3.100 icmp_seq=2 ttl=62 time=78.133 ms
84 bytes from 192.168.3.100 icmp_seq=3 ttl=62 time=46.867 ms
84 bytes from 192.168.3.100 icmp_seq=4 ttl=62 time=46.660 ms
84 bytes from 192.168.3.100 icmp_seq=5 ttl=62 time=46.873 ms

 

 

PC-2からPC-1

PC-2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=46.833 ms
84 bytes from 192.168.1.100 icmp_seq=2 ttl=62 time=47.093 ms
84 bytes from 192.168.1.100 icmp_seq=3 ttl=62 time=46.906 ms
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=46.885 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=31.601 ms

 

異なるセグメントのPCがお互いに通信できることが確認できます。

トップへ戻る