1、交换机支持的命令:(注:交换机支持命令对应的为思科2系列交换机。) 交换机基本状态: switch: ;交换机的ROM态 rommon> ;路由器的R状态 switch > ;用户模式 switch# ;特权模式 switc
2、h(config)# ;全局配置模式 switch(vlan)# 交换机VLAN配置模式 switch(config-if)# ;端口配置模式 switch(config-line)# ; 指定连接状态(console连接 telnet连接) 交换机显示命令: switch#write
3、 ;保存配置信息 switch#show running ;查看当前配置信息 switch#show startup 查看交换机NVROM配置信息 switch#show vlan ;查看vlan配置信息 switch#show vlan-switch 同样为查看vlan配置信息(一些高端交换机比如3系列的交
4、换机必须用这个命令才能查看vlan配置信息) switch#show vtp status 查看VTP配置信息 switch#show interface ;查看所有的端口信息 switch#show interface f0/3 ;查看指定的f0/3快速以太网端口信息 switch#show interfacef0/3 switchport 查看指定的f0/3快速以
5、太网端口trunk信息 switch #show spanning-tree 查看交换机生成树协议情况 switch #show spanning-tree vlan 2 查看交换机VLAN2的生成树协议情况 switch #show spanning-tree interface f0/1 查看交换机F0/1端口生成树协议情况 switch #show cdp 显示交换机当前邻居更新信息 switch #show cdp nei
6、ghbor ;显示邻居直连路由信息 switch #show cdp neighbor detail 显示邻居直连路由详细信息 switch #show cdp interface 显示所有端口是否开启cdp功能 switch (config-if)#no cdp enable 关闭指定端口的cdp功能 switch (config-if)#cdp enable 打开指定端口的cdp功能 switc
7、h (config)#no cdp run 关闭所有端口的cdp功能 switch (config)#cdp run 打开所有端口的cdp功能 switch#show version 查看交换机版本信息 switch#show flash 查看flash里面的IOS信息 switch#show mac-address-table 查看交换机所有端口的MAC 地址信息
8、
交换机口令设置:
switch>enable ;进入特权模式
switch#config terminal ;进入全局配置模式
switch(config)#hostname
9、tch(config)#enable password xxa ;设置特权非密口令 switch(config)#line console 0 ;进入控制台口 switch(config-line)#login ;允许登录 switch (config-line)# password xx 设置登陆控制台口口令 switch (config-line)#exec-timeout 0 0
10、 设置控制台口多长时间不操作会自动退出,前面一个0表示分钟 后面一个0表示秒 两个都是0表示一直不会自动退出。 switch(config-line)#logging sy switch(config-line)#no ip domain-lookup 关闭域名查找功能(如果你输错了命令,switch会认为你输入的是域名,就会查找。。。浪费时间。no ip domain-lookup就是取消这种查找) switch(config-line)#line vty 0 4 ;进入虚拟终端 switch(conf
11、ig-line)#login ;允许登录 switch(config-line)#password xx ;设置登录虚拟终端口令xx switch#exit ;返回命令 交换机常规配置 switch(config)#no mac-address-table static (需要删掉的mac地址) fastethernet f0/7 清除掉交换
12、机F0/7端口的MAC地址 switch(config-if)#duplex full/halt/auto ;设置交换机端口工作方式 (full全双工 halt半双工模式 auto自动检测) switch(config-if)#speed 10/100/1000/auto ;设置交换机对应端口局域网交换速度 switch(config)#interface f0/1 进入快速以太网端口端口f0/1 switch(config)#interface vlan 1
13、 ;进入vlan 1 switch(config)#interface range f0/1 – 24 进入快速以太网端口f0/1到f0/24 交换机文件操作: switch#copy running-config startup-config 将RAM的当前配置存储到NVRAM switch#copy running-config tftp 备份RAM存储的配置信息到tftp switch#copy startup-config tftp 备份NVRAM配置备份到tftp switch#c
14、opy flash tftp ;备份路由器的flash文件IOS到tftp switch#copy tftp startup-config ;恢复NVRAM配置文件 switch#copy tftp running-config 恢复NVRAM配置文件 switch#copy tftp flash: 将flash文件IOS从tftp恢复到路由器 switch#erase startup-config 清除NVRA
15、M存储的配置文件 交换机生成树协议配置 switch(config)#spanning-tree 开启交换机生成树协议 switch(config)#no spanning-tree 关闭交换机生成树协议 switch(config-if)#spanning-tree port-priority 32 设定这个端口的优先级为32(端口优先级取值范围为0~240 之间的16 倍数,即取值范围为 0、16、32、48…240.设定数值越小,优先级越高) switch(config)#spanning-tree priority
16、 4096 设定这个交换机STP优先级为4096(取值范围为0~61440 之间的4096 的倍数,即取值范围为0、4096、8192…61440. 设定数值越小,优先级越高) 交换机端口镜像配置 Switch (config)# monitor session 1 destination interface f0/1 配置f0/1为镜像端口。 Switch (config)# monitor session 1 source interface f0/2 both 配置f0/2为被镜像端口,且出入双向数据均被镜
17、像。 Switch (config)# monitor session 1 source interface f0/2-f0/10 both 配置f0/1到f0/10为被镜像端口,且出入双向数据均被镜像。 Switch (config)# monitor session 1 source vlan2 both 配置整个vlan2为被镜像端口,且出入双向数据均被镜像。 Switch (config)# no monitor session 1 去掉镜像1。 交换机VLAN设置: switch#vlan database
18、 ;进入VLAN设置
switch(vlan)#vlan 2 ;建VLAN 2
switch(vlan)#vlan 2 name
19、名
switch(vlan)#vtp password
20、 启动三层交换机路由转发 switch(config-if)#switchport access vlan 2 ;当前端口加入vlan 2 switch(config-if)#switchport mode trunk ;设置为干线(开启trunk干线功能) switch(config-if)#switchport trunk encap dot1q ;设置vlan 中继(开启vlan封装的802.1q协议) switch(config-if)#switchport trunk all
21、owed vlan all ;设置允许的vlan(这个命令为允许所有的vlan从这个干线进行传递)
switch(config-if)#switchport trunk allowed vlan 2 3 设置允许的vlan(这个命令为允许vlan 2和 vlan 3从这个干线进行传递)
交换机设置IP地址:
switch(config-if)#ip address
22、dir flash: ;查看闪存 3750#show arp 查看IP与MAC对应 Address Age (min) Hardware Addr Type Interface --------------- ---------- -------------- ------ -------------------- 10.0.0.2 31 0090.0b09.622e arpa Gi1/1 192.168
23、100.3 0 00e0.6109.5e90 arpa VL10 192.168.100.49 15 0019.21bd.b6cd arpa VL10 192.168.100.50 0 00e0.b0ef.97d8 arpa VL10 192.168.100.51 1 0019.21cf.dcdb arpa VL10 看MAC地址从哪个端口学习上来 3750#show mac-address-table
24、 Vlan MAC Address Type Interface ---------- -------------------- -------- ------------------- 1 001e.ecbf.8744 DYNAMIC Gi1/22 1 00d0.f87b.f7a5 DYNAMIC Gi1/23 1 00d0.f88b.a04d DYNAMIC Gi1/24 交换机
25、名(config)# interface fastethernet 0/1 /*进入接口0/1的配置模式 交换机名(config-if)# speed 10 /*设置该端口的速率为10Mb/s 交换机名(config-if)# duplex full /*设置该端口为全双工 交换机名(config-if)# end /*退回到特权模式 交换机名# show interface fastethernet 0/1 /*查询端口0/1的配置结果 1、duplex auto;
26、自适应双工模式 2、duplex full; 全双工模式 3、duplex half; 半双工模式 路由器支持的命令: 建立本地数据库用户名CNTC 密码123 router(config)#username CNTC password 123 进入控制台接口,配置路由器以本地数据库的方式进行认证 router(config)#line console 0 router(config-line)#login local router(config-line)# 进入VTY接口,设置远程登录时用本地数据库认证 route
27、r(config)#line vty 0 4 router(config-line)#login local router(config-line)# router#Clear line vty 0 永久性清除telent登录 查看路由器当前配置show running-config 可以通过“default”命令修改快速还原以前的封装协议 向192.168.1.1发送150个大小为200字节的数据包 router(config)#line console 0 router(config-line)#exec-timeout
28、0 0 设置路由器console永不超时 router(config-line)#logging synchronous 阻止控制台口信息妨碍CLI操作(console口信息同步) No ip domain-lookup 关闭域名解析功能 no auto-summary关闭自动汇总 路由器基本状态: router: ;路由器的ROM态 rommon>
29、 ;路由器的R状态 router> ;用户模式 router# ;特权模式 router(config)# ;全局配置模式 router(config-if)# ;端口配置模式 router(config-line)#
30、 ; 指定连接状态(console连接 telnet连接) router(config-router)# 路由状态配置模式(动态路由配置模式) router(dhcp-config)# 路由器DHCP配置模式 路由器显示命令: router#show running ;显示配置信息 router#show startup 查看交换机NVROM启动配置信息 r
31、outer#show interface ;显示接口信息 router#show ip int brief 显示接口ip地址 router#show interface f0/0 ;查看指定端口信息 router#show ip route ;显示路由表信息 router #show cdp 显示路由器当前邻居更新信息 router#sh
32、ow cdp neighbor ;显示邻居直连路由信息 router#show cdp neighbor detail 显示邻居直连路由详细信息 router#show cdp interface 显示所有端口是否开启cdp功能 router#show access-lists router (config-if)#no cdp enable 关闭指定端口的cdp功能 router
33、config-if)#cdp enable 打开指定端口的cdp功能 router(config)#no cdp run 关闭所有端口的cdp功能 router(config)#cdp run 打开所有端口的cdp功能 router(config)#no ip domain lookup 关掉域名解析 router#reload ;重新起动 router#s
34、how version 查看路由器版本信息
router#show flash 查看flash里面的IOS信息
路由器口令设置:
router>enable ;进入特权模式
router#config terminal ;进入全局配置模式
router(config)#hostname
35、 设置路由器的主机名 router(config)#enable secret xxx ;设置特权加密口令(真正进入enable特权模式需要输入这个口令) router(config)#enable password xxx ;设置特权非密口令 router(config)#line console 0 ;进入控制台口 router(config-line)#login ;要求口
36、令验证 router(config-line)# password xx 设置登陆控制台口口令 router(config-line)#exec-timeout 0 0 设置控制台口多长时间不操作会自动退出,前面一个0表示分钟 后面一个0表示秒 两个都是0表示一直不会自动退出。 router(config-line)#logging sy router(config-line)#no ip domain-lookup 关闭域名查找功能(如果你输错了命令,router会认为你输入的是域名
37、就会查找。。。浪费时间。no ip domain-lookup就是取消这种查找) router(config-line)#line vty 0 4 ;进入虚拟终端 router(config-line)#login ;要求口令验证 router(config-line)#password xx 设置登录虚拟终端口令xx router(config)#(Ctrl+z) ; 返回特权模式
38、 router#exit ;返回命令 路由器常规配置: router#clock set 18:10:53 20 march 2010 设定路由器时钟,例子设定的为2010年3月20日18点10分53秒 router(config)#interface s0/0 ;进入Serail接口(串口) router(config)#interface f0/0 进入快速以太网接口f0/0
39、
router(config-if)#no shutdown ;激活当前接口
router(config-if)#bandwidth 64 ;设定指定串口带宽
router(config-if)#clock rate 64000 ;设置同步时钟
router(config-if)#ip address
40、second ;设置第二个IP
router(config-if)#interface f0/0.1 ;进入子接口
router(config-subif.1)#ip address
41、config-register 0x2102 ;正常使用配置文件 router#reload ;重新引导 路由器文件操作: router#copy running-config startup-config 将RAM的当前配置存储到NVRAM router#copy running-config tftp 备份RAM存储的配置信息到tftp router#copy startup-config tftp 备份NVRAM
42、配置备份到tftp router#copy flash tftp ;备份路由器的flash文件IOS到tftp router#copy tftp startup-config ;恢复NVRAM配置文件 router#copy tftp running-config 恢复NVRAM配置文件 router#copy tftp flash: 将flash文件IOS从tftp恢复到路由器 router#erase startup-config
43、 清除NVRAM存储的配置文件 ROM状态: 如果需要将路由器恢复到出厂设置要求在先启动计算机的超级终端,还原为9600波特率,在路由器上电60秒内按计算机的 Ctrl+Break 键,你将会看到rommon> Ctrl+Break ;进入ROM监控态 rommon>confreg 0x2142 ;跳过配置文件 rommon>confreg 0x2102
44、 ;恢复配置文件
rommon>reset ;重新引导
rommon>copy xmodem:
45、1.1 指定TFTP服务器IP rommon>TFTP_FILE=c2600.bin 指定下载的文件 rommon>tftpdnld ;从tftp下载 rommon>dir flash: ;查看闪存内容 rommon>boot ;引导IOS 静态路由: ip
46、route
47、uter(config)#router rip ;启动RIP动态路由协议。
router(config-router) #version 2 设置启用RIP动态路由协议为RIPV2版本
router(config-router)#network
48、config)#router eigrp
49、由表信息 帧中继命令: router(config)#frame-relay switching ;使能帧中继交换 router(config-s0)#encapsulation frame-relay ;使能封装帧中继 router(config-s0)#frame-relay lmi-type cisco ;设置lmi本地接口管理类型(11.2以上的IOS不用配置会自动分配一个lmi类型) router(config-s0)#frame-relay intf-type DCE ;设置为D
50、CE router(config-s0)#frame-relay dlci 16 ; router(config-s0)#frame-relay local-dlci 130 ;设置本地虚电路号 router(config-s0)#frame-relay interface-dlci 120 ;设置本地虚电路号 router(config-s0)#frame-relay map 10.35.35.1 110 broadcast 手动指派本地虚电路号 router(config-if)#frame-






