Cisco機器でのOSPFの基本設定方法を説明します。
OSPFの基礎知識や動作原理、エリアの考え方などについては下記を参照してください。
目次
ネットワーク構成
下記のネットワーク構成を例にOSPFの基本設定について説明します。
OSPFの基本設定
STEP
OSPFの有効化(OSPFプロセスの起動)
router ospf [Process ID]
設定例
Router1(config)#router ospf 1
Router2(config)#router ospf 1
STEP
ルーターIDの設定
router-id [A.B.C.D]
設定例
Router1(config-router)#router-id 100.100.100.254
Router2(config-router)#router-id 100.100.100.253
STEP
OSPFを有効化するインターフェースの指定
network [A.B.C.D] [wildcard-mask] area [Area-ID]
設定例
Router1(config-router)#network 172.16.1.0 0.0.0.255 area 0
Router1(config-router)#network 192.168.1.0 0.0.0.255 area 0
Router2(config-router)#network 172.16.1.0 0.0.0.255 area 0
Router2(config-router)#network 192.168.2.0 0.0.0.255 area 0
ワイルドカードマスクについては、下記を参照してください。
OSPFの設定確認・ステータス確認
OSPFの設定やステータスは、下記のコマンドで確認できます。
show run | section router ospf
show ip ospf
show ip ospf neighbor
show ip ospf interface
show ip ospf database
show ip route
(show ip route ospf)
設定確認 – show run | section router ospf
OSPFの設定を確認するには下記のコマンドを実行します。
show run | section router ospf
コマンドの出力結果 – show run | section router ospf
Router1#show run | section router ospf
router ospf 1
router-id 100.100.100.254
network 172.16.1.0 0.0.0.255 area 0
network 192.168.1.0 0.0.0.255 area 0
Router2#show run | section router ospf
router ospf 1
router-id 100.100.100.253
network 172.16.1.0 0.0.0.255 area 0
network 192.168.2.0 0.0.0.255 area 0
設定したコンフィグが表示されます。
OSPF起動状況の確認 – show ip ospf
OSPFの起動状況を確認するには下記のコマンドを実行します。
show ip ospf
コマンドの出力結果 – show ip ospf
Router1#show ip ospf
Routing Process "ospf 1" with ID 100.100.100.254
Start time: 04:17:00.372, Time elapsed: 00:51:26.302
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Supports NSSA (compatible with RFC 3101)
Supports Database Exchange Summary List Optimization (RFC 5243)
Event-log enabled, Maximum number of events: 1000, Mode: cyclic
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
Incremental-SPF disabled
Minimum LSA interval 5 secs
Minimum LSA arrival 1000 msecs
LSA group pacing timer 240 secs
Interface flood pacing timer 33 msecs
Retransmission pacing timer 66 msecs
EXCHANGE/LOADING adjacency limit: initial 300, process maximum 300
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
Number of areas transit capable is 0
External flood list length 0
IETF NSF helper support enabled
Cisco NSF helper support enabled
Reference bandwidth unit is 100 mbps
Area BACKBONE(0)
Number of interfaces in this area is 2
Area has no authentication
SPF algorithm last executed 00:30:19.869 ago
SPF algorithm executed 4 times
Area ranges are
Number of LSA 3. Checksum Sum 0x01258D
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
Router2#show ip ospf
Routing Process "ospf 1" with ID 100.100.100.253
Start time: 04:16:25.436, Time elapsed: 00:51:25.094
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Supports NSSA (compatible with RFC 3101)
Supports Database Exchange Summary List Optimization (RFC 5243)
Event-log enabled, Maximum number of events: 1000, Mode: cyclic
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
Incremental-SPF disabled
Minimum LSA interval 5 secs
Minimum LSA arrival 1000 msecs
LSA group pacing timer 240 secs
Interface flood pacing timer 33 msecs
Retransmission pacing timer 66 msecs
EXCHANGE/LOADING adjacency limit: initial 300, process maximum 300
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
Number of areas transit capable is 0
External flood list length 0
IETF NSF helper support enabled
Cisco NSF helper support enabled
Reference bandwidth unit is 100 mbps
Area BACKBONE(0)
Number of interfaces in this area is 2
Area has no authentication
SPF algorithm last executed 00:30:17.619 ago
SPF algorithm executed 4 times
Area ranges are
Number of LSA 3. Checksum Sum 0x01258D
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
主に以下のステータスが確認できます。
- プロセスID
- ルーターID
- OSPFの起動時刻 / 起動時間
OSPFネイバー確立状況の確認 – show ip ospf neighbor
OSPFのネイバー確立状況を確認するには下記のコマンドを実行します。
show ip ospf neighbor
コマンドの出力結果 – show ip ospf neighbor
Router1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
100.100.100.253 1 FULL/BDR 00:00:36 172.16.1.2 GigabitEthernet0/0
Router2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
100.100.100.254 1 FULL/DR 00:00:33 172.16.1.1 GigabitEthernet0/0
主に以下のステータスが確認できます。
- ネイバーID
- ネイバーの確立状況(2WAY/EXSTART/EXCHANGE/FULL)
- ネイバールーターの役割(DR /BDR/DROTHER)
- ネイバーダウンが検知されるまでの残り時間
OSPFインターフェースの状況確認 – show ip ospf interface
OSPFを有効にしたインターフェースのステータスを確認するには下記のコマンドを実行します。
show ip ospf interface
コマンドの出力結果 – show ip ospf interface
Router1#show ip ospf interface
GigabitEthernet0/1 is up, line protocol is up
Internet Address 192.168.1.254/24, Area 0, Attached via Network Statement
Process ID 1, Router ID 100.100.100.254, Network Type BROADCAST, Cost: 1
Topology-MTID Cost Disabled Shutdown Topology Name
0 1 no no Base
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 100.100.100.254, Interface address 192.168.1.254
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:03
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/2/2, flood queue length 0
Next 0x0(0)/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)
GigabitEthernet0/0 is up, line protocol is up
Internet Address 172.16.1.1/24, Area 0, Attached via Network Statement
Process ID 1, Router ID 100.100.100.254, Network Type BROADCAST, Cost: 1
Topology-MTID Cost Disabled Shutdown Topology Name
0 1 no no Base
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 100.100.100.254, Interface address 172.16.1.1
Backup Designated router (ID) 100.100.100.253, Interface address 172.16.1.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:06
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/1/1, flood queue length 0
Next 0x0(0)/0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 2
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 100.100.100.253 (Backup Designated Router)
Suppress hello for 0 neighbor(s)
Router2#show ip ospf interface
GigabitEthernet0/1 is up, line protocol is up
Internet Address 192.168.2.254/24, Area 0, Attached via Network Statement
Process ID 1, Router ID 100.100.100.253, Network Type BROADCAST, Cost: 1
Topology-MTID Cost Disabled Shutdown Topology Name
0 1 no no Base
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 100.100.100.253, Interface address 192.168.2.254
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:06
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/2/2, flood queue length 0
Next 0x0(0)/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)
GigabitEthernet0/0 is up, line protocol is up
Internet Address 172.16.1.2/24, Area 0, Attached via Network Statement
Process ID 1, Router ID 100.100.100.253, Network Type BROADCAST, Cost: 1
Topology-MTID Cost Disabled Shutdown Topology Name
0 1 no no Base
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 100.100.100.254, Interface address 172.16.1.1
Backup Designated router (ID) 100.100.100.253, Interface address 172.16.1.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:08
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/1/1, flood queue length 0
Next 0x0(0)/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 100.100.100.254 (Designated Router)
Suppress hello for 0 neighbor(s)
主に以下のステータスが確認できます。
- プロセスID
- ルーターID
- ネットワークタイプ
- DR/BDRの情報
OSPFデータベースの状況確認 – show ip ospf database
OSPFの設定を確認するには下記のコマンドを実行します。
show ip ospf database
コマンドの出力結果 – show ip ospf database
Router1#show ip ospf database
OSPF Router with ID (100.100.100.254) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
100.100.100.253 100.100.100.253 1950 0x80000005 0x002AB3 2
100.100.100.254 100.100.100.254 1949 0x80000005 0x00F6E6 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
172.16.1.1 100.100.100.254 1963 0x80000001 0x0003F4
Router2#show ip ospf database
OSPF Router with ID (100.100.100.253) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
100.100.100.253 100.100.100.253 1947 0x80000005 0x002AB3 2
100.100.100.254 100.100.100.254 1948 0x80000005 0x00F6E6 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
172.16.1.1 100.100.100.254 1962 0x80000001 0x0003F4
LSAタイプ毎のリンクステートデータベース情報が確認できます。
ルーティングテーブルの確認 – show ip route
ルーティングテーブルの内容を確認するには下記のコマンドを実行します。
show ip route
コマンドの出力結果 – show ip route
Router1#show ip route
Codes: L - local, C - connected, S - static, 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
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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.1.0/24 is directly connected, GigabitEthernet0/0
L 172.16.1.1/32 is directly connected, GigabitEthernet0/0
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/1
L 192.168.1.254/32 is directly connected, GigabitEthernet0/1
O 192.168.2.0/24 [110/2] via 172.16.1.2, 00:32:45, GigabitEthernet0/0
Router2#show ip route
Codes: L - local, C - connected, S - static, 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
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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.1.0/24 is directly connected, GigabitEthernet0/0
L 172.16.1.2/32 is directly connected, GigabitEthernet0/0
O 192.168.1.0/24 [110/2] via 172.16.1.1, 00:32:44, GigabitEthernet0/0
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet0/1
L 192.168.2.254/32 is directly connected, GigabitEthernet0/1
ルーティングテーブルの内容が確認できます。OSPFで相手側のLANセグメントへの経路情報を学習していることがわかります。
ルーティングテーブルの確認(OSPFで学習) – show ip route ospf
OSPFで学習したルーティングテーブルの内容を確認するには下記のコマンドを実行します。
show ip route ospf
コマンドの出力結果 – show ip route ospf
Router1#show ip route ospf
Codes: L - local, C - connected, S - static, 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
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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
O 192.168.2.0/24 [110/2] via 172.16.1.2, 00:32:54, GigabitEthernet0/0
Router2#show ip route ospf
Codes: L - local, C - connected, S - static, 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
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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
O 192.168.1.0/24 [110/2] via 172.16.1.1, 00:32:53, GigabitEthernet0/0
OSPFで学習したルーティングテーブルの内容が確認できます。OSPFで相手側のLANセグメントへの経路情報を学習していることがわかります。
以上で、「OSPFの基本設定 – Cisco機器での設定方法」の説明は完了です!