1.用户模式与特权模式
用户模式:可以使用一些基本的查询命令
特权模式:可以对交换机进行相关的配置
进入特权模式命令:switch> enable
退出特权模式:Switch#exit
启用命令查询:?
注意:可以用TAB键补齐命令,自选参数为用户自定义参数,可选参数为交换机设定的参数。
查看交换机配置:Switch# show running-config
保存交换机配置: Switch# copy running-config startup-config
Switch# write
查看端口信息: Switch# show interface
查看MAC地址表: Switch#show mac-address-table
查看交换机CPU的状态信息: Switch# show process
2.全局配置模式
进入全局配置模式: Switch# configure terminal
主机名参数:Switch(config# hostname 主机名
特权模式进入密码:Switch(config)# enable secret (参数)密码
取消特权模式密码:Switch(config)# no enable secret
取消主机名设置: Switch(config) #no hostname
退出配置模式: Switch(config )#exit
需要特别注意的是在配置模式中无法使用show命令,如果要使用的话show前必须加do 和空格,例如:do show *
指定根交换机命令: Switch(config# )spanning-tree vlan (参数) root primary
例如: Switch(config )#spanning-tree vlan 1 root primary
注意:设置交换机是基于VALN的
关闭生成树协议命令:Switch(config )#no spaning-tree vlan (vlan号)
例如:Switch(config )#no spanning-tree vlan 1
3.接口配置模式
进入接口配置模式:Switch(config )#inteerface 端口名称
启用端口:Switch(config )#no shutdown
进入同种类型多端口配置:Switch(config )#intface range fastethernet1/1-5
进入不同类型多端口配置:Switch(config )#interface range fastethernet1/1-5,g0/1-2
4.二层端口的配置
端口速率:Switch(config -if)#speed
双工模式:Switch(config -if)#duplex
禁用链路协商:Switch(config -if)#no negotiation auto
启用链路协商:Switch(config -if)#negotiation auto
5.VLAN的配置
新建VALAN:Switch(config)#vlan (vlan 号)
删除vlan:Switch(config)#no (vlan 号)
将一个接口加入VLAN
Switch(config-if)# switchport mode access
Switch(config-if)#switchport access (valn 号)
Switch(config-if)#no shutdown
Switch(config-if)#exit
将一个接口退出VLAN:
Switch(config-if)#interface (valn 号)
Switch(config-if)#no switchport access vlan (VLAN 号)
修改一个接口为端口为trunk模式
Switch(config)# int (端口号)
Switch(config)#sw mode trunk
VLAN的验证命令
Switch# show vlan ------显示VLAN列表
Switch#show int sw ------查看具体接口的VALN成员资格信息
6.VTP的配置
VTPDomain Name(VTP域名)
Switch#config t
Switch#vtp domain 自选参数
VTP mode (VTP模式)
Switch(config)#vtp mode 可选参数(Server/Client/Transparent)
例如: Switch(config)#vtp mode Server
VTP Pruning
Switch(config)#vtp pruning
查看VTP的配置命令:
Switch#show vtp status ----显示交换机运行的VTP模式、配置修订号和交换机所属的VTP域
Switch#show vtp copunters ---显示VTP消息相关的统计数据
7.远程登录交换机设置
配置管理VLAN:
Switch(conf)#interface vlan 1
Switch(config-if)#ip address x.x.x.x 255.255.255.0
Switch(config-if)#no shutdown
注意:‘IP地址必须与远程连接交换机的PC机地址在同一网段
在交换机上指定默认网关:
Switch(config)#ip default-gateway x.x.x.x
将交换机连接PC机的端口加入VLAN 1
Switch(config)#interface 端口号
Switch(config-if)#switchport mode access
Switch(config-if)# no shutdown
配置交换机的远程登录
Switch(config)# line vty 0 4
Switch(config-line)#password 自选密码
Switch(config-line)#login
Switch(config)#enable secret