当前位置: 移动技术网 > 科技>操作系统>Linux > cisco 路由器的操作系统基础命令集

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

2020年01月11日  | 移动技术网科技  | 我要评论

路由器和交换机里都有操作系统,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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网