因为最近需要使用SNMP协议监控思科交换机,顺便学习了下交换机。

下图是Cisco Catlyst 2960S 交换机

配置密码:

>en 第一次密码为空

Switch#conf t 进入全局配置模式

Switch(config)#hostname swa 设置交换机名

Switch(config)#enable secret aaa 设置特权加密口令为 aaa

Switch(config)#enable password aax 设置特权非密口令为 aax

Switch(config)#line console 0 进入控制台口(Rs232)

Switch(config-line)#password aa 设置登录口令aa

Switch(config-line)#login 登录要求口令验证

Switch(config-line)#line vty 0 4 进入虚拟终端virtual tty

Switch(config-line)#password a 设置登录口令a

Switch(config-line)#login 登录要求口令验证

Switch(config-line)#exit 返回上一层

Switch(config)#exit 返回上一层

Switch#sh run 看配置信息

Switch#exit 返回命令

配置Vlan

新建一个Vlan

Switch>en (enable 的简洁版)进入特权模式

Switch#conf t (configure terminal的简洁版) 进入全局配置模式

Switch (config)# vlan vlan-id 创建一个Vlan或者进入Vlan配置模式(vlan-id一般是数字)

Switch (config-vlan)# name vlan-name 给Vlan命名(取消设置:no name)

Switch (config-vlan)# mtu mtu-size 设置最大通讯量(取消设置:no mtu)

Switch (config-vlan)#remote-span 开启远程流量监控(关闭:no remote-span)

Switch (config-vlan)# end 回到特权模式

Switch#show vlan {name vlan-name | id vlan-id} 查看当前配置

删除Vlan(如果vlan中配置接口,要先删除Vlan中的接口,否则会删除不干净)

Switch>enable 进入特权模式

Switch#conf t (configure terminal的简洁版) 进入全局配置模式

------如果vlan下已经分配了接口,需要把接口先删了-------
switch(config)#int interface-id 进入接口配置(可以用range指示一个范围,int range f0/1 - 5)
switch(config-if)#no switchport access vlan vlan-id
switch(config-if)#exit
------如果vlan下已经分配了接口,需要把接口先删了-------

Switch (config)# no vlan vlan-id 删除Vlan(vlan-id一般是数字)

Switch (config)# end 回到特权模式

Switch#show vlan brief 查看删除情况

端口加入特定Vlan

Switch>enable 进入特权模式

Switch#conf t 进入全局配置模式

Switch (config)# interface interface-id 进入端口配置(interface-id可通过show running获取,形如GigabitEthernet1/0/10或者f
0/1等,可以是一个范围,int range f0/1 - 5)

Switch (config-if)# switchport mode access 将接口的模式设为访问模式

Switch (config-if)# switchport access vlan vlan-id 将端口加入指定的Vlan(恢复端口默认配置:default interface interface-id)

Switch (config-if)# end 回到特权模式

Switch#show running-config interface interface-id 查看端口模式

Switch#show interfaces interface-id switchport 查看端口详细配置

批量端口加入特定Vlan

int range fa0/1 - 10

switchport access VLan V2

将特定端口设为trunk

Switch(config)#default interface fastEthernet 0/1 端口恢复默认值

Switch(config)#interface fastethernet0/1 进入端口模式

Switch(config-if)#switchport mode trunk 设置端口为trunk模式

Switch(config-if)#switchport nonegotiate 将接口设置为不协商模式

Switch(config-if)end

Switch#wr

启用snmp

Switch>enable 进入特权模式

Switch#configure terminal 进入全局配置模式

Switch (config)# snmp-server community string [view view-name] [ro | rw] [access-list-number]

(关闭snmp: no snmp-server)

(删除团体字符: no snmp-server community string) 配置snmp团体字符并开启snmp代理服务

String: 团体口令字符(所有SNMP命令中只有设置团体口令的snmp-server community是必须的,其它的都是可选的.)

View: view 可以用于限定哪些MIB分支不能用本community-string存取预先用snmp-server view定义

ro | rw: ro获得MIB对象信息;rw获得并可以修改MIB对象信息

access-list-number:访问列表号

Switch (config)#access-list access-list-number {deny |

permit} source [source-wildcard] 配置拒绝或者允许访问snmp代理服务的IP地址,访问列表号为上一步指定的列表号

Switch (config)#end 回到特权模式

Switch#show running-config 查看配置

cisco2960口令恢复

交换机口令恢复的步骤

⒈串口线连接到到交换机的console口。

⒉先按住交换机面板上的mode键,然后打开电源。

⒊初始化flash。

>flash_init

⒋更名含有password的配置文件。

>rename flash:config.text flash:config.old

⒌启动交换机。

>boot

⒍进入特权模式。

>enable

⒎此时开机是已忽略password。

#rename flash:config.old flash:config.text

⒏copy配置文件到当前系统中。

#copy flash:config.text system:running-config

⒐修改口令。

#configure terminal

#enable secret

⒑保存配置。

#write

发表回复