连线规则:交换机之间应该使用交叉线(一端采用T568A标准,另一端采用T568B标准),交换机与主机之间应该使用直通线(两端采用T568B或T568A的标准)。
网线类型 | 常见应用 |
---|---|
直通网线 | 交换机和路由器连接;交换机和服务器连接;集线器和服务器连接 |
交叉网线 | 交换机和交换机连接;交换机和集线器连接;集线器和集线器连接;路由器和路由器连接;路由器和个人电脑连接 |
实验目的
VLAN的主要作用有两点,一是提高网络安全性,阻止未经授权的VLAN访问,二是提高网络传输效率,将广播隔离在子网之内。
PC ip地址配置
其它:略
SW0配置
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2 //如果不存在,则创建VLAN2
Switch(config-vlan)#name fd //将VLAN2命名为fd
Switch(config-vlan)#exit
Switch(config)#vlan 3 //创建VLAN3
Switch(config-vlan)#name IT //将VLAN3命名为IT
Switch(config-vlan)#exit
Switch(config)#int f0/2 //端口2
Switch(config-if)#switchport access vlan 2 //将端口2加入vlan2
Switch(config-if)#int f0/3 //端口3
Switch(config-if)#switchport access vlan 2 //将端口3加入vlan2
Switch(config)#int f0/4 //端口4
Switch(config-if)#switchport access vlan 3 //将端口4加入vlan3
Switch(config)#int f0/24
Switch(config-if)#switchport mode trunk //24端口设置为trunk
Switch(config-if)#end
Switch#show vlan //查看vlan接口信息
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, 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
Fa0/24, Gig0/1, Gig0/2
2 fd active Fa0/2, Fa0/3
3 IT active Fa0/4
4 VLAN0004 active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
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
4 enet 100004 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
Remote SPAN VLANs
------------------------------------------------------------------------------
Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------
SW1配置
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2 //创建VLAN2
Switch(config-vlan)#name fd //VLAN命名为fd
Switch(config-vlan)#vlan 3 //创建VLAN3
Switch(config-vlan)#name IT //VLAN命名为IT
Switch(config-vlan)#exit
Switch(config)#int f0/2 //端口2
Switch(config-if)#switchport access vlan 2 //将端口2加入vlan2
Switch(config-if)#int f0/3
Switch(config-if)#switchport access vlan 2 //将端口3加入vlan2
Switch(config-if)#int f0/4
Switch(config-if)#switchport access vlan 3 //将端口4加入vlan3
Switch(config)#int f0/24
Switch(config-if)#switchport mode trunk //24端口设置为trunk
Switch(config-if)#end
Switch#show vlan //查看vlan接口信息
%SYS-5-CONFIG_I: Configured from console by console
Switch#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, 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
Fa0/24, Gig0/1, Gig0/2
2 fd active Fa0/2, Fa0/3
3 IT active Fa0/4
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
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
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
Remote SPAN VLANs
------------------------------------------------------------------------------
Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------
实验验证
1.PC0 ping通 PC1
2.PC1 ping通 PC2 、PC5
3.PC3 ping通 PC7
在trunk上移除VLAN3的流量,使得SW0和SW1之间的VLAN3不能通信
注:在sw0和sw1同样操作命令
Switch# conf t
Switch(config)#int f0/24
Switch(config-if)#switchport trunk allowed vlan remove 3
Switch(config-if)#end
Switch#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Fa0/24 on 802.1q trunking 1
Port Vlans allowed on trunk
Fa0/24 1-2,4-1005
Port Vlans allowed and active in management domain
Fa0/24 1,2 //valn3已不再trunk的allowed列表
Port Vlans in spanning tree forwarding state and not pruned
Fa0/24 none
实验验证
1.PC3 ping不通 PC7
疑惑点
1、在还未建立sw0和sw1的trunk前,sw0和sw1默认的vlan1之间的pc可以ping通?
原因是 f0/24接口在默认的vlan1中。