一、查询命令
1.常用的查询命令
查看当前生效的配置信息:
display current-configuration
//正在生效的配置,默认参数不显示。查看当前视图下生效的配置信息:
display this
//常用于接口视图,正在生效的配置,默认参数不显示。2.常用的正则表达式管道符“|”的使用(begin、exclude、include)
| begin 直到过滤出匹配的项目,剩下内容全部显示出来。| exclude 输出不匹配所有行。`| include 只输出匹配所有行。3.诊断信息查询
display diagnostic-information
//该命令集合了多条常用display命令的输出信息。
二、用户界面(User-interface)
常用的用户界面
1.Console(CON)用户界面
设备上一个物理接口(Console口),计算机的串口或者USB口——使用Console线连接到——通信设备的Console口——实现本地访问。
2.VTY用户界面。
虚拟类型终端(Virtual Type Terminal)是一种虚拟线路端口,使用远程登录(telnet、ssh)方式进行访问,最多支持21个用户同时访问。用户界面的用户级别(level)管理
1.Password验证,需要在用户界面配置Level。[MYWS-ui-console0]dis th
#
user-interface con 0 authentication-mode password //配置password验证user privilege level 15 //配置用户权限级别set authentication password cipher PASSWORD //设置登录密码
之前写个关于ssh配置-传送门
2.AAA验证,需要在AAA视图下配置Level。[MYWS-ui-console0]dis th
#
user-interface vty 0 4
authentication-mode aaa
//配置VTY用户认证方式为AAA认证
protocol inbound ssh
//配置VTY用户界面支持的协议为SSH协议
quitaaa
local-user NAME password irreversible-cipher PASSWORD
//创建与SSH用户同名的本地用户和对应的登录密码
local-user NAME service-type ssh
//配置本地用户的服务方式为SSH
local-user NAME privilege level (1-15)
//配置本地用户级别
quit
-------------设备命令操作-------------
[MYWS]dis user-interface //可查看到设备当前支持的用户界面以及它们的绝对编号Idx Type Tx/Rx Modem Privi ActualPrivi Auth Int
+ 0 CON 0 9600 - 3 3 N - 34 VTY 0 - 0 - P - 35 VTY 1 - 0 - P - 36 VTY 2 - 0 - P - 37 VTY 3 - 0 - P - 38 VTY 4 - 0 - P - 50 VTY 16 - 0 - P - 51 VTY 17 - 0 - P - 52 VTY 18 - 0 - P - 53 VTY 19 - 0 - P - 54 VTY 20 - 0 - P - 67 LTT 0 9600 - 0 - N - 68 LTT 1 9600 - 0 - N - 69 LTT 2 9600 - 0 - N - 70 LTT 3 9600 - 0 - N - 71 LTT 4 9600 - 0 - N - 72 LTT 5 9600 - 0 - N - 73 LTT 6 9600 - 0 - N - 74 LTT 7 9600 - 0 - N - 75 LTT 8 9600 - 0 - N - 76 LTT 9 9600 - 0 - N - 77 LTT 10 9600 - 0 - N - 78 LTT 11 9600 - 0 - N - 79 LTT 12 9600 - 0 - N - 80 LTT 13 9600 - 0 - N - 81 LTT 14 9600 - 0 - N - 82 LTT 15 9600 - 0 - N - 83 LTT 16 9600 - 0 - N -
UI(s) not in async mode -or- with no hardware support:
1-32 + : Current UI is active. //当前用户界面处于活动状态。F : Current UI is active and work in async mode. //当前用户界面是活动的,在异步模式下工作。Idx : Absolute index of UIs.//用户界面的绝对索引。Type : Type and relative index of UIs.//UI 的类型和相对索引。Privi: The privilege of UIs.//UI 的特权。ActualPrivi: The actual privilege of user-interface.//用户界面的实际特权。Auth : The authentication mode of UIs.//UI 的身份验证模式。A: Authenticate use AAA. //使用 AAA 进行身份验证。N: Current UI need not authentication. //当前用户界面不需要身份验证。P: Authenticate use current UI's password. //使用当前用户界面的密码进行身份验证。Int : The physical location of UIs.//UI 的物理位置。
三、用户界面一些小细节参数调整
1.可以根据实际使用需求设置最大数
[MYWS]user-interface ?INTEGER<0,34-48,50-54> The first user terminal interface to be configuredconsole Primary user terminal interfacecurrent The current user terminal interfacemaximum-vty The maximum number of VTY users, the default valueis 5vty The virtual user terminal interface [MYWS]user-interface maximum-vty ?INTEGER<0-15> The maximum number of VTY users, the default value is 5//VTY 用户的最大数量,默认值为5[MYWS]user-interface maximum-vty 15 //可以根据实际使用需求设置最大数2. 配置Console用户界面的物理属性(默认一般不调整:传输速率-9600 bit/s,不进行流控、不进行校验、停止位-1、数据位-8)user-interface con 0
(speed、flow-control、parity、stopbits、databits)3. 设置用户超时断连功能
user-interface con 0 或者 vty界面
[MYWS-ui-console0]idle-timeout ?INTEGER<0-35791> Set the number of minutes before a terminal user timesout(default: 10minutes)//设置终端用户超时前的分钟数(默认为10分钟)4.清除在线用户
当用户需要将某个登录用户与设备的连接断开时,可以清除指定的在线用户。
kill user-interface 参数
//清除在线用户5.用户界面通信
执行命令send 参数
//指定发送消息的用户界面,根据系统提示,输入消息并发送。
<MYWS>send ?INTEGER<0-54> Specify a user terminal interface and configure it all All user terminal interfacesconsole Primary user terminal interfacevty The virtual user terminal interface <MYWS>send all ?<cr> <MYWS>send all Enter message, end with CTRL+Z or Enter; abort with CTRL+C:
MYWS!!!
Warning: Send the message? [Y/N]:y6. 安全加固(限制那些用户能否登陆成功)比较实用
用户界面支持ACL(基本ACL(2000~2999)和高级ACL(3000~3999))。
[MYWS]user-interface vty 0 4
[MYWS-ui-vty0-4]acl ?INTEGER<2000-3999> Apply basic or advanced ACLipv6 Filter IPv6 addresses[MYWS-ui-vty0-4]acl ?
[MYWS-ui-vty0-4]acl 2000 ?inbound Filter login connections from the current user interfaceoutbound Filter logout connections from the current user interface[MYWS-ui-vty0-4]acl 2000
这个ACL的inbound、outbound比较关键。请看图
四、检查配置结果
也是运维过程中常见的手段方法。
display users all
//查看用户界面的使用信息。
display user-interface console 0
//查看Console用户界面信息。
display user-interface maximum-vty
//查看VTY类型用户界面的最大个数。
display user-interface vty 0
//查看VTY用户界面信息。
display ssh server ip-block all
//查看所有认证失败的客户端IP地址。
display ssh server ip-block list
//查看因认证失败而被锁定的客户端IP地址。
display vty ip-block list
//查看因为认证失败而被阻止的IP地址列表。
display vty ip-block all
//查看所有认证失败的IP地址。
display vty mode
//查看VTY的工作模式。