思科2960交换机配置命令


交换机基本状态:
switch: ;ROM状态, 路由器是rommon>
hostname> ;用户模式
hostname# ;特权模式
hostname(config)# ;全局配置模式
hostname(config-if)# ;接口状态

交换机口令设置:
switch>enable ;进入特权模式
switch#config terminal ;进入全局配置模式
switch(config)#hostname ;设置交换机的主机名
switch(config)#enable secret xxx ;设置特权加密口令
switch(config)#enable password xxa ;设置特权非密口令
switch(config)#line console 0 ;进入控制台口
switch(config-line)#line vty 0 4 ;进入虚拟终端
switch(config-line)#login ;允许登录
switch(config-line)#password xx ;设置登录口令xx
switch#exit ;返回命令

交换机VLAN设置:
switch#vlan database ;进入VLAN设置
switch(vlan)#vlan 2 ;建VLAN 2
switch(vlan)#no vlan 2 ;删vlan 2
switch(config)#int f0/1 ;进入端口1
switch(config-if)#switchport access vlan 2 ;当前端口加入vlan 2
switch(config-if)#switchport mode trunk ;设置为干线
switch(config-if)#switchport trunk allowed vlan 1,2 ;设置允许的vlan
switch(config-if)#switchport trunk encap dot1q ;设置vlan 中继
switch(config)#vtp domain ;设置发vtp域名
switch(config)#vtp password ;设置发vtp密码
switch(config)#vtp mode server ;设置发vtp模式
switch(config)#vtp mode client ;设置发vtp模式

交换机设置IP地址:
switch(config)#interface vlan 1 ;进入vlan 1
switch(config-if)#ip address ;设置IP地址
switch(config)#ip default-gateway ;设置默认网关
switch#dir flash: ;查看闪存

交换机显示命令:
switch#write ;保存配置信息
switch#show vtp ;查看vtp配置信息
switch#show run ;查看当前配置信息
switch#show vlan ;查看vlan配置信息
switch#show interface ;查看端口信息
switch#show int f0/0 ;查看指定端口信息

 

 

 

                                 交换机命令总结
基本配置命令
Switch >enable       进入特权模式
Switch #config terminal         进入全局配置模式
Switch (config)#hostname        设置交换机的主机名
Switch(config)#enable password          进入特权模式的密码(明文形式保存)
Switch(config)#enable secret             加密密码(加密形式保存) (优先)
Switch(config)#ip default-gateway      配置交换机网关
Switch(config)#show mac-address-table            查看MAC地址
Switch(config)logging synchronous                     阻止控制台信息覆盖命令行上的输入
Switch(config)no ip domain-lookup                                      关闭DNS查找功能
Switch(config)exec-timeout 0 0                                                         阻止会话退出
 
使用Telnet远程式管理
Switch (config)#line vty 0 4    进入虚拟终端
Switch (config-line)# password     设置登录口令
Switch (config-line)# login    要求口令验证
 
控制台口令
switch(config)#line console 0    进入控制台口
switch(config-line)# password xx   
switch(config-line)# 设置登录口令login    允许登录
<!--[if !supportLineBreakNewLine]--&gt
<!--[endif]--&gt
Cisco发现协议(CDP)
Switch(config)#show cdp                                   显示Cisco设备全局配置信息
Switch(config)#show cdp interface 端口            查看CDP配置下端口信息
Switch(config)#show cdp neighbors                   显示直连Cisco设备信息
 Switch(config)#show cdp neighbors detail       查看邻居详细信息
 
<!--[if !supportLineBreakNewLine]--&gt
<!--[endif]--&gt

恢复出厂配置
Switch(config)#erase startup-config
Switch(config)delete vlan.dat

 

配置接口标识     接口标识用于区分路由器的各个接口。
switch(config)#interface fastethernet 0/1       以0/1 接口为例
switch(config)# description this is a fast Ethernet port used to connecting the company’s intranet! 

 
 
 
 Vtp配置
switch(config)#vtp domain        设置vtp域名
switch(config)#vtp password       设置vtp密码
switch(config)#vtp mode server /client/transparent  设置vtp服务器模式
switch(config)#vtp version         设置vtp版本
switch(config)#vtp pruning         启用vtp修解
注:要想从vtp中减少一台交换机只需将该交换机vtp 域名更改
Vlan基本配置
  Switch#vlan database                                                进去vlan配置模式
  Switch(vlan)#vlan 号码 name 名称                         创建vlan及vlan名
  Switch(vlan)#vlan号码 mtu数值                             修改MTU大小
  Switch(vlan)#exit                                                      更新vlan数据并推出
  Switch#show vlan                                                     查看\验证
  Switch#copy running-config startup-config             保存配置
  叫NO 删除VLAN
 

VLAN 中添加 删除端口
   Switch#config terminal                                            进入全局配置
   Switch(config)#interface fastethernet0/1                 进入要分配的端口
   Switch(config-if)#Switchport mode access             定义二层端口
   Switch(config-if)#Switchport acces vlan 号            把端口分给一个vlan
Switch(config-if)#switchport mode trunk    设置为干线
Switch(config-if)#switchport trunk encapsulation dot1q    设置vlan 中继协议
Switch(config-if)#no switchport mode 或 ( switchport mode access)    禁用干线
Switch(config-if)#switchport trunk allowed vlan add 1,2  从Trunk中添加vlans
Switch(config-if)#switchport trunk allowed vlan remove 1,2 从Trunk中删除vlan
Switch(config-if)#switchport trunk pruning vlan remove 1,2 ;从Trunk中关闭局部修剪

 查看vlan信息 Switch#show vlan brief              所有vlan信息
 查看vlan信息 Switch#show vlan id     某个vlan信息
 
注:Switch#show int trunk 查看trunk协议
注:可以使用default interface interface-id               还原接口到默认配置状态
         
   Trunk
  开启(no)          ——将端口设置为永久中继模式
  关闭(off)         ——将端口设置为永久非中继模式, 并且将链路转变为非中继链路
  企望(desirable)——让端口主动试图将链路转换成中继链路
  自动(auto)       ——使该端口愿意将链路变成中继链路
 
   配置接口为动态协商模式
       Switch(config)#interface 接口号
       Switch(config)#switchport mode dynamic  desirable/auto
 
   
生成树stp:
Switch(config)#spanning-tree vlan     启用stp生成树(基于vlan)
Switch(config)#spanning-tree vlan root primary    指定根交换机(基于vlan)
Switch(config)#spanning-tree vlan root secondary    指定备用根交换机(基于vlan)
Switch(config)#spanning-tree vlan priority <0-65535> 指定交换机优先级(基于vlan)
Switch(config)#no spanning-tree vlan priority    将交换机的优先级恢复默认值(基于vlan)
Switch(config-if)#spanning-tree vlan cost <0-200000000> 指定端口成本(起用trunk的端口模式下)
Switch(config-if)#spanning-tree vlan port-prioty <0-255> 指定交换机端口优先级(基于vlan)
Switch(config-if)#spanning-tree portfast    配置速端口(连接终端设备的端口状态)如pc机
Switch(config)#spanning-tree uplinkfast    配置上行速端口
注:在配置上行速端口前要先将基于vlan上的网桥优先级,网桥成本恢复默认值。起用了该命令后在进行优先级更改,
注:vlan为可选参数,当没有该参数时将修改所有vlan网桥的优先级\及所有的vlan端口成本
Switch#show spanning-tree summery    检测vlan生成树配置
Switch#show spanning-tree vlan detail    浏览详细生成树配置信息
Switch#show spanning-tree interface detail    浏览详细生成树端口配置信息

以太网通道配置
switch(config)#interface range fasternet0/1 - 2    将fasternet0/1和0/2 口捆绑
switch(config-if)#channel-group 1 mode on    配置以太通道模式
switch(config-if)#port-channel load-balance {dst-mac | src-mac}在链路间实现负载均衡
switch#show etherchannel  1  summary    查看通道信息
switch#show etherchannel  load-balance    查看通道信息

交换机显示命令:
switch#show vtp status    查看vtp配置信息
switch#show running-config    查看当前配置信息
switch#show vlan    查看vlan配置信息
switch#show interface    查看端口信息
switch#show int f0/0    查看指定端口信息
switch#dir flash:    查看闪存
switch#show version    查看当前版本信息
switch#show cdp    cisco设备发现协议  (可以查看聆接设备)
switch#show cdp traffic    杳看接收和发送的cdp包统计信息
switch#show cdp neighbors    查看与该设备相邻的cisco设备
switch#show interface f0/1 switchport                                    查看有关switchport的配置
switch#show cdp neighbors                              查看与该设备相邻的cisco设备

 



配置接口标识     接口标识用于区分路由器的各个接口。
switch(config)#interface fastethernet 0/1      
0/1 接口为例
switch(config)# description this is a fast Ethernet port used to connecting the company’s intranet!  


 

 


 Vtp
配置
switch(config)#vtp domain        
设置vtp域名
switch(config)#vtp password       
设置vtp密码
switch(config)#vtp mode server /client/transparent 
设置vtp服务器模式
switch(config)#vtp version        
设置vtp版本
switch(config)#vtp pruning         
启用vtp修解
:要想从vtp中减少一台交换机只需将该交换机vtp 域名更改
Vlan
基本配置
  Switch#vlan database                                               
