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

网络实验八:用路由器实现跨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

R2:

同上:

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   r1
R2(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

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

六:给pc机配置ip和网关

给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

给pc31即图上的pc3

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

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值