Vlan管理地址:172.16.0.1 255.255.255.0 F0/0端口用于管理来用

划分四个Vlan 学生(students)Vlan100,教师(teacher)Vlan30,财务(marketing)Vlan40,市场部(accounting)Vlan10,然后将相应的端口划分到其Vlan下面
sw#sh run

interface VLAN1
ip address 172.16.0.1 255.255.255.0
no ip directed-broadcast
no ip route-cache

line con 0
exec-timeout 0 0
logging synchronous
transport input none
stopbits 1
line vty 0 4
login
line vty 5 15
login
!
end

Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/2
Switch(config-if)#swit
Switch(config-if)#switchport mode
Switch(config-if)#switchport mode ac
Switch(config-if)#switchport mode access
Switch(config-if)#swit
Switch(config-if)#switchport a
Switch(config-if)#switchport access vlan 10
Switch(config-if)#int f0/3
Switch(config-if)#swit
Switch(config-if)#switchport mode a
Switch(config-if)#switchport mode access
Switch(config-if)#sw
Switch(config-if)#switchport a
Switch(config-if)#switchport access lan 10
                                    ^
% Invalid input detected at '^' marker.

Switch(config-if)#exit
Switch(config)#end
Switch#show v
00:20:32: %SYS-5-CONFIG_I: Configured from console by console
Switch#show vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, 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, Fa0/24, Gi0/1,
                                                Gi0/2
10   Markeing                         active    Fa0/2
30   Teacher                          active
40   Accouting                        active
100 Students                         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
10   enet 100010     1500 -      -      -        -    -        0      0
30   enet 100030     1500 -      -      -        -    -        0      0

Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/3
Switch(config-if)#s
Switch(config-if)#sw
Switch(config-if)#switchport mode a
Switch(config-if)#switchport mode access
Switch(config-if)#sw
Switch(config-if)#switchport a
Switch(config-if)#switchport access vlan 10
Switch(config-if)#int f0/4
Switch(config-if)#swit
Switch(config-if)#switchport mode access
Switch(config-if)#swit
Switch(config-if)#switchport access vlan 10
Switch(config-if)#int f0/5
Switch(config-if)#swit
Switch(config-if)#switchport mode a
Switch(config-if)#switchport mode access
Switch(config-if)#sw
Switch(config-if)#switchport access vlan 10
Switch(config-if)#int f0/6
Switch(config-if)#swit
Switch(config-if)#switchport mode access
Switch(config-if)#sw
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#end
Switch#show
00:23:04: %SYS-5-CONFIG_I: Configured from console by console
Switch#show vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, 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, Gi0/1,
                                                Gi0/2
10   Markeing                         active    Fa0/2, Fa0/3, Fa0/4, Fa0/5,
                                                Fa0/6
30   Teacher                          active
40   Accouting                        active
100 Students                         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
10   enet 100010     1500 -      -      -        -    -        0      0
30   enet 100030     1500 -      -      -        -    -        0      0

Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface range f0/7 - 8
                         ^
% Invalid input detected at '^' marker.

Switch(config)#interface range f0/7 -8
                         ^
% Invalid input detected at '^' marker.

Switch(config)#int f0/7
Switch(config-if)#switch
Switch(config-if)#switchport mode access
Switch(config-if)#sw
Switch(config-if)#switchport access vlan 30
Switch(config-if)#int f0/8
Switch(config-if)#switch
Switch(config-if)#switchport mode access
Switch(config-if)#swit
Switch(config-if)#switchport acces
Switch(config-if)#switchport access vlan 30
Switch(config-if)#int f0/9
Switch(config-if)#swit
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 40
Switch(config-if)#end
Switch#show
00:26:28: %SYS-5-CONFIG_I: Configured from console by console
Switch#show vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, 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,
                                                Gi0/1, Gi0/2
10   Markeing                         active    Fa0/2, Fa0/3, Fa0/4, Fa0/5,
                                                Fa0/6
30   Teacher                          active    Fa0/7, Fa0/8
40   Accouting                        active    Fa0/9
100 Students                         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
10   enet 100010     1500 -      -      -        -    -        0      0
30   enet 100030     1500 -      -      -        -    -        0      0
40   enet 100040     1500 -      -      -        -    -        0      0

Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int rang f0/10, f12
                   ^
% Invalid input detected at '^' marker.

Switch(config)#int rang f0/10, f0/12
                   ^
% Invalid input detected at '^' marker.

Switch(config)#end
Switch#show vlan
00:27:55: %SYS-5-CONFIG_I: Configured from console by console
Switch#int rang f0/10, f0/12
       ^
% Invalid input detected at '^' marker.

Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/10
Switch(config-if)#swi
Switch(config-if)#switchport mode access
Switch(config-if)#sw
Switch(config-if)#switchport access vlan 100
Switch(config-if)#int f0/11
Switch(config-if)#sw
Switch(config-if)#switchport mode access
Switch(config-if)#sw
Switch(config-if)#switchport access vlan 100
Switch(config-if)#int f0/12
Switch(config-if)#swit
Switch(config-if)#switchport acc
Switch(config-if)#switchport access vlan 100]
                                            ^
