路由器和交换机里都有操做系统,cisco的操做系统叫ios。
怪不得路由器贵,原来也是带操做系统的机器啊,之前真是小白。linux
1,>:用户模式:啥也干不了。ios
2,#:特权模式:用于检验在全局模式里的配置是否生效了。下面的R1是路由器的名字(是在GNS3里设置的)。c++
从用户模式进入特权模式enable
shell
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上有多个接口。dom
问号做用:显示因此可用的选择。学习
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)#
命令执行完,若是没有任何反馈信息,则说明命令执行成功!3d
打开接口:在接口模式,输入: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 run
是show 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
只查看接口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
关闭域名解析,在全局模式输入: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
去到客户那里后,路由器的密码客户会告诉你,而后客户就走了,你调试可能须要好几个小时,好比中午出去吃的饭,回来发现由于超时,自动退出了,你还的去问客户密码,挺麻烦的,因此关闭超时自动退出功能。