LoginSignup
0
0

More than 3 years have passed since last update.

GNS3でシンプルなNW構成を作ってみた。

Last updated at Posted at 2020-12-12

前提

CCNAの学習のため、毎日書籍やUdemyなどで学習している。でもエンジニアはやはり手を動かさないとダメだと思い、GNS3を使い始めた。職場のIOSを使って、とりあえず簡単なものから少しずつやっていく。

今回の構成

このとってもシンプルな構成でPC1からPC2へPingを飛ばせるようにする。
NW構成.png

まずは構成図にしたがってPC1, 2にIPアドレス割り当てる。
スクリーンショット 2020-12-12 071137.png

ちなみに、コマンドがわからないときには「?」を使うと、一覧表示してくれる。

PC1> ip ?
ip ARG ... [OPTION]
  Configure the current VPC's IP settings
    ARG ...:
    address [mask] [gateway]
    address [gateway] [mask]
                   Set the VPC's ip, default gateway ip and network mask
                   Default IPv4 mask is /24, IPv6 is /64. Example:
                   ip 10.1.1.70/26 10.1.1.65 set the VPC's ip to 10.1.1.70,
                   the gateway to 10.1.1.65, the netmask to 255.255.255.192.
                   In tap mode, the ip of the tapx is the maximum host ID
                   of the subnet. In the example above the tapx ip would be
                   10.1.1.126
                   mask may be written as /26, 26 or 255.255.255.192
    auto           Attempt to obtain IPv6 address, mask and gateway using SLAAC
    dhcp [OPTION]  Attempt to obtain IPv4 address, mask, gateway, DNS via DHCP
          -d         Show DHCP packet decode
          -r         Renew DHCP lease
          -x         Release DHCP lease
    dns ip         Set DNS server ip, delete if ip is '0'
    domain NAME    Set local domain name to NAME

これでIPアドレスの割り当て方が以下だとわかる。
ip [address] [mask] [gateway]

実際にやってみる。

PC1> ip 192.168.1.100 255.255.255.0 192.168.1.1
Checking for duplicate address...
PC1 : 192.168.1.100 255.255.255.0 gateway 192.168.1.1

同じことをPC2にも行う。

PC2> ip 192.168.3.100 255.255.255.0 192.168.3.1
Checking for duplicate address...
PC1 : 192.168.3.100 255.255.255.0 gateway 192.168.3.1

次に、RT1,2にIPアドレスを割り当てる。
スクリーンショット 2020-12-12 071213.png
まずはどちらのRTもPC1, PC2と隣接しているインターフェースから。
ここを設定すれば、ひとまずPC1-RT1のfa0/0とPC2-RT2のfa0/0の間でPingが飛ぶようになる。

RTへのIPアドレス設定コマンドは、
ip address [address] [netmask]
RT1から

R1(config)#int fa0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#end

ちゃんとIPアドレスが設定できているか確認。不要部分は長いため省略。

R1#sh ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.1.1     YES manual up                    up  

ここで疑問。
GNS3って、デフォルトでstatusはすべてupなのか?
no shutにしていないところもすべてupになっている。
自分でひとつひとつshutすべき?

Pingによる疎通確認
スクリーンショット 2020-12-12 072417.png

RT1にIPアドレス設定前

PC1> ping 192.168.1.1
host (192.168.1.1) not reachable

当然不達が返ってくる。not reachableなので、そもそも宛先まで届いていないということ。

IPアドレス設定後

PC1> ping 192.168.1.1
84 bytes from 192.168.1.1 icmp_seq=1 ttl=255 time=8.924 ms
84 bytes from 192.168.1.1 icmp_seq=2 ttl=255 time=7.481 ms
84 bytes from 192.168.1.1 icmp_seq=3 ttl=255 time=3.495 ms
84 bytes from 192.168.1.1 icmp_seq=4 ttl=255 time=5.486 ms
84 bytes from 192.168.1.1 icmp_seq=5 ttl=255 time=4.392 ms

