前提
CCNAの学習のため、毎日書籍やUdemyなどで学習している。でもエンジニアはやはり手を動かさないとダメだと思い、GNS3を使い始めた。職場のIOSを使って、とりあえず簡単なものから少しずつやっていく。
これまでやったこと
[GNS3でシンプルなNW構成を作ってみた。]
(https://qiita.com/mavs4133/items/f64d8be585f6f367c324)
今回の構成
これでPC1からPC2へPingを飛ばせるようにする。
今回もGNS3を使って手を動かしていく。
まずはPC1、2にそれぞれIPアドレスを割り当て、デフォルトルートを設定。
これで各PCから出ていく方向を決める。
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> ip 192.168.4.100 255.255.255.0 192.168.4.1
Checking for duplicate address...
PC2 : 192.168.4.100 255.255.255.0 gateway 192.168.4.1
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
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
R3(config)#int fa0/1
R3(config-if)#ip address 192.168.3.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#end
R3(config)#int fa0/1
R3(config-if)#ip address 192.168.4.1 255.255.255.0
R3(config-if)#no shut
R3(config-if)#end
これでPC1はRT1の両インターフェースに、PC2はRT3の両インターフェースにPingが飛ばせるようになる。
PC1> ping 192.168.1.1
84 bytes from 192.168.1.1 icmp_seq=1 ttl=255 time=9.644 ms
84 bytes from 192.168.1.1 icmp_seq=2 ttl=255 time=2.411 ms
84 bytes from 192.168.1.1 icmp_seq=3 ttl=255 time=5.442 ms
84 bytes from 192.168.1.1 icmp_seq=4 ttl=255 time=8.424 ms
84 bytes from 192.168.1.1 icmp_seq=5 ttl=255 time=2.391 ms
PC1> ping 192.168.2.1
84 bytes from 192.168.2.1 icmp_seq=1 ttl=255 time=11.461 ms
84 bytes from 192.168.2.1 icmp_seq=2 ttl=255 time=7.635 ms
84 bytes from 192.168.2.1 icmp_seq=3 ttl=255 time=8.361 ms
84 bytes from 192.168.2.1 icmp_seq=4 ttl=255 time=6.474 ms
84 bytes from 192.168.2.1 icmp_seq=5 ttl=255 time=8.466 ms
PC2> ping 192.168.4.1
84 bytes from 192.168.4.1 icmp_seq=1 ttl=255 time=9.296 ms
84 bytes from 192.168.4.1 icmp_seq=2 ttl=255 time=4.611 ms
84 bytes from 192.168.4.1 icmp_seq=3 ttl=255 time=11.588 ms
84 bytes from 192.168.4.1 icmp_seq=4 ttl=255 time=10.471 ms
84 bytes from 192.168.4.1 icmp_seq=5 ttl=255 time=6.800 ms
PC2> ping 192.168.3.2
84 bytes from 192.168.3.2 icmp_seq=1 ttl=255 time=10.399 ms
84 bytes from 192.168.3.2 icmp_seq=2 ttl=255 time=10.549 ms
84 bytes from 192.168.3.2 icmp_seq=3 ttl=255 time=3.645 ms
84 bytes from 192.168.3.2 icmp_seq=4 ttl=255 time=5.564 ms
84 bytes from 192.168.3.2 icmp_seq=5 ttl=255 time=8.413 ms
RT2にもIPアドレスを設定してPingを実行。
当然まだこの状態ではPingはPC1からRT2も、PC2からRT2も通らない。
タイムアウトなので、RT2までは届いているが、PC1のNWは戻ってこれていないということ。これはPC2からRT2も同様。
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
まずはPC1のほうから設定。RT2にスタティックでRT2に192.168.1.0のNWを設定してみる。
これでRT2のfa0/0、192.168.2.0のNWまでは通るはず。
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
コマンドの意味としては、
「このNWに届けたいなら、このインターフェースに送って!」
そしてルーティングテーブルを覗いてみる。
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/0
C 192.168.3.0/24 is directly connected, FastEthernet0/1
ちゃんと今回も「スタティックでAD値1、192.168.2.1経由で192.168.1.0のNWに行く!!」という経路情報が足されているのがわかる。
この状態でPingを打てばちゃんと返ってくる。
PC1> ping 192.168.2.2
84 bytes from 192.168.2.2 icmp_seq=1 ttl=254 time=30.517 ms
84 bytes from 192.168.2.2 icmp_seq=2 ttl=254 time=32.566 ms
84 bytes from 192.168.2.2 icmp_seq=3 ttl=254 time=27.439 ms
84 bytes from 192.168.2.2 icmp_seq=4 ttl=254 time=30.612 ms
84 bytes from 192.168.2.2 icmp_seq=5 ttl=254 time=32.666 ms
しかし、PC1からfa0/1、192.168.3.0のNWにPingを飛ばすと、
以下のようにhost unreachableになる。
PC1> ping 192.168.3.1
*192.168.1.1 icmp_seq=1 ttl=255 time=4.438 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=2 ttl=255 time=2.603 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=3 ttl=255 time=4.630 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=4 ttl=255 time=8.570 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=5 ttl=255 time=6.523 ms (ICMP type:3, code:1, Destination host unreachable)
type3はdestination unreachableで、code1はhost unreachableの意味。
おそらくRT1が192.168.3.0のNWを知らないため。これをまたスタティックで設定すると、通るはず。まずはルーティングテーブルの確認。たしかに192.168.3.0のNWを知らない。
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
スタティックでルート情報を設定してする。
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R1(config)#end
R1#ip
*Mar 1 00:30:40.475: %SYS-5-CONFIG_I: Configured from console by console
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
これでPingが通って、PC1からRT2のfa0/1までの疎通確認ができた。
PC1> ping 192.168.3.1
84 bytes from 192.168.3.1 icmp_seq=1 ttl=254 time=22.468 ms
84 bytes from 192.168.3.1 icmp_seq=2 ttl=254 time=32.556 ms
84 bytes from 192.168.3.1 icmp_seq=3 ttl=254 time=28.505 ms
84 bytes from 192.168.3.1 icmp_seq=4 ttl=254 time=29.495 ms
84 bytes from 192.168.3.1 icmp_seq=5 ttl=254 time=22.923 ms
次にPC1からRT3のfa0/1にPingするが、timeoutになる。
PC1> ping 192.168.3.2
192.168.3.2 icmp_seq=1 timeout
192.168.3.2 icmp_seq=2 timeout
192.168.3.2 icmp_seq=3 timeout
192.168.3.2 icmp_seq=4 timeout
192.168.3.2 icmp_seq=5 timeout
先ほどスタティックで192.168.3.0のNWを設定したため、このNWにPingは送れるが、どうやら返ってこれないらしい。RT3の持つルーティングテーブルが192.168.1.0と192.168.2.0のNWを知らないためのようなので設定してみる。
R3#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.4.0/24 is directly connected, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/1
↑↑上のような状態だとPingが戻ってこれないため、
↓↓下のようにコマンドでスタティックに設定。
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#
R3(config)#
R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1
R3(config)#end
R3#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.4.0/24 is directly connected, FastEthernet0/0
S 192.168.1.0/24 [1/0] via 192.168.3.1
S 192.168.2.0/24 [1/0] via 192.168.3.1
C 192.168.3.0/24 is directly connected, FastEthernet0/1```
そうすると、fa0/1からはちゃんとPing返ってくる。
PC1> ping 192.168.3.2
84 bytes from 192.168.3.2 icmp_seq=1 ttl=253 time=53.342 ms
84 bytes from 192.168.3.2 icmp_seq=2 ttl=253 time=49.589 ms
84 bytes from 192.168.3.2 icmp_seq=3 ttl=253 time=44.485 ms
84 bytes from 192.168.3.2 icmp_seq=4 ttl=253 time=36.538 ms
84 bytes from 192.168.3.2 icmp_seq=5 ttl=253 time=47.608 ms
次にRT3のfa0/0にPingを飛ばすと、host unreachableになってしまう。
PC1> ping 192.168.4.1
*192.168.1.1 icmp_seq=1 ttl=255 time=13.526 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=2 ttl=255 time=10.567 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=3 ttl=255 time=4.684 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=4 ttl=255 time=2.464 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.1.1 icmp_seq=5 ttl=255 time=9.575 ms (ICMP type:3, code:1, Destination host unreachable)
これもRT1、2が192.168.4.0のNWを知らないから。両方にこのNWをスタティックで設定すれば、通るはず。
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
R1(config)#end
R1#sh
*Mar 1 00:50:03.599: %SYS-5-CONFIG_I: Configured from console by console
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
S 192.168.4.0/24 [1/0] via 192.168.2.2
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
R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2
R2(config)#end
R2#s
*Mar 1 00:49:36.023: %SYS-5-CONFIG_I: Configured from console by console
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.4.0/24 [1/0] via 192.168.3.2
S 192.168.1.0/24 [1/0] via 192.168.2.1
C 192.168.2.0/24 is directly connected, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/1
これでちゃんとPC1から192.168.4.1までPingが通ることを確認。
PC1> ping 192.168.4.1
84 bytes from 192.168.4.1 icmp_seq=1 ttl=253 time=52.142 ms
84 bytes from 192.168.4.1 icmp_seq=2 ttl=253 time=52.288 ms
84 bytes from 192.168.4.1 icmp_seq=3 ttl=253 time=51.450 ms
84 bytes from 192.168.4.1 icmp_seq=4 ttl=253 time=35.121 ms
84 bytes from 192.168.4.1 icmp_seq=5 ttl=253 time=46.270 ms
これですべてのRTにすべてのNWが設定されているので、やっとPC1-PC2間でPingが飛ばせるようになるはず!
PC1> ping 192.168.4.100
84 bytes from 192.168.4.100 icmp_seq=1 ttl=61 time=58.224 ms
84 bytes from 192.168.4.100 icmp_seq=2 ttl=61 time=65.351 ms
84 bytes from 192.168.4.100 icmp_seq=3 ttl=61 time=59.886 ms
84 bytes from 192.168.4.100 icmp_seq=4 ttl=61 time=57.293 ms
84 bytes from 192.168.4.100 icmp_seq=5 ttl=61 time=65.335 ms
なった!!疎通確認終了!!!
というわけで、だんだんやっとIPアドレスやスタティックルートの設定コマンドが手に慣れてきた。やはりコマンドを打った分だけできるようになっていく感じはする。どんどんやって行こう。
次はルータ4つの構成でやってみる。たぶん一気に難易度が上がりそう。。。
以上。
追記
どうやらRTは必ずしもすべてのNWを知る必要はないよう。
例えば、PC1から192.168.4.0のNWにPingを飛ばすのに、192.168.3.0は知らなくてもOK。
スタティックで設定しすぎたかも。。。