次のような、3つのネットワークを2台のルータで接続したネットワー クを構築する実験を行います。
但し、これを実現するのに、ルータ一台の他、スイッチ一台、パソコン一台だ けを使用します。 そのため、実験1同様にVLAN、 Virtual Machine を活用します。
なお、今回はスイッチでもルーティングを行います。 ポートと VLAN 間でルーティングします。
まず、ルータ、スイッチ、PC を接続します。 これは実験1と同様です。 ルータの FastEthernet0/0 をスイッチの FastEthernet0/6 に、 ルータの FastEthernet0/1 をスイッチの FastEthernet0/7 につなぎます。 PC をスイッチの FastEthernet0/8 につなぎます。 なお、アドレスを設定せずにルータ、スイッチを輪になるように接続すると、 802.1d のプロトコルにより、輪ができている状態を解消するために、一部のポート が停止します。 これは、アドレスを振りなおした後でポートを起動すれば使用できるようにな りますので、問題ありません。
また、ルータやスイッチを接続するためのシリアルケーブルを PC に接続しま す。 PC では Tera Term などの端末ソフトを起動します。
設定はポート 6はルータポート、 ポート 7 を VLAN5 とします。 そして、ポート 8 は dot1q 指定の trunc に指定し、VLAN4 と VLAN 5 を通 します。 ルータはポート 6 と VLAN4 に接続し、それぞれ IP アドレスとして、 172.20.5.2/24 と 172.20.3.1/24 を設定します。
configure terminal
vlan 4
exit
vlan 5
exit
ip routing
interface fastethernet0/6
no switchport
ip address 172.20.5.2 255.255.255.0
no shutdown
exit
interface fastethernet0/7
switchport mode access
switchport access vlan 5
exit
interface fastethernet0/8
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 4,5
exit
interface vlan 4
ip address 172.20.3.1 255.255.255.0
no shutdown
end
スイッチの設定の確認は show vlan、show interfaces FastEthernet0/8 switchport などで確認します。
catalyst3560#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Gi0/1
3 VLAN0003 active
4 VLAN0004 active
5 VLAN0005 active Fa0/7
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
4 enet 100004 1500 - - - - - 0 0
5 enet 100005 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0
Remote SPAN VLANs
------------------------------------------------------------------------------
Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------
catalyst3560#show interfaces FastEthernet 0/6
FastEthernet0/6 is up, line protocol is up (connected)
Hardware is Fast Ethernet, address is 0025.83c7.fc41 (bia 0025.83c7.fc41)
Internet address is 172.20.5.2/24
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 100Mb/s, media type is 10/100BaseTX
input flow-control is off, output flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:06, output 00:00:08, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
157 packets input, 17239 bytes, 0 no buffer
Received 28 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 24 multicast, 0 pause input
0 input packets with dribble condition detected
1558 packets output, 151322 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier, 0 PAUSE output
0 output buffer failures, 0 output buffers swapped out
catalyst3560#show interfaces vlan 4
Vlan4 is up, line protocol is up
Hardware is EtherSVI, address is 0025.83c7.fc42 (bia 0025.83c7.fc42)
Internet address is 172.20.3.1/24
MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:01, output 00:04:16, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
69 packets input, 6651 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
2 packets output, 128 bytes, 0 underruns
0 output errors, 0 interface resets
0 output buffer failures, 0 output buffers swapped out
catalyst3560#show interfaces FastEthernet 0/8 switchport Name: Fa0/8 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 3 (VLAN0003) Administrative Native VLAN tagging: enabled Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk Native VLAN tagging: enabled Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: 4,5 Pruning VLANs Enabled: 2-1001 Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disabled Appliance trust: none
catalyst3560#show 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
172.20.0.0/24 is subnetted, 2 subnets
C 172.20.3.0 is directly connected, Vlan4
C 172.20.5.0 is directly connected, FastEthernet0/6
IP アドレスは変わりますが、実験1とほとんど同じです。
configure terminal
interface FastEthernet0/0
ip address 172.20.5.1 255.255.255.0
no shutdown
exit
interface FastEthernet0/1
ip address 172.20.2.1 255.255.255.0
no shutdown
end
ここで、 no shutdown を指定しないと、接続時に停止したポートが有効にな りませんので注意が必要です。
設定を確認するには、 show ip route を打つことで、自動的にルー ティングテーブルに接続したポートが自動的に追加されていることが確認でき ます。
yourname#show 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
172.20.0.0/24 is subnetted, 2 subnets
C 172.20.2.0 is directly connected, FastEthernet0/1
C 172.20.5.0 is directly connected, FastEthernet0/0
このような設定では、 VPC1 から VPC2 へ ping を打つと、返事が返って きません。これは何故でしょう?
C:\Documents and Settings\sakamoto>ping 172.20.2.3
Pinging 172.20.2.3 with 32 bytes of data:
Reply from 172.20.3.1: Destination host unreachable.
Reply from 172.20.3.1: Destination host unreachable.
Reply from 172.20.3.1: Destination host unreachable.
Reply from 172.20.3.1: Destination host unreachable.
Ping statistics for 172.20.2.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\Documents and Settings\sakamoto>
これは双方のルータにおいて、ネットワーク情報が不十分なため、不明なネッ トワークを相手のルータに託せるか判断ができないためです。 Wire Shark で確かめてみましょう。
するとスイッチ側のルータに届きます。 スイッチ側のルータのルーティングケーブルには次のエントリがあります。
catalyst3560#show 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
172.20.0.0/24 is subnetted, 2 subnets
C 172.20.3.0 is directly connected, Vlan4
C 172.20.5.0 is directly connected, FastEthernet0/6
catalyst3560#
このため、ルーティングテーブルに必要な情報を書き込む必要があります。
とりあえず、スイッチ側のルータのルーティングテーブルにスタテイックに情 報を書いてみます。
configure terminal
ip route 172.20.2.0 255.255.255.0 172.20.5.1
end
catalyst3560#show 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
172.20.0.0/24 is subnetted, 3 subnets
S 172.20.2.0 [1/0] via 172.20.5.1
C 172.20.3.0 is directly connected, Vlan4
C 172.20.5.0 is directly connected, FastEthernet0/6
このようにし、 VPC1 から
C:\Documents and Settings\sakamoto>ping 172.20.2.3
Pinging 172.20.2.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 172.20.2.3:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
C:\Documents and Settings\sakamoto>
するとスイッチ側のルータに届きます。 スイッチ側のルータのルーティングケーブルには次のエントリがあります。
172.20.0.0/24 is subnetted, 3 subnets
S 172.20.2.0 [1/0] via 172.20.5.1
C 172.20.3.0 is directly connected, Vlan4
C 172.20.5.0 is directly connected, FastEthernet0/6
1841 ルータ のルーティングテーブルは次の様になっています。
172.20.0.0/24 is subnetted, 2 subnets
C 172.20.2.0 is directly connected, FastEthernet0/1
C 172.20.5.0 is directly connected, FastEthernet0/0
従って、 172.20.3.3 宛のパケットの転送先は計算できず、 VPC2 宛に ICMP Unreachable が 送られます。
VPC2 に ICMP Unreachable が届きますが、それ以上何も起きません。 そのため、 VPC1 は何もメッセージを受けとりません。
VPC1 はタイムアウトを表示します。
1841 ルータにスタティックルートを設定します。
configure terminal
ip route 172.20.3.0 255.255.255.0 172.20.5.2
end
すると、初めて VPC1 の
この時の各ルータのルーティングテーブルは次の様になっています。
172.20.0.0/24 is subnetted, 3 subnets
C 172.20.2.0 is directly connected, FastEthernet0/1
S 172.20.3.0 [1/0] via 172.20.5.2
C 172.20.5.0 is directly connected, FastEthernet0/0
172.20.0.0/24 is subnetted, 3 subnets
S 172.20.2.0 [1/0] via 172.20.5.1
C 172.20.3.0 is directly connected, Vlan4
C 172.20.5.0 is directly connected, FastEthernet0/6
S はスタティックルートを表しています。
次に、各ルータのスタティックルートを削除して、 RIP プロトコルでルーティ ングテーブルを計算させましょう。
configure terminal
no ip route 172.20.3.0 255.255.255.0
router rip
network 172.20.0.0
end
configure terminal
no ip route 172.20.2.0 255.255.255.0
router rip
network 172.20.0.0
end
このときのルーティングテーブルは次の様になっています。
172.20.0.0/24 is subnetted, 3 subnets
C 172.20.2.0 is directly connected, FastEthernet0/1
R 172.20.3.0 [120/1] via 172.20.5.2, 00:00:19, FastEthernet0/0
C 172.20.5.0 is directly connected, FastEthernet0/0
172.20.0.0/24 is subnetted, 3 subnets
R 172.20.2.0 [120/1] via 172.20.5.1, 00:00:05, FastEthernet0/6
C 172.20.3.0 is directly connected, Vlan4
C 172.20.5.0 is directly connected, FastEthernet0/6
また、 Wire Shark で取得できる RIP のパケットは次の様になっています。
次に、RIP を止めて OSPF でルーティングテーブルを計算させましょう。
configure terminal
no router rip
router ospf 109
network 172.20.0.0 255.255.0.0 area 0
end
configure terminal
no router rip
router ospf 109
network 172.20.0.0 255.255.0.0 area 0
end
このときのルーティングテーブルは次の様になっています。
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
172.20.0.0/24 is subnetted, 3 subnets
C 172.20.2.0 is directly connected, FastEthernet0/1
O 172.20.3.0 [110/2] via 172.20.5.2, 00:14:41, FastEthernet0/0
C 172.20.5.0 is directly connected, FastEthernet0/0
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
172.20.0.0/24 is subnetted, 3 subnets
O 172.20.2.0 [110/2] via 172.20.5.1, 00:13:20, FastEthernet0/6
C 172.20.3.0 is directly connected, Vlan4
C 172.20.5.0 is directly connected, FastEthernet0/6
また、 Wire Shark で取得できる OSPF のパケットは次の様になっています。
ルータが2台以上あると、相互に独立に接続しているネットワークの情報を知 らなければなりません。 手動で行うのはスタティックルーティングで、これは各情報をじかに入力する ものです。 一方ダイナミックルーティングとして RIP や OSPF があります。 これらは、原理が大きく異なりますが、設定方法はかなり似ています。 但し、RIP はサブネットマスクを伝搬しませんので、その設定もありません。
また、 ping に関して、行きの経路が無い場合は ICMP unreachable を受ける ためエラーを検知できますが、帰りの経路が無い場合はエラーを受けることが できずタイムアウトします。