vlan间通信实验报告
- 格式:docx
- 大小:37.57 KB
- 文档页数:8
vlan间通信实验报告
实验目的:
本次实验旨在通过搭建虚拟局域网(VLAN)网络,掌握VLAN的基本原理和配置方法,以及学习如何在不同VLAN之间进行通信。
实验环境:
1.三台计算机:PC1、PC2、PC3
2.三个交换机:SW1、SW2、SW3
3.网线若干
4.路由器一台
实验过程:
1.配置交换机
首先需要将三个交换机进行基本配置。我们使用命令行方式进行配置。
(1)设置管理口IP地址和子网掩码
SW1(config)#interface vlan 1
SW1(config-if)#ip address 192.168.0.1 255.255.255.0
SW2(config)#interface vlan 1
SW2(config-if)#ip address 192.168.0.2 255.255.255.0
SW3(config)#interface vlan 1
SW3(config-if)#ip address 192.168.0.3 255.255.255.
(2)开启交换机端口连接状态检测功能
SW1(config)#spanning-tree portfast bpduguard default
SW2(config)#spanning-tree portfast bpduguard default
SW3(config)#spanning-tree portfast bpduguard default
(3)将端口划分到不同的VLAN中
在这里我们将PC1和PC2放置在VLAN10中,将PC3放置在VLAN20中。
SW1(config)#vlan 10
SW1(config-vlan)#name vlan10 SW1(config-vlan)#exit
SW1(config)#vlan 20
SW1(config-vlan)#name vlan20
SW1(config-vlan)#exit
SW2(config)#vlan 10
SW2(config-vlan)#name vlan10
SW2(config-vlan)#exit
SW2(config)#vlan 20
SW2(config-vlan)#name vlan20
SW2(config-vlan)#exit
SW3(config)#vlan 10
SW3(config-vlan)#name vlan10
SW3(config-vlan)#exit
SW3(config)#vlan 20
SW3(config-vlan)#name vlan20
SW3(config-vlan)#
(4)配置交换机端口
我们需要将PC1和PC2的接口连接到交换机的Fa0/1和Fa0/2端口,将PC3的接口连接到交换机的Fa0/3端口。
在这里,我们需要将Fa0/1和Fa0/2端口划分到VLAN10中,将Fa0/3端口划分到VLAN20中。
对于每个交换机,我们需要执行以下命令:
interface FastEthernet0/x
switchport mode access
switchport access vlan xx
其中x表示端口号,xx表示VLAN编号。
(5)配置路由器
为了实现不同VLAN之间的通信,我们需要在路由器上进行一些配置。
首先,我们需要为路由器的每个接口分配IP地址。在这里,我们使用192.168.10.1作为VLAN10的网关地址,并使用192.168.20.1作为VLAN20的网关地址。
Router(config)#interface FastEthernet0/0 Router(config-if)#ip address 192.168.10.1 255.255.255.0
Router(config-if)#no shutdown
Router(config)#interface FastEthernet0/1
Router(config-if)#ip address 192.168.20.1 255.255.255.0
Router(config-if)#no shutdown
然后,我们需要为路由器启用路由功能,并添加静态路由。
Router(config)#ip routing
Router(config)#ip route 192.168.x.x 255.255.255.x 192.168.y.y
其中,x表示源IP地址所在的VLAN编号,y表示目标IP地址所在的VLAN编号。
2.PC配置
我们需要为PC1、PC2和PC3分别配置IP地址和子网掩码。在这里,我们使用以下地址:
PC1:192.168.10.2/24
PC2:192.168.10.3/24
PC3:192,168,20,2/24
3.VLAN间通信测试
现在,我们已经完成了所有的配置工作。接下来,我们来测试不同VLAN之间的通信是否正常。
首先,在PC1上打开命令提示符窗口,并尝试ping PC2:
C:\>ping 192,168,10,3
如果通信正常,则会显示以下信息:
Reply from 192,168,10,3: bytes=32 time<1ms TTL=128
Reply from 192,168,10,3: bytes=32 time<1ms TTL=128
Reply from 192,168,10,3: bytes=32 time<1ms TTL=128
Reply from 192,168,10,3: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.10.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
然后,在PC1上尝试ping PC3:
C:\>ping 192.168.20.2
如果通信正常,则会显示以下信息:
Reply from 192.168.20.2: bytes=32 time<1ms TTL=128
Reply from 192.168.20.2: bytes=32 time<1ms TTL=128
Reply from 192.168.20.2: bytes=32 time<1ms TTL=128
Reply from 192.168.20.2: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.20.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
最后,在PC2上尝试ping PC3:
C:\>ping 192,168,20,2
如果通信正常,则会显示以下信息:
Reply from 192,168,20,2: bytes=32 time<1ms TTL=128
Reply from 192,168,20,2: bytes=32 time<1ms TTL=128
Reply from 192,168,20,2: bytes=32 time<1ms TTL=128
Reply from 192,168,20,2: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.20.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
结论:
通过以上测试,我们可以得出以下结论:
1.VLAN之间的通信需要通过路由器进行转发。
2.不同VLAN之间的通信需要配置静态路由。
3.在不同VLAN之间进行通信时,需要使用网关地址作为目标IP地址。