进去vlan配置模式
  Switch(vlan)#vlan
号码 name 名称                         创建vlanvlan
  Switch(vlan)#vlan
号码 mtu数值                             修改MTU大小
  Switch(vlan)#exit                                                      
更新vlan数据并推出
  Switch#show vlan                                                    
查看\验证
  Switch#copy running-config startup-config             
保存配置

  NO 删除VLAN

 


VLAN
中添加 删除端口
   Switch#config terminal                                           
进入全局配置
   Switch(config)#interface fastethernet0/1                
进入要分配的端口
   Switch(config-if)#Switchport mode access            
定义二层端口
   Switch(config-if)#Switchport acces vlan
            把端口分给一个vlan

Switch(config-if)#switchport mode trunk    设置为干线
Switch(config-if)#switchport trunk encapsulation dot1q   
设置vlan 中继协议
Switch(config-if)#no switchport mode
( switchport mode access)    禁用干线
Switch(config-if)#switchport trunk allowed vlan add 1
Trunk中添加vlans
Switch(config-if)#switchport trunk allowed vlan remove 1
2 Trunk中删除vlan
Switch(config-if)#switchport trunk pruning vlan remove 1
2 ;从Trunk中关闭局部修剪

 
查看vlan信息 Switch#show vlan brief              所有vlan信息
 
查看vlan信息 Switch#show vlan id     某个vlan信息

 

:Switch#show int trunk 查看trunk协议

注:可以使用default interface interface-id               还原接口到默认配置状态
         
   Trunk
 
开启(no          ——将端口设置为永久中继模式

  关闭(off         ——将端口设置为永久非中继模式, 并且将链路转变为非中继链路
  
企望(desirable——让端口主动试图将链路转换成中继链路

  自动(auto       ——使该端口愿意将链路变成中继链路


   
配置接口为动态协商模式
       Switch(config)#interface
接口号
       Switch(config)#switchport mode dynamic  desirable/auto
 
    
生成树stp
Switch(config)#spanning-tree vlan    
启用stp生成树(基于vlan
Switch(config)#spanning-tree vlan root primary   
指定根交换机(基于vlan
Switch(config)#spanning-tree vlan root secondary   
指定备用根交换机(基于vlan
Switch(config)#spanning-tree vlan priority <0-65535>
指定交换机优先级(基于vlan
Switch(config)#no spanning-tree vlan priority   
将交换机的优先级恢复默认值(基于vlan
Switch(config-if)#spanning-tree vlan cost <0-200000000>
指定端口成本(起用trunk的端口模式下)
Switch(config-if)#spanning-tree vlan port-prioty <0-255>
指定交换机端口优先级(基于vlan
Switch(config-if)#spanning-tree portfast   
配置速端口(连接终端设备的端口状态)如pc
Switch(config)#spanning-tree uplinkfast   
配置上行速端口
:在配置上行速端口前要先将基于vlan上的网桥优先级,网桥成本恢复默认值。起用了该命令后在进行优先级更改,
:vlan为可选参数,当没有该参数时将修改所有vlan网桥的优先级\及所有的vlan端口成本
Switch#show spanning-tree summery   
检测vlan生成树配置
Switch#show spanning-tree vlan detail   
浏览详细生成树配置信息
Switch#show spanning-tree interface detail   
浏览详细生成树端口配置信息

以太网通道配置
switch(config)#interface range fasternet0/1 - 2   
fasternet0/10/2 口捆绑
switch(config-if)#channel-group 1 mode on   
配置以太通道模式
switch(config-if)#port-channel load-balance {dst-mac | src-mac}
在链路间实现负载均衡
switch#show etherchannel  1  summary   
查看通道信息
switch#show etherchannel  load-balance   
查看通道信息

交换机显示命令:
switch#show vtp status   
查看vtp配置信息
switch#show running-config   
查看当前配置信息
switch#show vlan   
查看vlan配置信息
switch#show interface   
查看端口信息
switch#show int f0/0   
查看指定端口信息
switch#dir flash:   
查看闪存
switch#show version   
查看当前版本信息
switch#show cdp    cisco
设备发现协议  (可以查看聆接设备)
switch#show cdp traffic   
杳看接收和发送的cdp包统计信息
switch#show cdp neighbors   
查看与该设备相邻的cisco设备
switch#show interface f0/1 switchport                                   
查看有关switchport的配置
switch#show cdp neighbors                             
查看与该设备相邻的cisco设备

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22087074/viewspace-687582/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22087074/viewspace-687582/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值