网络实验八:用路由器实现跨vlan通信
一:网络拓扑图如下:
详细的介绍前几次实验都已详细的说明啦,由于时间的关系,这次就简单明了的说明重点:
二:首先对交换机S1,S2进行配置即vlan的划分
s1:
Switch>enable Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2
VLAN 2 added:
Name:VLAN0002
Switch(config)#interface fastethernet 0/2 Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config)#interface fastethernet 0/3 Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config)#interface fastethernet 0/1 Switch(config-if)#switchport access vlan 2
由于端口0/1默认情况下是属于vlan1,为了能通信,也需要划分到vlan2中。s2:同上
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 3
VLAN 3 added:
Name:VLAN0003
Switch(config)#interface fastethernet 0/2
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
Switch(config)#interface fastethernet 0/3
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
Switch(config)#interface fastethernet 0/1
Switch(config-if)#switchport access vlan 3
三:对路由器进行配置使路由器之间能通信
R1
Press Enter to Start
Router>
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1 R1(config)#interface serial 0/0 R1(config-if)#ip address 172.16.2.1 255.255.255.0
R1(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Serial0/0, changed state to up
%LINK-3-UPDOWN: Interface Serial0/0, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
R1(config-if)#clock rate 64000
%LINK-3-UPDOWN: Interface Serial0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1(config-if)#exit
同上:
Press Enter to Start
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#interface serial 0/0
R2(config-if)#ip address 172.16.2.2 255.255.255.0
R2(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R2(config-if)#exit
R2(config)#exit
测试如下:有r2 ping r1R2(config-if)#exit
R2(config)#exit
R2#ping 172.16.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
r1
R1(config-if)#exit
R1(config)#ip route 172.16.3.0 255.255.255.0 172.16.2.2
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.1
r1
R1(config)#interface ethernet 0/0
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
R1(config-if)#
r2
R2(config)#interface ethernet 0/0
R2(config-if)#ip address 172.16.3.1 255.255.255.0
R2(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
给pc21即图上的pc1
C:>ipconfig /ip 172.16.1.2 255.255.255.0 C:>ipconfig /dg 172.16.1.1
C:>ping 172.16.3.2
Pinging 172.16.3.2 with 32 bytes of data:
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Ping statistics for 172.16.3.2: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 172.16.3.3
Pinging 172.16.3.3 with 32 bytes of data:
Reply from 172.16.3.3: bytes=32 time=60ms TTL=241
Reply from 172.16.3.3: bytes=32 time=60ms TTL=241
Reply from 172.16.3.3: bytes=32 time=60ms TTL=241
Reply from 172.16.3.3: bytes=32 time=60ms TTL=241
Reply from 172.16.3.3: bytes=32 time=60ms TTL=241
Ping statistics for 172.16.3.3: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ipconfig /ip 172.16.3.2 255.255.255.0
C:>ipconfig /dg 172.16.3.1
C:>ping 172.16.1.2
Pinging 172.16.1.2 with 32 bytes of data:
Reply from 172.16.1.2: bytes=32 time=60ms TTL=241
Reply from 172.16.1.2: bytes=32 time=60ms TTL=241
Reply from 172.16.1.2: bytes=32 time=60ms TTL=241
Reply from 172.16.1.2: bytes=32 time=60ms TTL=241
Reply from 172.16.1.2: bytes=32 time=60ms TTL=241
Ping statistics for 172.16.1.2: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>ping 172.16.1.3
Pinging 172.16.1.3 with 32 bytes of data:
Reply from 172.16.1.3: bytes=32 time=60ms TTL=241
Reply from 172.16.1.3: bytes=32 time=60ms TTL=241
Reply from 172.16.1.3: bytes=32 time=60ms TTL=241
Reply from 172.16.1.3: bytes=32 time=60ms TTL=241
Reply from 172.16.1.3: bytes=32 time=60ms TTL=241
Ping statistics for 172.16.1.3: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms