交换机的常用操作项<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

l      交换机的三种模式
用户模式:查看简单的配置
特权模式:能够进行查看和命令的操作,相当于管理员
全局配置模式:配置交换机的参数
1
、由用户模式输入enable、进入特权模式
2
、由特权模式进入全局配置模式输入config terminal
3
、配置接口的ip时要进入到相应的接口中,用interface +接口

 

l      更改主机名
switch(config)#hostname A

l      设置进入特权模式的密码
switch(config)#enable password 1234 
明文显示
switch(config)#enable secret cisco 
加密显示

l      设置console口密码
switch(config)#line console 0
switch(config-line)#password  123
switch(config-line)#login

l      查看mac地址列表
switch#show mac-address-table

l      查看mac地址列表刷新时间
switch#show mac-address-table aging-time

l      更改mac地址列表刷新时间
switch(config)#mac-address-table aging-time 200

l      保存配置
switch#copy running-config startup-config
switch#write

l      恢复出厂默认设置
switch#erase startup-config
switch#reload
l   添加接口的描述信息
switch(config-if)# description connection to routerA

l      设置交换机的网关
switch(config)#ip default-gateway 192.168.1.1

l      关掉DNS解析
switch(config)#
no ip domain-lookup
l   将接口设为trunk
     switch(config-if)#switchport mode trunk
l   关闭trunk
     switch(config-if)#switchpor mode access
●        配置接口为动态协商模式
 switch(config-if)#switchport mode dynamic desirable/auto
 
l   还原接口到默认配置状态
     switch(config-if)#default interface interface-id
l      查看当前配置(RAM
switch#show running-config

l      查看交换机的配置(NVRAM
switch#show startup-config

l      查看cdp的全局信息
switch#show cdp

l      查看接口的cdp配置信息
switch#show cdp interface f0/2

l      查看有关cdp包的统计信息
switch#show cdp traffic

l      查看邻居信息
switch#show cdp neighbors

l      查看所有入口项的详细信息
switch#show cdp neighbors detail
switch#show cdp entry *

l      实现交换机的远程管理
switch(config)#enable secret cisco
switch(config)#intface valn 1
switch(config-if)#ip address 192.168.1.100 255.255.255.0
switch(config-if)#no shutdown
switch(config)#line vty 0 4
switch(config-line)#password 123
switch(config-line)#login
c:\>telnet 192.168.1.100

l      交换机的密码恢复
1
、将交换机的电源拔下
2
、按住mode键插上电源,当出现switch:时将手松开
3
switch:flash_init      //加载到flash
4
switch:dir flash:      //查看flash中的文件
5
rename flash:config.text  flash:config.old //更改文件名
6
boot                 //重新启动交换机
7
rename flash:config.old  flash:config.text  //将文件名改回
8
copy flash:config.text  running-config
9
enable password  cisco            //重新设置密码
10write                           //保存

l      创建vlan方法一
switch#vlan database
switch(vlan)#vlan  10  name  ****
switch(vlan)#exit

l      创建vlan方法二
switch(config)#vlan 10
switch(config-vlan)#name ****

l      删除vlan方法一
switch(vlan)#no vlan 10
switch(vlan)#exit

l      删除vlan方法二
switch(config)#no vlan 10

l      删除vlan方法三
switch#delete vlan.dat

l      将端口加入到vlan
switch(config-if)#switchport access vlan 10

l      将一组连续的端口加入到vlan
switch(config)# interface range f0/1 – 5
switch(config-if-range)#switchport access vlan 10

l      <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /> 将端口从vlan中删除
switch(config-if)#no switchport access vlan 10
switch(config-if)#switchport access vlan 1
switch(config-if-range)#no switchport access vlan 10
switch(config-if-range)#switchport access vlan 1

l      查看所有vlan的摘要信息
switch#show vlan brief

l      查看指定vlan的信息
switch#show vlan id 10
 
●        查看接口模式
      switch#show interface f0/1 switchport
●        在trunk中添加或删除某个vlan(在trunk口中)
      switch(config-if)#switchport trunk allowed vlan add 10
      switch(config-if)#switchport trunk allowed vlan remove 10