网络实验八(路由器实现跨vlan通信)

来源:互联网 发布:ubuntu 16.04 下载jdk 编辑:程序博客网 时间:2024/06/03 15:59

网络实验八:用路由器实现跨vlan通信

一:网络拓扑图如下:


详细的介绍前几次实验都已详细的说明啦,由于时间的关系,这次就简单明了的说明重点:

二:首先对交换机S1,S2进行配置即vlan的划分

s1:

Switch>enableSwitch#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 2VLAN 2 added:    Name:VLAN0002Switch(config)#interface fastethernet 0/2Switch(config-if)#switchport access vlan 2Switch(config-if)#exitSwitch(config)#interface fastethernet 0/3Switch(config-if)#switchport access vlan 2Switch(config-if)#exitSwitch(config)#interface fastethernet 0/1Switch(config-if)#switchport access vlan 2
由于端口0/1默认情况下是属于vlan1,为了能通信,也需要划分到vlan2中。

s2:同上

Switch>enableSwitch#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.Switch(config)#vlan 3VLAN 3 added:    Name:VLAN0003Switch(config)#interface fastethernet 0/2Switch(config-if)#switchport access vlan 3Switch(config-if)#exitSwitch(config)#interface fastethernet 0/3Switch(config-if)#switchport access vlan 3Switch(config-if)#exitSwitch(config)#interface fastethernet 0/1Switch(config-if)#switchport access vlan 3


三:对路由器进行配置使路由器之间能通信

R1

Press Enter to StartRouter>Router>enable Router#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.Router(config)#hostname R1R1(config)#interface serial 0/0R1(config-if)#ip address 172.16.2.1 255.255.255.0R1(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 downR1(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 upR1(config-if)#exit

R2:

同上:

Press Enter to StartRouter>enableRouter#configure terminalEnter configuration commands, one per line.  End with CNTL/Z.Router(config)#hostname R2R2(config)#interface serial 0/0R2(config-if)#ip address 172.16.2.2 255.255.255.0R2(config-if)#no shutdown%LINK-3-UPDOWN: Interface Serial0/0, changed state to upR2(config-if)#exitR2(config)#exit
测试如下:有r2  ping   r1
R2(config-if)#exitR2(config)#exitR2#ping 172.16.2.1Type 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)#exitR1(config)#ip route 172.16.3.0 255.255.255.0 172.16.2.2

r2

R2#configure terminalEnter 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/0R1(config-if)#ip address 172.16.1.1 255.255.255.0R1(config-if)#no shutdown%LINK-3-UPDOWN: Interface Ethernet0/0, changed state to upR1(config-if)#


r2

R2(config)#interface ethernet 0/0R2(config-if)#ip address 172.16.3.1 255.255.255.0R2(config-if)#no shutdown%LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up

六:给pc机配置ip和网关

给pc21即图上的pc1

C:>ipconfig /ip 172.16.1.2 255.255.255.0C:>ipconfig /dg 172.16.1.1C:>ping 172.16.3.2Pinging 172.16.3.2 with 32 bytes of data:Reply from 172.16.3.2: bytes=32 time=60ms TTL=241Reply from 172.16.3.2: bytes=32 time=60ms TTL=241Reply from 172.16.3.2: bytes=32 time=60ms TTL=241Reply from 172.16.3.2: bytes=32 time=60ms TTL=241Reply from 172.16.3.2: bytes=32 time=60ms TTL=241Ping 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 =  55msC:>ping 172.16.3.3Pinging 172.16.3.3 with 32 bytes of data:Reply from 172.16.3.3: bytes=32 time=60ms TTL=241Reply from 172.16.3.3: bytes=32 time=60ms TTL=241Reply from 172.16.3.3: bytes=32 time=60ms TTL=241Reply from 172.16.3.3: bytes=32 time=60ms TTL=241Reply from 172.16.3.3: bytes=32 time=60ms TTL=241Ping 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

给pc31即图上的pc3

C:>ipconfig /ip 172.16.3.2 255.255.255.0C:>ipconfig /dg 172.16.3.1C:>ping 172.16.1.2Pinging 172.16.1.2 with 32 bytes of data:Reply from 172.16.1.2: bytes=32 time=60ms TTL=241Reply from 172.16.1.2: bytes=32 time=60ms TTL=241Reply from 172.16.1.2: bytes=32 time=60ms TTL=241Reply from 172.16.1.2: bytes=32 time=60ms TTL=241Reply from 172.16.1.2: bytes=32 time=60ms TTL=241Ping 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 =  55msC:>ping 172.16.1.3Pinging 172.16.1.3 with 32 bytes of data:Reply from 172.16.1.3: bytes=32 time=60ms TTL=241Reply from 172.16.1.3: bytes=32 time=60ms TTL=241Reply from 172.16.1.3: bytes=32 time=60ms TTL=241Reply from 172.16.1.3: bytes=32 time=60ms TTL=241Reply from 172.16.1.3: bytes=32 time=60ms TTL=241Ping 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

由于时间关系:上面就只是列啦实验结果和过程,其实全部的内容都是前面几次实验的。这次就是一个综合的实验,。