交换机与路由器配置命令汇总

  • 格式:doc
  • 大小:46.50 KB
  • 文档页数:6

交换机与路由器配置命令汇总交换机1.交换机的配置模式(1)用户模式sw>(2)特权模式sw>enable(3)全局配置模式sw#config terminal(4)接口配置模式sw(config)#interface f0/0(5)链路模式sw(config)#line console 02.交换机与路由器的一些实用命令(1)配置超时R(config)#line console 0R(config-line)#exec-timeout 0 0 (永不超时)(2)日志同步R(config)#line console 0R(config-line)#logging synchronous(3)禁用DNSR(config)#no ip domain-lookup3.交换机的show命令(1)sw#show mac-address-table 查看mac地址表(2)sw#show running-config 查看配置信息,RAM与NVRAM中sw#show startup-config(3)sw#show cdp 显示设备的cdp全局配置信息sw#show cdp interface f0/1 显示了f0/1接口的cdp配置信息sw#show cdp traffic 显示了有关cdp包的统计信息sw#show cdp neighborssw#show cdp neighbors detailsw#show cdp entry * 显示所有入口项的细节(4)验证接口模式sw#show interface interface-id trunksw#show interface interface-id switchport(5)验证VLAN的配置sw#show vlan brief (2950)sw#show vlan-switch brief (3640)sw#show vlan id vlan-id4.交换机配置的保存sw#copy running-config startup-configsw#write5.恢复出厂设置sw#erase startup-configsw#reload6.交换机的基本配置(1)主机名的配置sw(config)#hostname benetbenet(config)#(2)特权模式密码的配置sw(config)#enable password 123 明文sw(config)#enable secret 456 加密同时配置时,加密的使能口令在登录时生效(3)用户模式密码的配置sw(config)#line console 0sw(config-line)#password 123sw(config-line)#loginsw(config-line)#exit(4)telnet远程登录的密码配置sw(config)#line vty 0 4sw(config-line)#password 456sw(config-line)#loginsw(config-line)#exit(5)IP地址的配置(便于对交换机进行远程管理)sw(config)#interface vlan 1sw(config-if)#ip address 192.168.0.1 255.255.255.0sw(config-if)#no shutdown(6)交换机网关的配置sw(config)#ip default-gateway 192.168.0.1当管理工作的位置与交换机不在同一网段时,需要为交换机配置网关7.静态VLAN的配置(1)在VLAN数据库中创建VLANsw#vlan databasesw(vlan)#vlan vlan-id name vlan-name(2)删除VLANsw#vlan databasesw(vlan)#no vlan vlan-id(3)在VLAN中添加端口sw(config)#interface interface-idsw(config-if)#switchport access vlan vlan-id(4)在VLAN中删除端口sw(config)#default interface interface-id或者sw(config-if)#no switchport access vlan vlan-id8.VLAN Trunk的配置(1)配置接口为Trunk模式sw(config)#interface interface-idsw(config-if)#switchport mode trunk(2)配置接口为动态协商模式sw(config)#interface interface-idsw(config-if)#switchport mode dynamic desirable/auto(3)从Trunk中移除某个VLANsw(config)#interface interface-idsw(config-if)#switchport trunk allowed vlan remove vlan-list(4)在Trunk上添加某个VLANsw(config)#interface interface-idsw(config-if)#switchport trunk allowed vlan add vlan-list 9.交换机的密码恢复 2950系列1)拔下交换机电源2)按MODE,接上电源3)出现switch:时松开MODE键4)switch:flash_init5)switch:dir flash:6)switch:rename flash:config.text flash:config.old7)switch:boot8)switch#dir flash9)switch#rename flash:config.old flash:config.text10)switch#copy flash:config.text running-config11)重新配置密码并保存路由器1.路由器的配置模式(1)用户模式R>(2)特权模式R>enableR#(3)全局配置模式R#config terminalR(config)#(4)接口配置模式R(config)#interface interface-idR(config-if)#(5)子接口模式R(config)#interface f0/0.1R(config-subif)#(6)链路模式R(config)#line console 0R(config-line)#(7)路由模式R(config)#router ripR(config-router)#2.show命令(1)查看某个接口的状态R#show interface f0/0(2)查看路由表R#show ip route(3)查看端口状态R#show ip interface brief(4)查看路由表版本,串口信息R#show versionR#show controllers serial1/0(5)查看路由协议配置R#show ip protocol(6)使用RIP协议调试命令查看RIP路由更新过程R#debug ip rip3.路由器的一般配置(1)主机名配置R(config)#hostname Benet(2)路由标识配置R(config)#banner motd $...$(3)接口标识配置R(config)#interface f0/0R(config-if)#description ...(4)控制台密码R(config)#line console 0R(config-line)#password 123R(config-line)#loginR(config-line)#exit(5)特权模式密码R(config)#enable password 123(6)加密保存的密码R(config)#enable secret 456(7)给所有密码加密R(config)#service password-encryption4.路由器的其它配置(1)配置DCE时钟(接口为串口时配置)R(config-if)#clock rate 64000(2)配置loopback地址(做测试用)R(config)#interface loopback 0R(config-if)#ip address 192.168.0.10 255.255.255.0R(config-if)#no shutdown(3)半、全双工配置sw(config)#interface f0/0sw(config-if)#speed 10/100sw(config-if)#duplex half/fullR(config)#interface e0/0R(config-if)#duplex half/full5.单臂路由的配置R(config)#interface e0/0R(config-if)#no shutdownR(config)#interface e0/0.1R(config-subif)#encapsulation dot1Q 1R(config-subif)#ip address 192.168.0.1 255.255.255.0(Vlan的网关地址)6.静态路由的配置(1)添加R(config)#ip route network mask address 目标网络地址子网掩码下一跳地址(2)删除7.默认路由的配置R(config)#ip route 0.0.0.0 0.0.0.0 address8.动态路由(1)RIPv1 不支持不连续的子网,宣告路由信息时不携带网络掩码R(config)#router ripR(config-router)#network 192.168.0.0 (直连网络的网络地址)(2)RIPv2 支持不连续的子网,宣告信息是携带网络掩码R(config)#router ripR(config-router)#version 2R(config-router)#no auto-summaryR(config-router)#network 10.10.0.09.路由器的密码恢复Cisco2500(1)重启路由器,在60S内按下Ctrl+Break键,使路由进入ROM Monitor模式(2)rommon1>o/r 0x2142rommon2>boot(3)重启进入EXEC模式R>enableR#copy startup-config running-configR#config terminalR(config)#enable password ciscoR(config)#config-register 0x2102(4)R#copy running-config startup-configR#reloadCisco2600(1)重启路由器,在60S内按下Ctrl+Break键,使路由进入ROM Monitor模式(2)rommon1>confreg 0x2142rommon2>reset(3)重启进入EXEC模式R>enableR#copy startup-config running-configR#config terminalR(config)#enable password ciscoR(config)#config-register 0x2102(4)R#copy running-config startup-configR#reload10.TFTP在Cisco设备上的应用(1)确认电脑与路由的接口能ping通(需要用console线与交叉线,分别用来配置路由器与数据传输) R(config)#enable secret ciscoR(config)#line vty 0 4R(config-line)#password ciscolabR(config-line)#loginR(config-line)#exitR(config-if)#ip add 192.168.0.1 255.255.255.0 (一般用主机的网关地址)R(config-if)#no shutdownR#ping 192.168.0.123 (主机的IP地址)Ping通则可以进行下一步操作(2)打开Cisco TFTP Server,修改文件保存位置(3)上传和下载路由器的IOS和配置文件R#dir flash: 查看文件名称将路由器flash中的IOS软件通过TFTP复制到主机192.168.0.123中,目的是用来备份路由器的IOS. R#copy flash: tftp:Source filename []? c2600.mz.123-e.binAddress or name of remote hose []? 192.168.0.123将路由器flash中的IOS软件通过TFTP上传到路由器中,目的是用来升级路由器的IOS版本.R#copy tftp: flash:Source filename []? C2600.mz.123-e.binAddress or name of remote hose []? 192.168.0.123下载路由器的配置文件,目的是备份配置文件.R#copy startup-config tftp:R#copy running-config tftp:上传配置文件到路由器.R#copy tftp: startup-configR#copy tftp: running-config。