基于端口VLAN的交换机配置实验(不同vlan互通)

一、实验目的

1、理解虚拟LAN(VLAN)基本原理。
2、掌握一般交换机按端口划分VLAN的配置方法;
3.掌握Tag VLAN配置方法。

二、实验设备及软件

安装packet tracer软件的计算机一台。

三、实验方案

使用两台交换机,令不同vlan间的主机可以通信。

四、实验步骤

1.新建packet tracer拓扑图
在这里插入图片描述
2. 配置计算机的IP地址、子网掩码、网关、DNS。
3. 计算机的网关分别指向路由器的子接口。
4..配置路由器子接口ip地址。

五、实验结果及分析

为各个pc机配置IP地址:
在这里插入图片描述
在这里插入图片描述
创建VLAN10和VLAN20,并为两个VLAN配置IP地址与子网掩码:

Switch>enable
Switch#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface vlan 10
Switch(config-if)#ip address 192.168.1.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#interface vlan 20
Switch(config-if)#ip address 192.168.2.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#vlan 10
Switch(config-vlan)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
Switch(config-vlan)#name VLAN10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
Switch(config-vlan)#name VLAN20
Switch(config-vlan)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#show vlan br
Switch#show vlan brief

查看配置情况:
在这里插入图片描述
在switch0中,将pc0、pc1所连接的f0/1、f0/2分配到vlan10中,将pc2、pc3所连接的f0/3、f0/4分配到vlan20中:

Switch#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface fastEthernet 0/1
Switch(config-if)#switch mode access
Switch(config-if)#switch access vlan 10
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/2
Switch(config-if)#switch mode access
Switch(config-if)#switch access vlan 10
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/3
Switch(config-if)#switch mode access
Switch(config-if)#switch access vlan 20
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/4
Switch(config-if)#switch mode access
Switch(config-if)#switch access vlan 20
Switch(config-if)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#show vlan br
Switch#show vlan brief
Switch#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ip routing
Switch(config)#
Switch#
%SYS-5-CONFIG_I: Configured from console by console

在这里插入图片描述

测试在不同vlan下两端pc机连通情况:

pc0与poc1:
在这里插入图片描述
pc0与poc2:
在这里插入图片描述
pc0与poc3:
在这里插入图片描述
pc1与poc2:
在这里插入图片描述
pc1与poc3:
在这里插入图片描述

六、实验总结

   在不同VLAN下可以实现相互连通。
   两主机分别在不同的vlan中,并且也不在相同子网中,但是他们可以通信,这里我使用了一台交换机,两台交换机都配置串口并且他们放通的vlan.在交换机上我配置了vlan10 vlan20的ip地址,然后就算我再交换机上没有配置vlan的ip地址也可以使得这两台主机进行通信。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值