华为VRP基本操作之命令行基础

3.2 VRP命令行基础

命令行界面CLI(Command Line Interface)是用户与设备进行交互的常用工具。用户登录到路由器出现命令行提示符后,即进入命令行界面。

3.2.1命令行视图

  1. VRP启动程序

     管理员和工程师如果要访问在通用路由平台VRP上运行的华为产品,首先要进入启动程序。如图3-8开机界面信息提供了系统启动的运行程序和正在运行的VRP版本及其加载路径。启动完成以后,系统提示目前正在运行的是自动配置模式。用户可以选择是继续使用自动配置模式或是进入手动配置的模式。如果选择手动配置模式,在提示符处输入Y。在没有特别要求的情况下,我们选择手动配置模式。

图3-8 VRP启动界面

  1. VRP视图结构

     VRP命令结构定义了很多命令行视图,如图3-9所示,每条命令只能在特定的视图中执行。每个命令都注册在一个或多个命令视图下,用户只有先进入这个命令所在的视图,才能运行相应的命令。进入到VRP系统的配置界面后,VRP上最先出现的视图是用户视图。在该视图下,用户可以查看设备的运行状态和统计信息。若要修改系统参数,用户必须进入系统视图。用户还可以通过系统视图进入其他的功能配置视图,如接口视图和协议视图。通过提示符可以判断当前所处的视图。

图3-9 VRP视图结构

用户视图:程序启动成功后的见到的第一个界面用”<  >“标识

系统视图:在用户视图中输入system-view 命令进行切换,系统视图用”[  ]”标识。

3.2.2命令行功能和在线帮助

  1. 常用快捷键

     为了简化操作,系统提供了快捷键,使用户能够快速执行操作。表3-1中列举了系统定义的快捷键。

表3-1 常用快捷键

  1. 命令行在线帮助

VRP提供两种帮助功能,分别是部分帮助和完全帮助,如图3-10所示,部分帮助指的是,当用户输入命令时,如果只记得此命令关键字的开头一个或几个字符,可以使用命令行的部分帮助获取以该字符串开头的所有关键字的提示,如本例中所示。完全帮助指的是,在任一命令视图下,用户可以键入”?”获取该命令视图下所有的命令及其简单描述;如果键入一条命令关键字,后接以空格分隔的”?”,如果该位置为关键字,则列出全部关键字及其描述。

图3-10 命令行帮助

3.2.3 命令级别

系统将命令进行分级管理,以增加设备的安全性。设备管理员可以设置用户级别,一定级别的用户可以使用对应级别的命令行。缺省情况下命令级别分为0~3级,用户级别分为0~15级,详情见表2-3,用户0级为访问级别。用户1级为监控级别,对应命令级0、1级,包括用于系统维护的命令以及display等命令。用户2级是配置级别,包括向用户提供直接网络服务,包括路由、各个网络层次的命令。用户3-15级是管理级别,对应命令3级,该级别主要是用于系统运行的命令,对业务提供支撑作用,包括文件系统、FTP、TFTP下载、文件交换配置、电源供应控制,备份板控制、用户管理、命令级别设置、系统内部参数设置以及用于业务故障诊断的debugging命令。在具体使用中,如果我们有多个管理员帐号,但只允许某一个管理员保存系统配置,则可以将save命令的级别提高到4级,并定义只有该管理员有4级权限。这样,在不影响其他用户的情况下,可以实现对命令的使用控制。

表3-2命令级别

在文章最后加作者VX:可以免费领取以下资料

3.3  VRP基本操作

在本节中,我们将通过一个实例来完成VRP的一些最基本的操作,如图3-11所示:

图3-11 VRP的基本操作

  1. 熟悉VRP的视图

<Huawei>    //用户视图

<Huawei>system-view   //从用户视图进入到系统视图

Enter system view, return user view with Ctrl+Z.

[Huawei]      //[ ] 代表系统视图

