1
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Packet TracerでLANとLANを繋ぐ

Posted at

今回は前々回前回のLANを繋げて通信できるようにする。
以下の2つのLANを繋げる。
image.pngimage.png

配線

ルーターのポートが2つしか無かったので、SW1を破棄した。
以下の図のようにルーター同士をクロスケーブルで繋ぐ。
R1
IPアドレス:192.168.1.254
サブネットマスク:255.255.255.0
R2
IPアドレス:192.168.1.253
サブネットマスク:255.255.255.0
image.png

ルーティングの設定

現在の状態だとR1はR2のネットワーク(192.168.3.0/24)、R2はR1のネットワーク(192.168.2.0/24)を学習していない。
PC3からSV0にpingを飛ばすと、R2までは到達する。しかし、R2はPC3のネットワークを学習していないので、返信することができない。
image.png
そこで、OSPFを使って学習させる。

OSPFの設定

R1、R2にそれぞれOSPFを設定する。

R1のCLI
R1>en
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router ospf 1
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
R1(config-router)#end
R1#
R2のCLI
R2#
R2#conf t
R2(config)#router ospf 1
R2(config-router)#network 192.168.1.0 0.0.0.255 area 0
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0
R2(config-router)#end
R2#

ping実行で確認

つながらない・・・
image.png
R1,R2のルーティングを確認してみる。

R1のCLI
R1#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.2.254
  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
    192.168.1.254 0.0.0.0 area 0 --削除対象
    192.168.2.254 0.0.0.0 area 0 --削除対象
  Routing Information Sources:  
    Gateway         Distance      Last Update 
    192.168.2.254        110      00:21:58
  Distance: (default is 110)
R2のCLI
R2#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.2.254
  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 --削除対象
    192.168.1.254 0.0.0.0 area 0 --削除対象
    192.168.2.254 0.0.0.0 area 0 --削除対象
    192.168.3.0 0.0.0.255 area 0
  Routing Information Sources:  
    Gateway         Distance      Last Update 
    192.168.2.254        110      00:08:29
  Distance: (default is 110)

何度か登録し直したアドレスがそのまま残ってたので、削除。

R1のCLI
R1(config-router)#no network 192.168.1.254 0.0.0.0 area 0
R1(config-router)#no network 192.168.2.254 0.0.0.0 area 0
R2のCLI
R2(config-router)#no network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#no network 192.168.1.254 0.0.0.0 area 0
R2(config-router)#no network 192.168.2.254 0.0.0.0 area 0

それでもつながらず・・・
調査したら、R1もR2もルーターIDが「Router ID 192.168.2.254」で同じIDであることがわかった!
OSPFはルーターIDでルーター同士を認識する。つまり、これが原因かな。
R1,R2のルーターIDを変更する。

R1のCLI
R1>en
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1 --ルーターIDを設定
R1(config-router)#Reload or use "clear ip ospf process" command, for this to take effect
R1#reload --再起動 ※ルーターの設定は保存する
R2のCLI
R2>en
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2 --ルーターIDを設定
R2(config-router)#Reload or use "clear ip ospf process" command, for this to take effect
R2#reload --再起動 ※ルーターの設定は保存する

再度pingを飛ばす。

PC3からSV0へpingを3回飛ばす
--一回目は失敗。学習中かな〜
C:\>ping 192.168.3.1

Pinging 192.168.3.1 with 32 bytes of data:

Request timed out.
Reply from 192.168.2.254: Destination host unreachable.
Reply from 192.168.2.254: Destination host unreachable.
Reply from 192.168.2.254: Destination host unreachable.

Ping statistics for 192.168.3.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
--二回目は途中から成功!
C:\>ping 192.168.3.1

Pinging 192.168.3.1 with 32 bytes of data:

Request timed out.
Reply from 192.168.3.1: bytes=32 time<1ms TTL=126
Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
Reply from 192.168.3.1: bytes=32 time<1ms TTL=126

Ping statistics for 192.168.3.1:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
--三回目は問題なく成功!!
C:\>ping 192.168.3.1

Pinging 192.168.3.1 with 32 bytes of data:

Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
Reply from 192.168.3.1: bytes=32 time<1ms TTL=126
Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
Reply from 192.168.3.1: bytes=32 time<1ms TTL=126

Ping statistics for 192.168.3.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

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

ルーティングテーブルにOSPFで学習したIPアドレスが入っていることを確認!

R1のCLI
R1#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, E - EGP
       i - IS-IS, 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

     192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.1.0/24 is directly connected, GigabitEthernet0/0
L       192.168.1.254/32 is directly connected, 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で学習したIPアドレス
O    192.168.3.0/24 [110/2] via 192.168.1.253, 00:05:20, GigabitEthernet0/0
R2のCLI
R2#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, E - EGP
       i - IS-IS, 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

     192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.1.0/24 is directly connected, GigabitEthernet0/0
L       192.168.1.253/32 is directly connected, GigabitEthernet0/0
-- OSPFで学習したIPアドレス
O    192.168.2.0/24 [110/2] via 192.168.1.254, 00:08:20, GigabitEthernet0/0
     192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.3.0/24 is directly connected, GigabitEthernet0/1
L       192.168.3.254/32 is directly connected, GigabitEthernet0/1

終わりに

今回はOSPFを使っLANとLANを繋いだ。OSPFを勉強した当初はよくわからなかった。しかし、PacketTracerを使って、ネットワークを作成したことでOSPFの理解が深まった。
次回はLANをWAN(インターネット)に繋げようと思う!

1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?