利用packet tracer为交换机配置vlan:
技术原理:
Tag Vlan :是基于交换机端口的另外一种类型,主要用于跨交换机的相同VLAN内主机之间的直接访问,同时对于不同VLAN中的主机进行隔离。
实验步骤:
- 新建packet tracer 拓扑图
- 划分VLAN
- 将端口划分到对应的vlan中
- 设置Tag Vlan Trunk属性
- 进行测试
实验操作:
两台2960交换机,四台pc机,使用直连线进行连接;分别用两台交换机上的Pc机连接到交换机上相应端口,两台交换机使用24号端口相连;设置pc机的ip地址如图:
然后对switch0进行设置:
Switch>en
Switch#conf t #进入全局配置视图
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2 #划分两个VLAN 2,3
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#interface fa 0/1 #进入一号端口,一号端口连接的是pc0
Switch(config-if)#switchport access vlan 2 #将一号端口设置到vlan2
Switch(config-if)#exit
Switch(config)#int fa 0/2
Switch(config-if)#switchport access vlan 3 #二号端口设置到vlan3
Switch(config-if)#exit
Switch(config)#int fa 0/24
Switch(config-if)#sw #按下tab可以自动提示单词到下一行
Switch(config-if)#switchport mode trun
Switch(config-if)#switchport mode trunk #设置trunk
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up
Switch(config-if)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#show vlan #展示vlan配置
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23, Gig1/1, Gig1/2
2 VLAN0002 active Fa0/1
3 VLAN0003 active Fa0/2
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
--More--
按照同样的方式设置switch2
设置完成之后192.168.1.2和192.168.1.4是一个vlan下面的,另两个是在同一个VLAN下
最后对PC0进行命令行测试:
PC>ipconfig #查看当前ip
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::204:9AFF:FE6E:D97C
IP Address......................: 192.168.1.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.1
PC>ping 192.168.1.3 #虽然在同一个交换机下,但不在同一个网段内,所以不能通信;
Pinging 192.168.1.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.1.3:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
PC>ping 192.168.1.4
Pinging 192.168.1.4 with 32 bytes of data:
Reply from 192.168.1.4: bytes=32 time=1ms TTL=128
Reply from 192.168.1.4: bytes=32 time=0ms TTL=128
Reply from 192.168.1.4: bytes=32 time=1ms TTL=128
Reply from 192.168.1.4: bytes=32 time=8ms TTL=128
Ping statistics for 192.168.1.4:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 8ms, Average = 2ms
PC>
原文地址:https://www.cnblogs.com/thegarden/p/12425843.html
时间: 2024-10-29 09:07:09