% Invalid input detected at '^' marker.

Switch(config-if)#switchport access vlan 100
Switch(config-if)#end
Switch#show vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/13, Fa0/14, Fa0/15,
                                                Fa0/16, Fa0/17, Fa0/18, Fa0/19,
                                                Fa0/20, Fa0/21, Fa0/22, Fa0/23,
                                                Fa0/24, Gi0/1, Gi0/2
10   Markeing                         active    Fa0/2, Fa0/3, F
00:29:33: %SYS-5-CONFIG_I: Configured from console by consolea0/4, Fa0/5,
                                                Fa0/6
30   Teacher                          active    Fa0/7, Fa0/8
40   Accouting                        active    Fa0/9
100 Students                         active    Fa0/10, Fa0/11, Fa0/12
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
10   enet 100010     1500 -      -      -        -    -        0      0
30   enet 100030     1500 -      -      -        -    -        0      0
40   enet 100040     1500 -      -      -        -    -        0      0
100 enet 100100     1500 -      -      -        -    -        0      0
--More--
划分Vlan成功之后,来将需要的端口划分到相应的vlan下。例如:
将F0/11划分到VLAN 40 下
sw#conf t
sw#int f0/11
sw#switchport mode access
Sw#switchport access vlan 40

思考题:2900交换机支持的最大Vlan数目是多少?3500 了?
3500支持29个。。

思考题:能否使用一条命令将一批端口一次性划分到一个Vlan下面?
conf t
int range f0/1 - 10

 


试验二和试验三


观察2900和3500等交换机的启动过程,IOS的版本,以及它有多少接口等。。。
配置管理IP地址和默认网关
SW#conf t
SW#interface vlan 1
ip add 192.168.0.1 255.255.255.0
ip default-gateway 172.16.0.1

清除交换机残留配置,erase startup-config
删除划分的Vlan       del vlan.dat

 

 

sw1为 rack62sw1
sw2为 rack62sw2

                   Trunk配置

设备:3500交换机   Ios:Version 12.0(5)WC17,


第一步:在SW1上配置VTP
SW1#vlan da
SW1(vlan)#vtp domain norvel
Changing VTP domain name from NULL to norvel
SW1(vlan)#vtp server
Device mode already VTP SERVER.
SW1(vlan)#exit
APPLY completed.
Exiting....
SW1#

第二步:在SW2上配置VTP

SW2#vlan da
SW2(vlan)#vtp domain norvel
Changing VTP domain name from cisco to norvel
SW2(vlan)#vtp client
Setting device to VTP CLIENT mode.
SW2(vlan)#exit
In CLIENT state, no apply attempted.
Exiting....
SW2#

第三步:在SW1上配置Trunk中继端口

SW1wangwanli#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1wangwanli(config)#int f0/23
SW1wangwanli(config-if)#sw
SW1wangwanli(config-if)#switchport mode trunk
配置f0/23交换机端口为trunk
SW1wangwanli(config-if)#swi
SW1wangwanli(config-if)#switchport trunk en
SW1wangwanli(config-if)#switchport trunk encapsulation dot
SW1wangwanli(config-if)#switchport trunk encapsulation dot1q
配置中继的封装类型为8021.Q
SW1wangwanli(config-if)#switchport trunk allowed vlan all
配置交换机通过中继传输的vlan为all

 

第四步在SW2上配置trunk中继端口

SW2wangwanli#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW2wangwanli(config)#int f0/23
SW2wangwanli(config-if)#sw
SW2wangwanli(config-if)#switchport mode trunk
SW2wangwanli(config-if)#
01:08:25: %LINK-4-ERROR: FastEthernet0/23 is experiencing errors


SW2wangwanli#show int f0/23 switchport
Name: Fa0/23
Switchport: Enabled
Administrative mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: isl   封装了为isl协议
Operational Trunking Encapsulation: isl
Cisco 默认采用的是ISL封装
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 1
Pruning VLANs Enabled: 2-1001

Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
Self Loopback: No

 

第五步是在SW1上创建VLAN
SW1wangwanli(config)#vlan ta
SW1wangwanli(config)#exit
SW1wangwanli#vlan da
01:20:31: %SYS-5-CONFIG_I: Configured from con
SW1wangwanli#vlan da
SW1wangwanli(vlan)#vlan 2 name vlan 2
                                    ^
% Invalid input detected at '^' marker.

SW1wangwanli(vlan)#vlan 2 name VLAN2
VLAN 2 added:
    Name: VLAN2
SW1wangwanli(vlan)#vlan 3 name VLAN3
VLAN 3 added:
    Name: VLAN3
SW1wangwanli(vlan)#vlan 4 name VLAN4
VLAN 4 added:
    Name: VLAN4
SW1wangwanli(vlan)#vlan 5 name VLAN5
VLAN 5 added:
    Name: VLAN5
SW1wangwanli(vlan)#exit
APPLY completed.
Exiting....
SW1wangwanli#

