IOS指令的工作模式:
用户模式 >
特权模式 #
全局模式 (config)#
其他模式 (config-if)# 接口模式
(config-line)# 线路模式
(config-route)# 路由模式
> 用户 (读)
# 特权 (读、写)
(config)# 全局 (写)
> enable (进入特权模式的指令)
#
# configure terminal (进入全局模式的指令)
(config)#
(config)# exit (退回到特权模式)
或者
(config)# 按ctrl + z键 (退回到特权模式)
# disable (退回到用户模式)
>
> exit (关闭当前会话)
# exit (关闭当前会话)
# show version (查看设备基本信息)
# show running-config (查看正在运行的配置文件)
# show interface (查看所有接口状态)
# show interface [interface name] (查看指定接口状态)
例:
# show interface f 0/12 (查看f0/12接口状态)
# show interface serial 0/0 (查看s0/0接口状态)
# show ip int brief (查看所有接口的IP地址设置状况及接口状态)
# show clock (查看设备的时间、日期、年份的设置)
(config)# hostname [主机名] (更改设备主机名)
给设备定义时间、日期、年份:
(config)# clock timezone [时区名称] [时区范围] (设置时区)
# clock set [时间] [日期] [月份(英文表示)] [年份] (设置时间)
2900系列以上交换机设置IP地址
(config)# interface vlan 1 (进入VLAN 1 接口)
(config-if)# ip address [IP地址] [掩码] (设置IP地址)
(config-if)# no shutdown (打开该接口)
(config-if)# exit (返回到全局模式)
(config)#
Router设置IP地址
(config)# interface [接口名] (进入接口)
(config-if)# ip address [IP地址] [掩码] (设置IP地址)
(config-if)# no shutdown (打开该接口)
(config-if)# exit (返回到全局模式)
(config)#
以下的内容适用于2900以上Switch和Router:
定义从用户模式进入特权模式的口令:
(config)# enable password [口令] (设置明文口令)
(config)# enable secret [口令] (设置密文口令)
定义Console接口的口令
(config)# line con 0 (进入控制接口)
(config-line)# password [口令] (设置口令)
(config-line)# login (设置口令生效)
(config-line)# exit (返回到全局模式)
(config)#
s1#
定义Auxiliary接口的口令
(config)# line aux 0 (进入辅助接口)
(config-line)# password [口令] (设置口令)
(config-line)# login (设置口令生效)
(config-line)# exit (返回到特权模式)
(config)#
定义Telnet用户接口的口令
(config)# line vty 0 4 (进入vty接口)
(config-line)# password [口令] (设置口令)
(config-line)# login (设置口令生效)
(config-line)# exit (返回到特权模式)
(config)#
[0 4] 是指最多允许5位用户对设备进行Telnet登陆)
(config)# service password-encryption (让明文口令加密)
(config)# username [用户名] password [口令] (定义本地安全数据库)
(config)# line vty 0 4 (进入vty接口)
(config-line)# login local (使定义的本地用户名和口令生效)
(config)# line con 0 (进入con接口)
(config-line)# login local (使定义的本地用户名和口令生效)
(config)# banner motd # (定义启动显示文本)
以下的内容适用于2900以上Switch和Router:
(config)# line con 0
(config-line)# logging synchronous (定义命令同步)
(config-line)# exec-timeout 0 0 (定义会话超时时间)
(config-line)# exit
(config)#
(config)# line vty 0 4
(config-line)# logging synchronous (定义命令同步)
(config-line)# exec-timeout 0 0 (定义会话超时时间)
(config-line)# exit
(config)#
Router上的指令
# show controller [串行接口编号]
(查看该接口连接的是DTE线缆还是DCE线缆)
如果串行接口连接的是DCE线缆,则需要定义时钟
> enable
# conf t
(config)# interface [串行接口编号] (进入串行接口)
(config-if)# clock rate 64000 (定义时钟频率)
(config-if)# exit (返回到全局模式)
(config)#
# show interface [接口号]
Serial0/0 is up, line protocol is up
(代表该接口可以正常使用)
Serial0/0 is up, line protocol is down
(两端协议不匹配) HDLC ---------- PPP
(串行DCE接口没有设置时钟)
Serial0/0 is down, line protocol is down
(线缆故障)
(对端设备接口没有打开,或对端设备关闭电源)
Serial0/0 is administratively down, line protocol is down
(人为将接口关闭,通过指令可以打开)
# show interfaces fastEthernet 0/0
FastEthernet0/0 is administratively down, line protocol is down
(config)# no ip domain-lookup (关闭域名解析)
(config)# ip host [主机名] [主机IP地址] (建立静态映射)
# show host
# copy running-config startup-config (保存配置)
# show running-config (查看正在运行的配置文件)
# show startup-config (查看启动配置文件)
# erase startup-config (清空配置文件)
# reload (重新启动)
1900系列交换机设置IP地址
(config)# ip address [IP地址] [掩码] (设置IP地址)
1900系列交换机设置口令
设置enable口令、Telnet口令
(config)#enable password level 15 [口令] (明文口令)
(config)#enable secret [口令] (密文口令)
(config)#enable password level 15 12345
(config)#enable secret cisco
1900系列Switch的清空配置的指令:
# delete nvram
使用SDM配置路由器
(config)# ip http server
(config)# ip http authentication local
(config)# username [用户名] privilege 15 secret [口令]
(config)# line vty 0 4
(config-line)# privilege level 15
(config-line)# login local