千家信息网

交换机实现vlan访问以及vlan间互访

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,1、交换机实现vlan访问对pc0设置:192.168.2.1 255.255.255.0对pc1设置:192.168.3.1 255.255.255.0对pc2设置:192.168.2.2 255.
千家信息网最后更新 2026年11月01日交换机实现vlan访问以及vlan间互访

1、交换机实现vlan访问

对pc0设置:192.168.2.1 255.255.255.0


对pc1设置:192.168.3.1 255.255.255.0


对pc2设置:192.168.2.2 255.255.255.0


对pc3设置:192.168.3.2 255.255.255.0


对s0设置:

vlan 10

vlan 20

进入int f0/2

switchport mode access

switchport access vlan 10


进入int f0/3

switchport mode access

switchport access vlan 20


进入int f0/1

switchport mode trunk


对s1设置:

vlan 10

vlan 20


进入int f0/2

switchport mode access

switchport access vlan 10


进入int f0/3

switchport mode access

switchport access vlan 20


进入int f0/1

switchport mode trunk



从192.168.2.1 ping 192.168.2.2 可ping通,实现不同交换机的同vlan访问。



2、实现不同vlan间访问,小型网络采取添加路由器的方式(单臂路由)


对pc0设置:192.168.2.10 255.255.255.0 192.168.2.1


对pc1设置:192.168.3.10 255.255.255.0 192.168.3.1


对s0,int f0/4

switchport mode trunk


对router0,增加2个逻辑子接口,分别为期配置trunk和 ip ,如下:

int f0/0

no shut //一定要启用


int f0/0.10

encap dot1q 10

ip add 192.168.2.1 255.255.255.0

exit


int f0/0.20

encap dot1q 20

ip add 192.168.3.1 255.255.255.0

exit


从pc0,192.168.2.10 ping 192.168.3.10 ,可ping通,实现不同vlan间的互相访问。


注意:对于大型网络来说,一半不建议采用路由器,多采用三层交换机。原因为路由器Router 0 到s0之间的链路容易成为瓶颈和终端。

附件:http://down.51cto.com/data/2366457
0