思科设备基础命令配置

发布时间:2021-02-05    浏览量:

以下是在微思CCNA培训时做的笔记,这些命令还是比较常用的,希望对大家有所帮助。

1.思科设备的基本命令模式:
   --- System Configuration Dialog --- 
#路由器初始启动(交换机无此现象)
Continue with configuration dialog? [yes/no]: n #跳出对话配置模式
Press RETURN to get started!
Router>       #用户模式
Router>enable  #进入到特权模式
Router#disable  #返回到用户模式
Router>enable  
Router#       #特权模式
Router#configure terminal  #进入全局配置模式
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#  #全局配置模式
2.帮助命令的使用:
Router>enable 
Router#cl?      #字符后输入?,表示当前模式下以此字符开始的所有命令
clear  clock  
Router#clock ?  #空格之后?表示这个命令后面可以输入的所有命令
  read-calendar Read the hardware calendar into the clock
  set           Set the time and date
  update-calendar Update the hardware calendar from the clock
Router#clock
3.错误提示:
Router#e     
% Ambiguous command:  "e" #模糊命令 设备不识别
Router#clock 
% Incomplete command. #不完整命令 后面还有命令需要键入
Router#clock sat
              ^
% Invalid input detected at '^' marker.#无效输入在标记处 不可用命令
4.补全命令和缩写命令
当字符后直接输入?出现唯一的命令时,即可用此字符代替整个命令,同时按TAB键可以补全此命令。
Router#s?
*s=show  sdlc   send   set
setup    show    slip spec-file
ssh  start-chat  systat  
Router#sh?
show  
Router#sh
例如:
sh 可以代替 show 命令 ,输入sh后按TAB可以补全为show
5.密码配置
Router#conf t
Router(config)#enable password cisco   #进入特权模式密码
Router(config)#enable secret ccna      #进入特权模式加密密码,同时存在时优先使用secret 密码
Router(config)#
Router#sh run | in enable
enable secret 5 $1$.Gb2$gnGAVh9OmBDztBFxnv1MD/
enable password cisco
Router#conf t
Router(config)#service password-encryption  #明文密码封装
Router#sh run | in enable
enable secret 5 $1$.Gb2$gnGAVh9OmBDztBFxnv1MD/
enable password 7 121A0C041104

Router(config)#
Router(config)#line console 0  #控制台密码设置
Router(config-line)#password cisco
Router(config-line)#login
Router(config-line)#exi

Router(config)#line vty 0 4  #虚拟终端密码设置(telnet密码)
Router(config-line)#password cisco
Router(config-line)#login 
Router(config-line)#exi
6:常用命令
R1(config)#
R1(config)#hostname ?    #配置设备的名称
  WORD  This system's network name
R1(config)#hostname r1 
r1(config)#hostname R1
R1(config)#no ip domain-lookup  #关闭设备域名查找功能
R1(config)#line console 0
R1(config-line)#logging synchronous #开启日志同步功能,输入命令时不会被日志打断
R1(config-line)#exec-timeout ?    #console接口配置超时时间
  <0-35791>  Timeout in minutes
R1(config-line)#exec-timeout 0 ?
  <0-2147483>  Timeout in seconds
  <cr>
R1(config-line)#exec-timeout 0 0   #console接口配置永远不超时
R1(config-line)#exit    #返回命令,每次返回一级
R1(config)#end       #返回命令,直接回到特权模式
R1#
R1(config)#banner motd $  #配置登录标语,类似于’声明’
Enter TEXT message.  End with the character '$'
this is cisco r&s $
R1(config)#
R1(config)#interface FastEthernet 0/0        #进入接口
R1(config-if)#description link-to-r2-e0/0  #设置接口描述信息
R1(config-if)#duplex ?   #配置接口双工模式
  full  Force full duplex operation
  half  Force half-duplex operation
R1(config-if)#duplex full    #配置为全双工
R1(config-if)#speed 100     #配置端口速率为100
R1(config-if)#no shutdown   #开启接口
R1(config-if)#exit
R1(config)#exit
R1#
R1#copy running-config startup-config #保存配置文件(标准命令)
Destination filename [startup-config]? 
Building configuration...
[OK]
R1#write   #保存配置文件(快捷命令)
Building configuration...
[OK]
R1#reload     #重启设备
R1#erase startup-config   #清除设备启动配置文件
7.接口IP地址配置
R1(config)#interface serial 2/0     #配置串口IP地址
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface Fastethernet 0/0   #配置以太口IP地址
R1(config-if)#ip add 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exi
R1(config)#interface loopback 0    #配置环回接口IP地址
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exi
R1(config)#
8.常用SHOW命令
R1#show running-config     #查看当前配置
R1#show startup-config      #查看启动配置
R1#show flash:             #查看FLASH 
R1#show interfaces ethernet 0/0   #查看接口信息
R1#show ip interface brief        #简要显示接口信息
R1#show ip interface brief | ex un  #只显示配置IP的接口信息
R1(config)#do sh run    #在除特权模式下使用SHOW命令需要加DO
9.测试工具命令
R1#ping 192.168.12.2       #连通性测试
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/27/32 ms
R1#
R1#traceroute 192.168.12.2    #路由跟踪,记录到达目的地经过的每一跳路由器
Type escape sequence to abort.
Tracing the route to 192.168.12.2
  1 192.168.12.2 12 msec *  8 msec
R1#
R1#telnet 192.168.12.2       # 远程登录访问设备
Trying 192.168.12.2 ... Open
User Access Verification
Password: 
R2>enable
Password: 
R2#

微思网络总部
福建省厦门市思明区金山大厦
查看路线
微思网络集美分部
福建省厦门市集美区集美区浒...
查看路线
定位
点击左侧的按钮进行定位