命令行界面是指可在设备上输入可执行命令的界面。
一,命令行视图
<>为用户视图,在该视图可以使用display查看设备,协议,接口等状态,也可以使用ping,tracert等测试命令,某些命令如reboot(重启),reset等重置状态的命令必须在用户视图应用。
进入其他视图的基础是要先进入系统视图。
<Huawei>system-view //进入系统视图
[Huawei]interface GigabitEthernet 0/0/0 //进入接口视图
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.1 255.255.255.0 //配置接口IP地址
[Huawei-GigabitEthernet0/0/0]quit //退出命令
[Huawei]ospf //进入协议视图(ospf协议为例)
[Huawei-ospf-1]
二,常用快捷键
命令 | 功能 |
ctrl+A | 把光标移到当前命令行的最前端 |
ctrl+E | 把光标移到当前命令行的最尾端 |
ctrl+C | 停止当前命令的运行 |
ctrl+Z | 直接回到用户视图 |
ctrl+] | 终止当前连接或切换连接,如终止Telent |
ctrl+U | 删除整行命令行 |
Backspace | 删除光标左边的第一个字符 |
← or ctrl+B | 光标向左移动 |
→ or ctrl+F | 光标向右移动 |
Tab | 补全不完整的命令 |
三,登录和管理设备
1.通过Console端口登录和管理设备
通过Console端口管理设备,出于安全考虑可以设置密码认证登录:
[Huawei]user-interface console 0 //进入端口模式
[Huawei-ui-console0]authentication-mode password //设置认证模式为密码认证
[Huawei-ui-console0]set authentication password cipher huawei //设置密码为huawei
通过Telnet登录设备和管理设备
Telnet是最常见最灵活的远程管理网络设备管理的协议,该协议使用的端口号为23。Telnet是一种明文传输的协议,在安全性上不如SSH。
例:
首先保证设备之间网络的连通性。
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.6.1 255.255.255.0
-----------------------------------------------------------------------------------------
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.6.6 24 //子网掩码可以写成24
[R2]ping 192.168.6.1 //通过ping验证两台设备是否连通
PING 192.168.6.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.6.1: bytes=56 Sequence=1 ttl=255 time=130 ms
Reply from 192.168.6.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.6.1: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 192.168.6.1: bytes=56 Sequence=4 ttl=255 time=10 ms
Reply from 192.168.6.1: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 192.168.6.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/42/130 ms
[R2]
设置远程登录密码
[R1]user-interface vty 0 4 //进入用户虚拟终端端口,序号为0~4
[R1-ui-vty0-4]set authentication password cipher huawei //设置密码为华为
[R1-ui-vty0-4]user privilege level 15 //设置用户权限为15
[R1-ui-vty0-4]
通过R2进行验证
<R2>
<R2>
<R2>telnet 192.168.6.1
Press CTRL_] to quit telnet mode
Trying 192.168.6.1 ...
Connected to 192.168.6.1 ...
Login authentication
Password:
<R1>
<R1>
<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]
四, 配置系统时钟
<R1>clock timezone BJ add 8 //调整时区为北京+8区
<R1>clock datetime 0:40:15 2022-3-23 //设置时间
<R1>display clock //验证时间是否调整成功
2022-03-23 00:40:21
Wednesday
Time Zone(BJ) : UTC+08:00
<R1>
五,配制标题信息
常使用有一下三个标题消息参数。
- header参数:用来设置用户登录设备时在终端上显示标题信息。(内容可以是字符串或文件名 )
- login参数:指定用户在登录设备认证过程中激活终端连接时显示的标题信息。
- shell参数:指定当前用户成功登录设备并已经建立会话时显示的标题信息。
header {login|shell} information text命令能设置字符串形式的header。
[R1]header login information "hahahahahhaha" //配置远程用户登陆前的信息,引号内为内容
[R1]header shell information "heiheiheiheihei" //设置用户登录后可以看到的信息
[R1]
<R2>telnet 192.168.6.1
Press CTRL_] to quit telnet mode
Trying 192.168.6.1 ...
Connected to 192.168.6.1 ...
hahahahahhaha //这是登录时显示的信息
Login authentication
Password:
heiheiheiheihei //这是登陆后显示的内容
<R1>
六, 命令行等级划分
系统等级划分进行分级管理,来增加设备的安全性。默认,命令级别分为0~3级,用户级别分为0~15级。
用户级别 | 命令等级 | 名称 |
0 | 0 | 访问级 |
1 | 0,1 | 监控级 |
2 | 0,1,2 | 配置级 |
3~15 | 0,1,2,3 | 管理级 |
七, vrp文件系统
vrp文件系统是用来管理存放于储存器上的系统文件(如vrp的系统镜像),配置文件等系统,它是vrp正常运行的基础。
常见的储存设备包括Flash卡,SD卡,CF卡。
通常命名文件的规则:用一系列字符串组成文件名,不支持空格,不区分大小写。
VRP文件系统基本命令操作:
<R1>dir //dir显示当前目录下文件信息,其中第二列“Attr”中d表示文件目录;r表示可读;w表示可写入
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - Mar 23 2022 15:15:46 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 Mar 23 2022 15:15:36 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
1,090,732 KB total (784,464 KB free)
<R1>
--------------------------------------------------------------------------------------
<R1>cd dhcp/ //进入dhcp目录
<R1>pwd //查看当前目录
flash:/dhcp
<R1>more dh
<R1>more dhcp-duid.txt //查看文本文件的具体内容
*Huawei DHCP DUID*
*time* 2022-03-23 23:15:46
*version* 1
#DUID_LL: 0003000100E0FCFB4DB9
*end*
<R1>mkdir haha //创建haha文件
Info: Create directory flash:/dhcp/haha......Done
<R1>rmdir haha //删除haha文件
Remove directory flash:/dhcp/haha? (y/n)[n]:y
%Removing directory flash:/dhcp/haha...Done!
<R1>
---------------------------------------------------------------------------------------
<R1>copy dhcp-duid.txt test.txt //复制文件
Copy flash:/dhcp/dhcp-duid.txt to flash:/dhcp/test.txt? (y/n)[n]:y
100% complete
Info: Copied file flash:/dhcp/dhcp-duid.txt to flash:/dhcp/test.txt...Done
<R1>rename test.txt haha.txt //重命名
Rename flash:/dhcp/test.txt to flash:/dhcp/haha.txt? (y/n)[n]:y
Info: Rename file flash:/dhcp/test.txt to flash:/dhcp/haha.txt ......Done
<R1>delete haha.txt //删除文件
Delete flash:/dhcp/haha.txt? (y/n)[n]:y
Info: Deleting file flash:/dhcp/haha.txt...succeed.
<R1>undelete haha.txt //恢复删除的文件
(还有unreserved永久删除文件,reset recycle-bin彻底删除回收站中的文件,move移动文件)
八,配置文件管理
VRP设备上配置文件分为一下两种类型:
- 正在运行的配置文件;
- 保存的配置文件。
常见的快捷验证配置命令
命令 | 功能 |
display current-configuration | 显示当前配置文件 |
display saved-configuration | 显示保存的配置文件 |
display this | 显示当前模式的配置内容 |
[haha-GigabitEthernet0/0/0]display this //查看接口的配置
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 192.168.6.6 255.255.255.0
#
return
[haha-GigabitEthernet0/0/0]
-----------------------------------------------------------------------------------------
[haha]display current-configuration //查看当前所有的配置命令
[V200R003C00]
#
sysname haha
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface Ethernet0/0/0
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
---- More ----
-------------------------------------------------------------------------------------
[haha]display current-configuration configuration aaa //查看aaa的配置
[V200R003C00]
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
(startup saved-configuration+文件名 指定启动配置文件)