SW1wangwanli#show int f0/23 switchport
Name: Fa0/23
Switchport: Enabled
Administrative mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q   SW1是VTP server 在SW1封装的是dot1q SW2 show int f0/23 switchport 协议是ISL
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 1-5,10,30,40,100
Pruning VLANs Enabled: 2-1001

Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
Self Loopback: No
SW1wangwanli#


第七步 到SW2上查看是否可以学习到。。。。

 

 

 

 

在SW2通过trunk学习到SW1上所建的VLAN

 


                       配置生成树协议

SW1#conf t
int range f0/11 - 12
no sh
switchport mode trunk
end

SW2#conf t
int rang f0/11 - 12
no sh
switchport mode trunk
end

在SW2上 show spanning-tree

 

SW2#show spanning-tree

Spanning tree 1 is executing the IEEE compatible Spanning Tree protocol

We are the root of the spanning tree


问题1:生成树的根桥是那一个交换机?怎么来确定根桥?
根桥的选择取决于交换机的BPDU值,查看ID值和MAC地址表。两者比较最小的为rootswitch

问题2:如何知道一个交换机成为根桥?

问题3:为什么交换机会选择成为根桥?

问题4:为什么sw2的F0/12会被阻塞?为什么不是F0/11?
开销小为根端口,其他的端口就会阻塞。


              配置Spanning-tree 根桥和根路径开销
              


第一步 :配置SW1接口
conf t
int f0/23
sw me tr
int f0/24
sw me tr

第二步:配置SW2接口
conf t
int f0/23
sw me tr
int f0/24
sw me tr
第三步:查看那SW1运行spanning-tree的运行情况
SW1#show spanning-tree

Spanning tree 1 is executing the IEEE compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address 0030.1956.8400
Configured hello time 2, max age 20, forward delay 15
Current root has priority 32768, address 0001.9634.eb80
Root port is 38, cost of root path is 19
Topology change flag not set, detected flag not set, changes 9
Times: hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
Timers: hello 0, topology change 0, notification 0

 

第四步 查看SW2的生成树(Spanning-treee)运行情况

观察有无此数据
Spanning tree 1 is executing the IEEE compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address 0001.9634.eb80


We are the root of the spanning tree

 


第五步是 配置SW1的网桥优先级
SW1(config)#spanning-tree priority 1
01:23:55: ST: we are the spanning tree root   你是否将它设置根生成树
01:23:55: ST: FastEthernet0/24 become designated port
SW1(config)#int f0/23
SW1(config-if)#sh

经过SW1(config)#spanning-tree priority 1 设置了优先级
再来shouw spanning-tree 得多的结果如下,(只复制了重要一行内容)
Spanning tree 1 is executing the IEEE compatible Spanning Tree protocol
Bridge Identifier has priority 1, address 0030.1956.8400
Configured hello time 2, max age 20, forward delay 15
We are the root of the spanning tree
Topology change flag not set, detected flag not set, changes 13
Times: hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
Timers: hello 1, topology change 0, notification 0

已经成功修改成了根网桥
SW1#show spanning-tree interface f0/23
Interface Fa0/23 (port 37) in Spanning tree 1 is FORWARDING
   Port path cost 19, Port priority 128


SW1#show spanning-tree interface f0/24
Interface Fa0/24 (port 38) in Spanning tree 1 is FORWARDING
   Port path cost 19, Port priority 128
   Designated root has priority 1, address 0030.1956.8400
   Designated bridge has priority 1, address 0030.1956.8400
   Designated port is 38, path cost 0
   Timers: message age 0, forward delay 0, hold 0
   BPDU: sent 483, received 2413


第七步 修改SW2的F0/23的路径开销
SW2(config)#int f0/23
SW2(config-if)#sp
SW2(config-if)#spa
SW2(config-if)#spanning-tree cost 100
SW2(config-if)#
02:05:03: ST: stp_set_pathcost_for_api
02:05:03: ST: Adjust topology
SW2(config-if)#
02:05:08: %LINK-4-ERROR: FastEthernet0/23 is experiencing errors
SW2(config-if)#no sh
SW2(config-if)#sh
SW2(config-if)#
02:05:18: ST: sent Topology Change Notice on FastEthernet0/24 vlan 1
02:05:18: ST: FastEthernet0/23 vlan 1 -> blocking
02:05:18: ST: FastEthernet0/23 vlan 2 -> blocking
02:05:18: ST: FastEthernet0/23 vlan 3 -> blocking
02:05:18: ST: FastEthernet0/23 vlan 4 -> blocking
02:05:18: ST: FastEthernet0/23 vlan 5 -> blocking
02:05:18: %LINK-5-CHANGED: Interface FastEthernet0/23, changed state to administratively down
SW2(config-if)#
02:05:18: ST: Topology Change rcvd on FastEthernet0/24 vlan 2
02:05:18: ST: Topology Change rcvd on FastEthernet0/24 vlan 3
02:05:18: ST: Topology Change rcvd on FastEthernet0/24 vlan 4
02:05:18: ST: Topology Change rcvd on FastEthernet0/24 vlan 5
SW2(config-if)#
02:05:19: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to down