实验7 用路由器实现不同VLAN间路由

更新时间:2023-09-29 08:20:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

实验7 用路由器实现不同VLAN间路由

【实验名称】 通过路由器的以太口实现VLAN间路由

【实验目的】 掌握如何通过路由器的以太口实现VLAN间路由。

【背景描述】 假设某企业有2个主要部门:销售部和技术部,已经实现了把他们划分到了不同的局域网上,但他们之间需要相互进行通信,进行相互通讯,现要使用路由器对不同vlan的流量进行路由来实现这一目标。

【实现功能】 每个vlan里接一根线出来接到路由器的以太网口上,在路由器上配置合适的IP地址,利用路由器的路由功能来实现不同网段vlan流量的通讯。

【实验设备】 S2126G(1台)、R1762或RSR10路由器(1台)

【实验拓扑】

F0/0

192.168.10.1

router

F0/1

192.168.20.1

PC1

F0/5

F0/6 F0/16

PC2

switch

F0/15

192.168.10.1xx 255.255.255.0 192.168.10.1

Vlan10 Vlan20

192.168.20.1xx 255.255.255.0 192.168.20.1

【实验步骤】

第一步:在交换机SwitchA上创建Vlan 10,并将0/1-8端口划分到Vlan 10中。 SwitchA # configure terminal !进入全局配置模式。 SwitchA(config)# vlan 10 !创建Vlan 10。

SwitchA(config-vlan)# name sales !将Vlan 10命名为sales。 SwitchA(config-vlan)#exit

SwitchA(config)#interface range fastethernet 0/1-8 !进入接口配置模式。 SwitchA(config-if)#switchport access vlan 10 !将0/1-8端口划分到Vlan 10。

验证测试:验证已创建了Vlan 10,并将0/1-8端口已划分到Vlan 10中。 SwitchA#show vlan id 10

VLAN Name Status Ports ---- -------------------------------- --------- -------------------------------

10 sales active Fa0/1, Fa0/2,Fa0/3, Fa0/4, Fa0/5, Fa0/6,Fa0/7, Fa0/8,

第二步:在交换机SwitchA上创建Vlan 20,并将0/9-16端口划分到Vlan 20中。 SwitchA(config)# vlan 20 !创建Vlan 20。

SwitchA(config-vlan)# name technical !将Vlan 20命名为technical。 SwitchA(config-vlan)#exit

SwitchA(config)#interface range fastethernet 0/9-16 !进入接口配置模式。 SwitchA(config-if)#switchport access vlan 20 !将0/15端口划分到Vlan 20。

验证测试:验证已创建了Vlan 20,并将0/9-16端口已划分到Vlan 20中。 SwitchA#show vlan id 20

VLAN Name Status Ports ---- -------------------------------- --------- -------------------------------

20 technical active Fa0/9, Fa0/10,Fa0/11, Fa0/12, Fa0/13 Fa0/14,Fa0/15, Fa0/16,

第三步:在路由器router上配置端口IP地址: Router >en 14 !进入特权模式。 Password: (打上star,此处不显示,照打就是) !输入特权密码 Router #configure ter !进入全局配置模式。 Router(config)#interface fastethernet 1/0 !进入接口配置模式。 Router(config-if) #ip address 192.168.10.1 255.255.255.0 !配置IP地址及子网掩码。 Router(config-if)#no shutdown !开启端口。 Router(config-if)#exit !退出端口配置模式 Router(config)#interface fastethernet 1/1 !进入端口配置模式 Router(config-if) #ip address 192.168.20.1 255.255.255.0 !配置IP地址及子网掩码。 Router(config-if)#no shutdown !开启端口。 Router(config-if)#exit !退出端口配置模式 Router(config)#

验证测试:验证路由器接口IP地址配置及路由表。 R1#show ip interface brief

Interface IP-Address(Pri) OK? Status FastEthernet 0/0 192.168.10.1/24 YES UP FastEthernet 0/1 192.168.20.1/24 YES UP

R1#show ip route

Codes: C - connected, S - static, R - RIP B - BGP 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, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default

Gateway of last resort is no set

C 192.168.10.0/24 is directly connected, FastEthernet 0/0 C 192.168.10.1/32 is local host.

C 192.168.20.0/24 is directly connected, FastEthernet 0/1 C 192.168.20.1/32 is local host.

第四步:配置两台PC机 PC1的测试网卡配置如下:

PC2的测试网卡配置如下:

第五步:验证PC1与PC2能互相通信。

C:\\Documents and Settings\\Administrator>ping 192.168.20.100 !在PC1的命令行方式下验证能Ping通PC2 。 Pinging 192.168.20.100 with 32 bytes of data:

Reply from 192.168.20.100: bytes=32 time<1ms TTL=128 Reply from 192.168.20.100: bytes=32 time<1ms TTL=128 Reply from 192.168.20.100: bytes=32 time<1ms TTL=128 Reply from 192.168.20.100: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.20.100:

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\\Administrator>ping 192.168.10.100 !在PC2的命令行方式下验证能Ping通PC1 。 Pinging 192.168.20.100 with 32 bytes of data:

Reply from 192.168.10.100: bytes=32 time<1ms TTL=128 Reply from 192.168.10.100: bytes=32 time<1ms TTL=128 Reply from 192.168.10.100: bytes=32 time<1ms TTL=128 Reply from 192.168.10.100: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.10.100:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 0ms, Average = 0ms

第六步:测试结果

通过路由器的路由,使得不同vlan的主机可以相互通讯。

【注意事项】

? 需要设置PC的网关(即为上游路由器接口的IP地址)

本文来源:https://www.bwwdw.com/article/x8id.html

Top