[Huawei]interface GigabitEthernet 0/0/0  //从系统视图进入到接口视图

[Huawei-GigabitEthernet0/0/0]ip add      //我们只输入“ip add”,然后按Tab键,就可以补全“address”

[Huawei-GigabitEthernet0/0/0]ip address 10.1.1.1 24  //配置接口IP地址为10.1.1.1 ,掩码长度为24位。

[Huawei-GigabitEthernet0/0/0]quit  //quit命令是VRP系统中的退出当前层级命令。

[Huawei]ospf   // 进入到ospf协议视图

[Huawei-ospf-1]  // ospf是我们后面要学习的一个非常重要的动态路由协议,此处仅作为一个示例。

【技术要点1】

Tab键的使用:如果与之匹配的关键字唯一,按下<Tab>键,系统自动补全关键字,补全后,反复按<Tab>关键字不变。示例如下:

[Huawei] info-                            //按下Tab键

[Huawei] info-center

【技术要点2】

  退出命令我们可以用quit、return、和快捷键“Ctrl+z”。

  • Quit命令仅可以返回上一个视图
  • Return命令直接返回到用户视图
  • 快捷键“Ctrl+z”和return一样

  1. 给设备命名

[Huawei]sysname joinlabs    //更改系统名为joinlabs

[joinlabs]          //读者可以看到系统名由Huwei变成了joinlabs

  1. 查看当前运行的配置文件

<joinlabs>display current-configuration    //查看当前运行的配置文件

#

sysname joinlabs  //系统名为joinlabs

#

