Cisco機器でOSPFをインターフェース単位で設定する方法を説明します。
networkコマンドで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を有効化
interface [Interface Name]
ip ospf [Process ID] area [Area ID]
設定例
Router1(config)#interface GigabitEthernet0/0
Router1(config-if)#ip ospf 1 area 0
Router1(config)#interface GigabitEthernet0/1
Router1(config-if)#ip ospf 1 area 0
Router2(config)#interface GigabitEthernet0/0
Router2(config-if)#ip ospf 1 area 0
Router2(config)#interface GigabitEthernet0/1
Router2(config-if)#ip ospf 1 area 0
OSPFの設定確認・ステータス確認
OSPFの設定やステータスは、下記のコマンドで確認できます。
show run
show ip ospf
show ip ospf neighbor
show ip ospf interface
show ip ospf database
show ip route
(show ip route ospf)
設定確認 – show run
OSPFの設定を確認するには下記のコマンドを実行します。
show run
コマンドの出力結果 – show run | section router ospf
Router1#show run
interface GigabitEthernet0/0
ip ospf 1 area 0
interface GigabitEthernet0/1
ip ospf 1 area 0
router ospf 1
router-id 100.100.100.254
Router2#show run
interface GigabitEthernet0/0
ip ospf 1 area 0
interface GigabitEthernet0/1
ip ospf 1 area 0
router ospf 1
router-id 100.100.100.253
設定したコンフィグが表示されます。
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: 00:00:20.822, Time elapsed: 1w5d
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:17:33.756 ago
SPF algorithm executed 13 times
Area ranges are
Number of LSA 3. Checksum Sum 0x021CEC
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: 00:00:20.740, Time elapsed: 1w5d
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:17:29.277 ago
SPF algorithm executed 13 times
Area ranges are
Number of LSA 3. Checksum Sum 0x021CEC
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:35 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:31 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/0 is up, line protocol is up
Internet Address 172.16.1.1/24, Area 0, Attached via Interface Enable
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
Enabled by interface config, including secondary ip addresses
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:04
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 0, maximum is 2
Last flood scan time is 0 msec, maximum is 1 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)
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
Enabled by interface config, including secondary ip addresses
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:04
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)
Router2#show ip ospf interface
GigabitEthernet0/0 is up, line protocol is up
Internet Address 172.16.1.2/24, Area 0, Attached via Interface Enable
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
Enabled by interface config, including secondary ip addresses
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 1 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)
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
Enabled by interface config, including secondary ip addresses
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:09
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)
主に以下のステータスが確認できます。
- プロセス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 1212 0x8000022D 0x00FAB8 2
100.100.100.254 100.100.100.254 1211 0x8000022E 0x00C5EC 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
172.16.1.1 100.100.100.254 1922 0x80000054 0x005C48
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 1206 0x8000022D 0x00FAB8 2
100.100.100.254 100.100.100.254 1207 0x8000022E 0x00C5EC 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
172.16.1.1 100.100.100.254 1918 0x80000054 0x005C48
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:30, 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:15, 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:33:16, 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:33:01, GigabitEthernet0/0
OSPFで学習したルーティングテーブルの内容が確認できます。OSPFで相手側のLANセグメントへの経路情報を学習していることがわかります。
以上で、「OSPFの基本設定(インターフェース単位の設定)」の説明は完了です!