ちゃんと届くようになる。PC2についても同様に設定してPingがOKか確認。

今度は逆側のインターフェースにもIPアドレスを設定
スクリーンショット 2020-12-12 073241.png

RT1

R1(config)#int fa0/1
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#end

この設定をすれば、PC1-RT1のfa0/1とPC2-RT2のfa0/1でPingが飛ばせるようになる。

Pingで実際に疎通確認。

PC1> ping 192.168.2.1
84 bytes from 192.168.2.1 icmp_seq=1 ttl=255 time=8.659 ms
84 bytes from 192.168.2.1 icmp_seq=2 ttl=255 time=11.804 ms
84 bytes from 192.168.2.1 icmp_seq=3 ttl=255 time=5.524 ms
84 bytes from 192.168.2.1 icmp_seq=4 ttl=255 time=8.445 ms
84 bytes from 192.168.2.1 icmp_seq=5 ttl=255 time=11.514 ms

ちゃんと返ってくる。RT2も同様に設定し、Pingが通ることを確認。

Ping疎通確認

PC2> ping 192.168.3.1
84 bytes from 192.168.3.1 icmp_seq=1 ttl=255 time=19.629 ms
84 bytes from 192.168.3.1 icmp_seq=2 ttl=255 time=5.478 ms
84 bytes from 192.168.3.1 icmp_seq=3 ttl=255 time=5.171 ms
84 bytes from 192.168.3.1 icmp_seq=4 ttl=255 time=9.942 ms
84 bytes from 192.168.3.1 icmp_seq=5 ttl=255 time=2.416 ms

PC2> ping 192.168.2.2
84 bytes from 192.168.2.2 icmp_seq=1 ttl=255 time=6.303 ms
84 bytes from 192.168.2.2 icmp_seq=2 ttl=255 time=7.194 ms
84 bytes from 192.168.2.2 icmp_seq=3 ttl=255 time=7.447 ms
84 bytes from 192.168.2.2 icmp_seq=4 ttl=255 time=2.520 ms
84 bytes from 192.168.2.2 icmp_seq=5 ttl=255 time=2.574 ms

そしたらRTのインターフェースの状態を見てみる。
各インターフェースのIPアドレスとup/downを確認し、ちゃんと設定が正しくできていることがわかる。

R2#sh ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.3.1     YES manual up                    up  
FastEthernet0/1            192.168.2.2     YES manual up                    up  

PC1からRT2のfa0/1にPingを飛ばしてみる。
スクリーンショット 2020-12-12 080853.png

PC1> ping 192.168.2.2
192.168.2.2 icmp_seq=1 timeout
192.168.2.2 icmp_seq=2 timeout
192.168.2.2 icmp_seq=3 timeout
192.168.2.2 icmp_seq=4 timeout
192.168.2.2 icmp_seq=5 timeout

Pingはタイムアウトになってしまう。
タイムアウトということは、RT2までPing自体は通っている。しかし、RT2はPC1がいるNWである、192.168.1.0と直接接続していないため、PingがPC1に戻ってこれない。もしRT2まで届かないのであれば、not reachableになるはず。

上記の事象は、PC2からRT1にPingを飛ばしても同じ。

各RTのルートテーブルを覗いてみる。

R1#sh ip route
Codes: 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

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, FastEthernet0/1
R2#sh ip route
Codes: 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

Gateway of last resort is not set

C    192.168.2.0/24 is directly connected, FastEthernet0/1
C    192.168.3.0/24 is directly connected, FastEthernet0/0

まだルーティングの設定を何もしていないので、直接接続のネットワークしかルーティング情報がない。つまり、RT1は192.168.3.0のNWを、RT2は192.168.1.0のNWを知らない状態。これでは当然PC1-PC2間でのPing疎通も無理。PC1からPC2にPingを届かせるにはルーティングの設定が必要なので、スタティックルートの設定をしてみる。(スタティックルーティング)。下記がそのコマンド。

