cisco 路由器的操作系统基础命令集

路由器和交换机里都有操作系统,cisco的操作系统叫ios。
怪不得路由器贵,原来也是带操作系统的机器啊,以前真是小白。

ios里的几种模式

1,>:用户模式:啥也干不了。

2,#:特权模式:用于检验在全局模式里的配置是否生效了。下面的R1是路由器的名字(是在GNS3里设置的)。

从用户模式进入特权模式enable

R1>enable
R1#

3,R1(config):全局模式。在特权模式里,输入:configure terminal,就能进入全局模式。

R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#

4,接口模式:也属于全局模式。从全局模式进入接口模式,输入:interface f0/0。0/0就是接口的编号。

R1(config)#interface f0/0
R1(config-if)#

第一个0是代表0号slot(插槽);第二个0代表第一个接口。所以0/0就是0号slot上的0号接口。slot上有多个接口。

ios操作系统的命令简介:

  • 问号作用:显示所以可用的选择。

    R1#e?
    enable  erase  event  exit
  • 给接口分配ip地址:在接口模式里,输入ip address 192.168.1.1 255.255.255.0接口默认是关闭的,即使分配ip地址,还是关闭的,所以需要打开接口。

    R1(config-if)#ip address 192.168.1.1 255.255.255.0
    R1(config-if)#

    命令执行完,如果没有任何反馈信息,则说明命令执行成功!

  • 打开接口:在接口模式,输入:no shutdown。回到特权模式,输入ping 192.168.1.1,发现接口通了。

    R1(config-if)#no shutdown
    R1(config-if)#end
    R1#ping 192.168.1.1
    
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
  • 返回上一级:exit

    R1(config-if)#exit
    R1(config)#exit
    R1#
  • 回到特权模式:end

    R1(config-if)#end
    R1#
  • 查看路由器里的所有的配置:在特权模式输入show runshow running-config的缩写。

    R1#show running-config
    interface FastEthernet0/0
     ip address 192.168.1.1 255.255.255.0
     duplex auto
     speed auto
    !
    interface FastEthernet1/0
     no ip address
     shutdown
     duplex auto
     speed auto
    • 显示接口FastEthernet0/0的ip和子网掩码都有了,而且是全双工(duplex auto)
    • 显示接口FastEthernet1/0没有ip地址,而且是关闭(shutdown)的状态。
  • 只查看接口ip的信息:show ip interface brief

    R1#show ip interface brief
    Interface                  IP-Address      OK? Method Status                Protocol
    FastEthernet0/0            192.168.1.1     YES manual up                    up
    FastEthernet1/0            unassigned      YES unset  administratively down down
  • 修改route的名字:hostname NAME

    R1(config)#hostname R11
    R11(config)#hostname R1
    R1(config)#
  • 设置进入特权模式的密码:在全局模式输入:enable password xxxx

    R1(config)#enable password 123
    R1(config)#

    有个弊端,运行show run后,发现密码显示出来了。会被别人看到,不安全。

    !
    enable password 123
    !
  • 删掉进入特权模式的密码:在全局模式输入:no enable password

    R1(config)#no enable password
    R1(config)#
  • 撤销命令的用法:在原来的命令前加no,基本适用所有命令。

  • 设置进入特权模式的密码,而且在show run后,不显示密码:在全局模式输入:enable secret xxxx

    R1(config)#enable secret 123
    R1(config)#exit
    R1#show run
    !
    enable secret 5 $1$oL3d$BsBEm.qcwFcUUxRNNqSjN/
    !
  • 强行退出执行中的进程的快捷键:ctrl+shift+6。相当于linux里的ctrl+c

  • 回到特权模式的快捷键:ctrl+z。相当于end

  • 放弃当前输入的命令:ctrl+c

工程3招

  • 关闭域名解析,在全局模式输入:no ip domain lookup;打开域名解析,在全局模式输入:ip domain lookup。关闭域名解析后,当在特权模式,随便输入一些字母,回车后,这些字母就不会被当做域名去让dns去解析了。以防止小白输入了错的命令后,ios把错误的命令里的字符粗当成了域名,去让dns去解析了。但是调试完路由器后,一定要打开域名解析,否则就无法上网了。

  • 让输入的命令和信息同步:挺有用的。

    第一步:line console 0

    第二部:logging synchronous

    R1(config)#line console 0
    R1(config-line)#logging synchronous
  • 关闭超时自动退出功能,在R1(config-line)模式输入:#no exec-timeout

    去到客户那里后,路由器的密码客户会告诉你,然后客户就走了,你调试可能需要好几个小时,比如中午出去吃的饭,回来发现因为超时,自动退出了,你还的去问客户密码,挺麻烦的,所以关闭超时自动退出功能。

c/c++ 学习互助QQ群:877684253

本人微信:xiaoshitou5854

猜你喜欢

转载自www.cnblogs.com/xiaoshiwang/p/12177587.html