日期:2015-08-03  浏览次数:3464 次

1.1 用户模式与特权模式

用户模式:可以使用一些基本的查询命令

特权模式:可以对交换机进行相关的配置

进入特权模式命令:Switch>enable

退出特权模式命令:Switch#exit

启用命令查询:?

时间设置:Switch#clock set 时间(自选参数,参数必须符合交换机要求)

显示信息命令:Switch#show 可选参数

注意:可以用TAB键补齐命令,自选参数为用户自定义参数,可选参数为交换机设定参数

查看交换机配置: Switch#show running-config

保存交换机配置:Switch#copy  running-config startup-config

                   Switch#wr

查看端口信息:Switch#show interface

查看MAC地址表:Switch#show  mac-address-table

查看交换机CPU的状态信息:Switch#show processes

 

 

 

1.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 自选参数(VLAN号) root primary

例如: Switch(config)#spanning-tree vlan 1 root primary

需要注意的是:设置根交换机是基于VLAN的

关闭生成树协议命令:Switch(config)#no spanning-tree vlan 自选参数(VLAN号)

例如: Switch(config)#no spanning-tree vlan 1

 

 

 

1.3 接口配置模式

进入接口配置模式:Switch(config)#interface 端口名称(可选参数)

启用端口:Switch(config-if)#no shutdown

停用端口:Switch(config-if)#shutdown

进入同种类型多端口配置:Switch(config)# interface range  fastethernet 0/1-5

进入不同类型多端口配置:Switch(config)#interface range  fastethernet 0/1-5,gigabitethernet 0/1-2

退出接口配置模式:Switch(config-if)#exit

 

 

 

1.4  二层端口的配置

端口速率: Switch(config-if)#speed 可选参数

双工模式: Switch(config-if)#duplex 可选参数

禁用链路协商:Switch(config-if)#no negotiation auto

启用链路协商:Switch(config-if)#negotiation auto

 

 

 

1.5  VLAN的配置

新建VLAN:Switch(config)#vlan 自选参数(VLAN号)

Switch(config-vlan)#name自选参数(VLAN名)

例如:Switch(config)#vlan  1

Switch(config-vlan)#name  lab1

Switch(config-vlan)#exit

删除VLAN: Switch#vlan database

          Switch(vlan)#no vlan 自选参数(vlan号)

例如:Switch#vlan database

Switch(vlan)#no vlan 2

将一个接口加入VLAN

Switch(config)#interface  可选参数(接口号)

Switch(config-if)#switchport  mode  access

Switch(config-if)#switchport  access  vlan  自选参数(VLAN号)

Switch(config-if)#no  shutdown

Switch(config-if)#exit

例如:Switch(config)#interface  f0/1

Switch(config-if)#switchport  mode  access

Switch(config-if)#switchport  access  vlan  1

Switch(config-if)#no  shutdown

Switch(config-if)#exit

将一个接口退出VLAN

Switch(config)#interface  可选参数(接口号)

Switch(config-if)#no  switchport  access  vlan  自选参数(VLAN号)

例如:Switch(config)#interface  f0/1

Switch(config-if)#no  switchport  access  vlan  2

修改一个接口为端口汇聚模式

Switch(config)#interface  可选参数(接口号)

Switch(config-if)#switchport  mode  trunk

VLAN的验证命令:

Switch#show  vlan                    显示VLAN列表

Switch#show  interface  switchport   查看具体接口的VLAN成员资格信息

 

 

 

 

 

1.6 VTP的配置

VTP Domain Name(VTP域名)

Switch#configure terminal
Switch(config)#vtp domain 自选参数

例如: Switch(config)#vtp domain Lab_Network
VTP mode(VTP模式)

Switch(config)#vtp mode 可选参数(Server|Client| Transparent)

例如: Switch(config)#vtp mode Server

VTP Pruning(VTP修剪)

Switch(config)#vtp pruning

注意:有的交换机不支持VTP修剪命令

查看VTP的配置命令:

Switch#show vtp status

显示交换机运行的VTP模式,配置修订号和交换机所属的VTP域

Switch#show vtp counters

显示VTP消息相关的统计数据

 

 

 

1.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)#switchport access  vlan 1

Switch(config-if)#no shutdown

配置交换机的远程登录

Switch(config)#line vty  0 4

Switch(config-line)#password 自选参数

Switch(config-line)#login

Switch(config)#enable secret 自选参数