aaa

 authentication-scheme default

 authorization-scheme default

 accounting-scheme default

 domain default

 domain default_admin

 local-user admin password cipher OOCM4m($F4ajUn1vMEIBNUw#

 local-user admin service-type http

#

firewall zone Local

 priority 16

#

interface Ethernet0/0/0

#

interface Ethernet0/0/1

#

interface Serial0/0/0

 link-protocol ppp

#

interface Serial0/0/1

 link-protocol ppp

#

interface Serial0/0/2

 link-protocol ppp

#

interface Serial0/0/3

 link-protocol ppp

#

interface GigabitEthernet0/0/0

#

interface GigabitEthernet0/0/1

#

interface GigabitEthernet0/0/2

#

interface GigabitEthernet0/0/3

#

wlan

#

interface NULL0

#

ospf 1   //ospf进程1

#

user-interface con 0

user-interface vty 0 4

user-interface vty 16 20

#

return

【技术要点】

   有读者会问,刚刚我们只配置了系统名和OSPF,为什么还有这么多的命令?

因为除了“sysname joinlabs”,“ospf 1  ” 其它的都是预配,这些配置都是系统本身自带的。

  1. 保存当前的配置

<joinlabs>save   //保存

The current configuration will be written to the device  //当前这些配置将会保存到设备

Are you sure to continue?[Y/N]Y  //你是否继续,选择Y

Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:  //如果不改名,默认为vrpcfg.zip

May 16 2022 15:40:18-08:00 joinlabs %%01CFM/4/SAVE(l)[0]:The user chose Y when deciding whether to save the configuration to the device.

Now saving the current configuration to the slot 17.

Save the configuration successfully.

<joinlabs>

【技术要点】

如果读者给设备做了配置,没有保存,那么文件只在RAM里面,下次重启,配置就没有了。

所以大家一家要记得保存,只要保存了,文件就就进入了Flash/SD卡里面了,下次重启时,配置还在。

  

  1. 查看保存的配置文件

<joinlabs>display saved-configuration    //查看保存的配置文件

#

sysname joinlabs

#

undo info-center enable

#

aaa

 authentication-scheme default

 authorization-scheme default

 accounting-scheme default

 domain default

 domain default_admin

 local-user admin password cipher OOCM4m($F4ajUn1vMEIBNUw#

 local-user admin service-type http

#

firewall zone Local

 priority 16

#

interface Ethernet0/0/0

#

interface Ethernet0/0/1

#

interface Serial0/0/0

 link-protocol ppp

#

interface Serial0/0/1

 link-protocol ppp

#

interface Serial0/0/2

 link-protocol ppp

#

interface Serial0/0/3

 link-protocol ppp

#

interface GigabitEthernet0/0/0

#

interface GigabitEthernet0/0/1

#

interface GigabitEthernet0/0/2

#

interface GigabitEthernet0/0/3

#

wlan

#

interface NULL0

#

ospf 1

#

user-interface con 0

user-interface vty 0 4

user-interface vty 16 20

#

return

【技术要点】

读者在没有保存之前,用display saved-configuration命令查看,可以看到为空。

在文章最后加作者VX:可以免费领取以下资料

  1. 配置文件重置

<joinlabs>reset saved-configuration   //清空保存的配置文件

Warning: The action will delete the saved configuration in the device.

The configuration will be erased to reconfigure. Continue? [Y/N]:Y  //“配置将会被删除用于重新配置”选择Y

Warning: Now clearing the configuration in the device.

Info: Succeeded in clearing the configuration in the device.

<joinlabs>reboot   //重启,只有重新启动配置才能清空。

Info: The system is now comparing the configuration, please wait.

Warning: All the configuration will be saved to the configuration file for the next startup:, Continue?[Y/N]: N     //”所有的配置会被保存到下次启动文件中,是否继续”?一定要选择N,即不保存当前的配置

Info: If want to reboot with saving diagnostic information, input 'N' and then execute 'reboot save diagnostic-information'.

System will reboot! Continue?[Y/N]:Y  //选择Y

【技术要点】

文件重置相当于还原设备的所有配置,所以读者在使用些命令前要记得备份。

  1. 指定系统启动配置文件

<joinlabs>save joinlabs.cfg   //保存配置文件,配置文件名为joinlabs.cfg

Are you sure to save the configuration to flash:/joinlabs.cfg?[Y/N]:y //选择Y或者是回车

<joinlabs>dir flash:   //查看flash中的文件

Directory of flash:/

  Idx  Attr     Size(Byte)  Date        Time       FileName

    0  drw-              -  Aug 07 2015 13:51:14   src

    1  drw-              -  May 16 2022 15:05:00   pmdata

    2  drw-              -  May 16 2022 15:05:03   dhcp

    3  -rw-            603  May 16 2022 15:58:22   private-data.txt

    4  drw-              -  May 16 2022 15:20:09   mplstpoam

    5  -rw-            424  May 16 2022 16:02:18   vrpcfg.zip

    6  -rw-            794  May 16 2022 16:04:21   joinlabs.cfg  //可以看到文件保存成功

32,004 KB total (31,991 KB free)

<joinlabs>startup saved-configuration joinlabs.cfg   //指定启动配置文件名

Info: Succeeded in setting the configuration for booting system.

<joinlabs>save   //保存

The current configuration will be written to the device.

Are you sure to continue?[Y/N]y  //选择Y

Save the configuration successfully.

<joinlabs>display startup //使用命令查看设备重启后调用的配置文件

MainBoard:

  Configured startup system software:        NULL

  Startup system software:                   NULL

  Next startup system software:              NULL

  Startup saved-configuration file:          flash:/joinlabs.cfg

  Next startup saved-configuration file:     flash:/joinlabs.cfg   //可以看到设备下次启动时调用的配置文件

  Startup paf file:                            NULL

  Next startup paf file:                     NULL

  Startup license file:                       NULL

  Next startup license file:               NULL

  Startup patch package:                 NULL

  Next startup patch package:         NULL

【技术要点】

在默认情况下设备会调用根目录下的启动文件 ,而当设备有备份配置文件时,可以指定调用的配置文件,这样可以灵活地实施项目。

本文出自作者的《HCIA Datacom学习指南》
https://item.jd.com/14032255.html

 

  • 10
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值