(config)#ip route network mask ip-address | interface[distance][permanent]

まずPC1に設定する。
スクリーンショット 2020-12-12 214803.png

R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2

意味としては、192.168.3.0のNWに行きたいなら、192.168.2.2のインターフェースにいきますよー、ってくらい。これでまたRT1のルートテーブルを見てみると、

R1#sh ip route
Codes: 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

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, FastEthernet0/1
S    192.168.3.0/24 [1/0] via 192.168.2.2

最終行に192.168.3.0のNWへは、192.168.2.2を経由する!という情報が付け加えられた!!
ちみなにスタティックなのでS、AD値は[1/0]で1になっている。

これでまた一旦Ping。まだPC2で同様の設定をしていないため、timeoutになる想定。
これは先ほどと同様の理由。RT2は192.168.1.0をまだ知らないので、Pingを返せない。
実際にやってみると、

PC1> ping 192.168.3.100
192.168.3.100 icmp_seq=1 timeout
192.168.3.100 icmp_seq=2 timeout
192.168.3.100 icmp_seq=3 timeout
192.168.3.100 icmp_seq=4 timeout
192.168.3.100 icmp_seq=5 timeout

RT2でも同じくスタティックルートを設定してルートテーブルの確認。

R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
R2#sh ip route
Codes: 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

Gateway of last resort is not set

S    192.168.1.0/24 [1/0] via 192.168.2.1
C    192.168.2.0/24 is directly connected, FastEthernet0/1
C    192.168.3.0/24 is directly connected, FastEthernet0/0

これで下準備はすべて終了。PC1からPC2にPingが通るはず。
スクリーンショット 2020-12-12 215222.png

PC1> ping 192.168.3.100
192.168.3.100 icmp_seq=1 timeout
192.168.3.100 icmp_seq=2 timeout
84 bytes from 192.168.3.100 icmp_seq=3 ttl=62 time=42.623 ms
84 bytes from 192.168.3.100 icmp_seq=4 ttl=62 time=34.987 ms
84 bytes from 192.168.3.100 icmp_seq=5 ttl=62 time=33.360 ms

最初のtimeoutで一瞬焦るが、二回目以降は最初からちゃんと返ってくることを確認。

PC2からも一応やってみる。

PC2> ping 192.168.1.100
84 bytes from 192.168.1.100 icmp_seq=1 ttl=62 time=36.273 ms
84 bytes from 192.168.1.100 icmp_seq=2 ttl=62 time=34.802 ms
84 bytes from 192.168.1.100 icmp_seq=3 ttl=62 time=30.303 ms
84 bytes from 192.168.1.100 icmp_seq=4 ttl=62 time=41.515 ms
84 bytes from 192.168.1.100 icmp_seq=5 ttl=62 time=38.041 ms

それぞれ保存して終了。GNS3ではteraterm上でそれぞれ保存すればいいらしい。
PCならsave
RTならwr

PC1> save
Saving startup configuration to startup.vpc
.  done

R1#wr
Building configuration...
[OK]

PC2> save
Saving startup configuration to startup.vpc
.  done

R2#wr
Building configuration...
[OK]

一言

今回手を動かしてみて、シンプルな構成でもスタティックで設定していくとなかなか面倒だと実感。そうなると、やっぱりダイナミックルーティングでかなり作業量を減らせられそうで便利だね。
自分はインフラはクラウドから入ったので、いまの現場入るまでNWの知識ゼロ。どうしてもクラウドだと、ネットワーク回りって気にしないよなー。まぁ今後気にする必要があるのかわからないけど。

とりあえず今の現場でネットワークエンジニアである以上、最低限のNWの知識を身に着けていきたい。

次回はルータを一つ増やして、やってみる。

以上。

0
0
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
0
0