![見出し画像](https://assets.st-note.com/production/uploads/images/103075924/rectangle_large_type_2_d2aa84e6c22a448e881cacefd9e34aee.png?width=1200)
【Cisco】 OSPFの設定
OSPFの概要
作業ログ
OSPFの有効化
有効化
Router> enable
Router# configure terminal
Router(config)# router ospf [process-id]
(Router(config-router)# router-id [router-id])
[process-id]
OSPFプロセスのインスタンスを識別する一意の番号で、1から65535の範囲の整数が使用されます。OSPFネットワーク全体で一貫している必要はない。[router-id]
OSPFネットワーク内で一意である必要がある32ビットの識別子で、IPv4アドレス形式(例:192.168.1.1)で設定されますが、実際のIPアドレスである必要はないが、ルータ内で利用可能なIPアドレスから選択されることが一般的。
IPアドレスが設定されていれば設定の必要はない。設定しなければループバックインターフェイス、物理インターフェイスの順番でIPアドレスが設定される。
ループバックインターフェイス
ネットワークデバイス(特にルータ)に存在する仮想インターフェイスです。物理的に存在しないインターフェイスで、ルータ自体に IP アドレスを割り当てる目的で使用される。
Router(config)# interface Loopback0
Router(config-if)# ip address 192.168.100.1 255.255.255.255
ループバックインターフェイスを OSPF に追加
Router(config)# router ospf 1
Router(config-router)# network 192.168.100.1 0.0.0.0 area 0
ネットワークセグメントの指定
OSPFが稼働するネットワークセグメントを特定のエリアに関連付け、OSPFがそのネットワークセグメント上でHelloパケットを送信し、隣接ルータとのネイバー関係を構築できる。
Router(config-router)# network [network-address] [wildcard-mask] area [area-id]
------------------------------------------------------
Exp : Router(config-router)# network 192.168.1.0 0.0.0.255 area 0
インターフェースの設定(オプション)
必要に応じて、各インターフェースに対してOSPFの設定もできる。
Router(config)# interface [interface-name]
Router(config-if)# ip ospf [process-id] area [area-id]
Router(config-if)# ip ospf network [network-type]
Router(config-if)# ip ospf priority [priority]
------------------------------------------------------
Exp
Router(config)# interface GigabitEthernet0/0
Router(config-if)# ip ospf 1 area 0
Router(config-if)# ip ospf network broadcast
Router(config-if)# ip ospf priority 100
パッシブインターフェイス
インターフェイス上でOSPFヘローパケットの送信が無効になる。主にLAN内のクライアントデバイスに接続されているインターフェイスや、ルーティングプロトコルを使用しないインターフェイスに適用。
Router(config)# router ospf 1
Router(config-router)# passive-interface GigabitEthernet0/1
OSPFの設定確認(特権モード)
ネイバーの確認
Router# show ip ospf neighbor
------------------------------------------------------
Neighbor ID Pri State Dead Time Address Interface
192.168.1.2 1 FULL/BDR 00:00:38 10.1.1.2 FastEthernet0/0
192.168.1.3 1 FULL/DR 00:00:32 10.1.1.3 FastEthernet0/0
Neighbor ID: 隣接ルーターの OSPF ルーター ID
Pri: OSPF 優先度 (DR/BDR 選出時に使用)
State: ネイバーとの関係状態 (FULL はデータベースが同期済みを意味する)
Dead Time: 隣接ルーターがダウンと判断されるまでの時間
Address: 隣接ルーターの IP アドレス
Interface: 隣接ルーターとの通信に使用されているインターフェース
LSDB 情報の確認
LSDB は、OSPF ルーターが他のルーターから受信したリンクステートアドバタイズメント (LSA) を格納しており、これを基に最短経路ツリー (SPF) を計算し、ルーティングテーブルを構築。
Router# show ip ospf database
------------------------------------------------------
OSPF Router with ID (192.168.1.1) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
192.168.1.1 192.168.1.1 1032 0x80000003 0x009F72 3
192.168.1.2 192.168.1.2 1141 0x80000003 0x009FA3 3
192.168.1.3 192.168.1.3 1056 0x80000003 0x009F74 3
Link ID: LSA の識別子 (ルーターリンク LSA の場合、ルーター ID)
ADV Router: LSA を生成したルーターのルーター ID
Age: LSA の年齢(秒)
Seq#: LSA のシーケンス番号(更新時に増加)
Checksum: LSA のチェックサム(整合性確認用)
Link count: ルーターリンク LSA の場合、リンクの数
ルーティングテーブルの確認
Router# show ip route ospf
------------------------------------------------------
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
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
Gateway of last resort is not set
O IA 192.168.3.0/24 [110/65] via 10.1.1.2, 00:02:32, FastEthernet0/0
OSPF によって学習されたルートが1つあり、192.168.3.0/24 ネットワークへの OSPF Inter Area ルートで、コスト 65 で 10.1.1.2 を経由して到達し、FastEthernet0/0 インターフェースを使用。
OSPF プロトコルの確認
ルーターで実行されているルーティングプロトコルと、それらのプロトコルに関連する設定情報を表示。
Router# show 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.1.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
10.
送信/受信の OSPF アップデートに対するフィルタリストは設定されていない。
OSPF ルーター ID は 192.168.1.1。
このルーターには1つのエリアがあり、そのエリアは通常エリアです。
最大パス数は 4。
このルーターが OSPF に参加するネットワークは、10.x.x.x
インターフェイスの確認
Router# show ip ospf interface
------------------------------------------------------
FastEthernet0/0 is up, line protocol is up
Internet Address 10.1.1.1/24, Area 0
Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 192.168.1.3, Interface Address 10.1.1.3
Backup Designated Router (ID) 192.168.1.1, Interface Address 10.1.1.1
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:05
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/1, 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
インターフェイスがアップし、ラインプロトコルがアップしている。
IPアドレスが10.1.1.1/24で、エリアIDが0。
OSPFプロセスIDが1、ルーターIDが192.168.1.1、ネットワークタイプがBROADCAST、コストが10。
送信遅延が1秒、インターフェイスの状態がBDR(バックアップ・デザイナテッド・ルータ)、優先度が1。
デザイナテッド・ルータのIDが192.168.1.3、インターフェイスアドレスが10.1.1.3。
バックアップ・デザイナテッド・ルータのIDが192.168.1.1、インターフェイスアドレスが10.1.1.1。
タイマー間隔が設定されており、Helloタイマーが10秒、デッドタイマーが40秒、ウェイトタイマーが40秒、再送タイマーが5秒。
Helloパケットの送信が5秒後に予定
マルチエリアOSPF
設定例
Router(config)# router ospf [process-id]
# ネットワークの指定とエリアの割り当て
Router(config-router)# network [network-address] [wildcard-mask] area [area-id]
Router(config-router)# network [network-address] [wildcard-mask] area [area-id]
確認例
OSPFインターフェイスの確認
Router# show ip ospf interface
------------------------------------------------------
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0
...
FastEthernet0/1 is up, line protocol is up
Internet Address 192.168.1.10/24, Area 1
...
FastEthernet1/0 is up, line protocol is up
Internet Address 192.168.1.100/24, Area 2
...
OSPFネイバーの確認
Router# show ip ospf neighbor
------------------------------------------------------
Neighbor ID Pri State Dead Time Address Interface
192.168.1.2 1 FULL/BDR 00:00:38 192.168.1.2 FastEthernet0/0
192.168.1.11 1 FULL/DR 00:00:32 192.168.1.11 FastEthernet0/1
192.168.1.101 1 FULL/DR 00:00:35 192.168.1.101 FastEthernet1/0
LSDB 情報の確認
Router# show ip ospf database
------------------------------------------------------
OSPF Router with ID (192.168.1.1) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
192.168.1.1 192.168.1.1 1032 0x80000003 0x009F72 3
...
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
192.168.1.10 192.168.1.10 1141 0x80000003 0x009FA3 3
...
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
192.168.1.100 192.168.1.100 1056 0x80000003 0x009F74 3
...
ルーティングテーブルの確認
Router# show ip route ospf
------------------------------------------------------
O IA 192.168.2.0/24 [110/65] via 192.168.1.2, 00:02:32, FastEthernet0/0
O IA 192.168.3.0/24 [110/65] via 192.168.1.11, 00:02:27, FastEthernet0/1
O IA 192.168.4.0/24 [110/65] via 192.168.1.101, 00:02:25, FastEthernet1/0
先頭の「O IA」が他のエリアからルート情報を伝えられたことを示している。
OSPFパラメータの変更
ルータプライオリティの変更
Router(config)# interface [interface-name]
Router(config-if)# ip ospf priority [priority]
------------------------------------------------------
EXP
Router(config)# interface FastEthernet0/0
Router(config-if)# ip ospf priority 100
設定確認
Router# show ip ospf neighbor
------------------------------------------------------
Neighbor ID Pri State Dead Time Address Interface
192.168.1.2 100 FULL/DR 00:00:39 10.1.1.2 FastEthernet0/0
192.168.1.3 50 FULL/BDR 00:00:33 10.1.1.3 FastEthernet0/0
この例では、インターフェイスFastEthernet0/0のルータプライオリティが200に設定
コストの変更
Router(config)# interface [interface-name]
Router(config-if)# ip ospf cost [cost]
------------------------------------------------------
EXP
Router(config)# interface FastEthernet0/0
Router(config-if)# ip ospf cost 10
設定確認
Router# show ip ospf interface FastEthernet0/0
------------------------------------------------------
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0
Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
...
帯域幅の変更
帯域幅は、インターフェイスの通信速度を表す値で、通常はキロビット/秒 (Kbps) 単位で表される。
Router(config)# interface [interface-name]
Router(config-if)# bandwidth [bandwidth]
------------------------------------------------------
EXP
Router(config)# interface FastEthernet0/0
Router(config-if)# bandwidth 1000
設定確認
Router# show interfaces FastEthernet0/0
------------------------------------------------------
FastEthernet0/0 is up, line protocol is up
Hardware is AmdFE, address is 0009.b7a2.2a10 (bia 0009.b7a2.2a10)
Internet address is 192.168.1.1/24
MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,
reliability 255/255, txload 1/255, rxload 1/255
...
インターフェイスFastEthernet0/0の帯域幅が10000 Kbitに設定
Helloインターバルの変更
Router(config)# interface [interface-name]
Router(config-if)# ip ospf hello-interval [hello-interval]
------------------------------------------------------
EXP
Router(config)# interface FastEthernet0/0
Router(config-if)# ip ospf hello-interval 5
設定確認
Router# show ip ospf interface FastEthernet0/0
------------------------------------------------------
FastEthernet0/0 is up, line protocol is up
Internet Address 10.1.1.1/24, Area 0
Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.1.1, Interface address 10.1.1.1
Backup Designated router (ID) 192.168.1.2, Interface address 10.1.1.2
Timer intervals configured, Hello 20, Dead 80, Wait 80, Retransmit 5
Hello due in 00:00:15
Helloインターバルが20秒に設定されている
MTUミスマッチの検出無効化
Router(config)# router ospf [process-id]
Router(config-router)# no ip ospf mtu-ignore
デフォルトルートの配布
Router(config)# router ospf [process-id]
Router(config-router)# default-information originate [always]
設定確認
Router# show ip route
------------------------------------------------------
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
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
Gateway of last resort is 10.1.1.2 to network 0.0.0.0
O*E2 0.0.0.0/0 [110/1] via 10.1.1.2, 00:00:42, FastEthernet0/0
デフォルトルート(0.0.0.0/0)が OSPF 経由で配布されている
いいなと思ったら応援しよう!
![Ken @ インフラエンジニア](https://assets.st-note.com/production/uploads/images/101132722/profile_a98a67947884ad459174e833f9563c07.jpg?width=600&crop=1:1,smart)