NetDevOps — 华为设备命令汇总

举报
云物互联 发表于 2022/01/19 00:08:17 2022/01/19
【摘要】 目录 文章目录 目录Telnet 配置配置 password 登录认证模式配置 AAA 登录认证模式配置远程登录 L2 交换转发配置以太网接口配置链路技术配置链路聚合Smart Link ...

目录

Telnet 配置

配置 password 登录认证模式

# 进入管理控制口。
[Huawei]user-interface console 0  

# 设置密码。
[Huawei-ui-console0]authentication-mode password
Please configure the login password (maximum length 16):

# 设置特权等级。
[Huawei-ui-console0]user privilege level ? 

# 设置空闲超时时间为 2 0分钟,默认为 10 分钟。
[Huawei-ui-console0]idle-timeout 20 0

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

配置 AAA 登录认证模式

# 进入管理控制口。
[Huawei]user-interface console 0

# 设置 AAA 认证方式。
[Huawei-ui-console0]authentication-mode aaa
[Huawei-ui-console0]quit
[Huawei]aaa
[Huawei-aaa]local-user huawei password cipher hw

# 设置从终端登录
[Huawei-aaa]local-user huawei service-type terminal  

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

配置远程登录

  • AAA 远程登录模式
# 进入虚拟用户终端接口
[R1]user-interface vty 0 4
[R1-ui-vty0-4]authentication-mode aaa
[R1]aaa

# 配置本地用户和密码
[R1-aaa]local-user admin password cipher 123456

# 选择授权用户的服务类型
[R1-aaa]local-user admin service-type telnet

# 设置管理员的特权等级
[R1-aaa]local-user admin privilege level 3

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • password 远程登录模式
# 进入虚拟用户终端接口
[R2]user-interface vty 0 4
[R2-ui-vty0-4]authentication-mode password
[R2-ui-vty0-4]set authentication password simple 123456

# 设置用户特权等级
[R2-ui-vty0-4]user privilege level 3  

# 设置登录用户的参数
[R2-ui-vty0-4]user network-admin

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

L2 交换转发配置

以太网接口配置

[S1-G0/0/9]undo negotiation auto  //更改接口的速率和双工模式前应先关闭接口的自动协商功能
[S1-G0/0/9]speed 100  //设置为100M速率
[S1-G0/0/9]duplex full  //全双工模式
[S1]dis eth-trunk 1  //查看Eth-trunk 1配置结果


  
 
  • 1
  • 2
  • 3
  • 4
  • 5

链路技术配置

链路聚合

[S1]interface Eth-Trunk 1  //聚合交换机之间的Eth-Trunk端口编号相等
[S1-Eth-Trunk1]mode lacp-static  //lacp模式
[S1-Eth-Trunk1]trunkport GigabitEthernet 0/0/1 to 0/0/2  //将成员端口加入到聚合端口中
[S1-Eth-Trunk1]max active-linknumber 2  //设置活动上限阀值
[S1-Eth-Trunk1]port link-type trunk 
[S1-Eth-Trunk1]port trunk allow-pass vlan all
[S1-Eth-Trunk1]dis eth-trunk 1 verbose  //查看聚合端口的信息
[S1] lacp priority 100  //配置系统优先级使其成为主控端
[S1-G0/0/1] lacp priority 100  //配置活动链路优先级
[S1-G0/0/2] lacp priority 100  //配置活动链路优先级

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

Smart Link

[S1-G0/0/1]stp disable  //关掉相关接口的STP
[S1]smart-link group 1
[S1-smlk-group1]port GigabitEthernet 0/0/1 master  //设置主端口
[S1-smlk-group1]port g0/0/2 slave  //设置从端口
[S1-smlk-group1]flush send control-vlan 10 password simple 123  //使能smart link组1发送Flush帧的功能,携带的控制VLAN编号为10,密码是:123
[S1-smlk-group1]restore enable  //开启回切功能
[S1-smlk-group1]timer wtr 30  //回切时间为30秒
[S1-smlk-group1]smart-link enable  //使能Smart Link组1的功能
[S1-smlk-group1]dis smart-link group 1  //查看Smart Link组1的信息
[S2-GigabitEthernet0/0/1]smart-link flush receive control-vlan 10 password simple 123  //设置其他交换机可以接收和处理携带控制VLAN编号是10的Flush帧

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

端口类型配置

配置端口为 Access 类型

[Huawei]vlan 10  //创建vlan 10
[Huawei]interface GigabitEthernet 0/0/2  //进入g0/0/2端口
[Huawei-GigabitEthernet0/0/2]port link-type access  //选择端口类型
[Huawei-GigabitEthernet0/0/2]port default vlan 10  //划分VLAN

技巧:[S2]vlan batch 3 to 5  //创建VLAN3、4、5

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

配置端口的 Hybrid 类型

[SW1]vlan 10
[SW1-GigabitEthernet0/0/1]port hybrid pvid vlan 10
[SW1-GigabitEthernet0/0/1]port hybrid untagged vlan 10 30  //对VLAN10和30去标签

  
 
  • 1
  • 2
  • 3

配置端口的 Trunk 类型

[SW1]interface g0/0/24
[SW1-GigabitEthernet0/0/24]port link-type trunk
[SW1-GigabitEthernet0/0/24]port trunk allow-pass vlan all  //允许所有VLAN通过

  
 
  • 1
  • 2
  • 3

更改 Trunk 端口的 PVID

[SW1-GigabitEthernet0/0/24]port trunk pvid vlan 10

  
 
  • 1

Eth Trunk 配置

创建 Eth-trunk 1,并将接口加入 Eth-trunk 1

[S1]interface Eth-Trunk 1
[S1]int g0/0/9
[S1-GigabitEthernet0/0/9]eth-trunk 1[S1]interface Eth-Trunk 1
[S1-Eth-Trunk1]trunkport g0/0/9

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

配置 Eth-trunk 1 链路为 Access

[S1]interface Eth-Trunk 1
[S1-Eth-Trunk1]port link-type access
[S1-Eth-Trunk1]port default vlan 5

  
 
  • 1
  • 2
  • 3

端口镜像

[R1]observe-port 1 interface Ethernet4/0/1  //设置观察端口
[接口] mirror to observe-port 1 both  //将镜像端口映射到观察端口

  
 
  • 1
  • 2

端口绑定

[Huawei]user-bind static mac-address 5489-988B-5157 int e0/0/1 //绑定MAC地址
[Huawei]user-bind static ip-address 192.168.1.3  //绑定IP地址

  
 
  • 1
  • 2

端口安全

[接口]port-security enable  //启用端口安全
[接口]port-security max-mac-num 2  //自动学习MAC地址的最大数量
[接口]port-security protect-action shutdown  //保护行为为关闭端口

  
 
  • 1
  • 2
  • 3

STP 配置

查看STP

#各接口简要STP状态
[S1]dis stp brief

#具体接口详细STP信息
[S1]dis stp interface g0/0/10

#查看当前根桥信息
[S1]dis stp

#查看实例1的信息
[SW1]dis stp instance 1 brief

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

配置 STP

#修改桥优先级
[S1]stp priority 4096  //数值越小优先级越高

#修改端口优先级
[S1-GigabitEthernet0/0/9]stp port priority 32    //默认为128,数值越小优先级越高

#配置边缘端口(使端口快速进入转发状态)
[S3]interface Ethernet0/0/3
[S3-Ethernet0/0/3]stp edged-port enable

[S3-Ethernet0/0/3]stp cost  //设置路径开销值

[根交换机]stp timer forward-delay  //设置延迟时间

[根交换机]stp edged-port enable  //设置网络直径

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

配置 MSTP

[SW1]stp region-configuration  //进入MST域
[SW1-mst-region]region-name huawei  //配置域名
[SW1-mst-region]revision-level 1  //配置修订级别为1
[SW1-mst-region]instance 1 vlan 10  //制定MSTI 1与VLAN10的映射

  
 
  • 1
  • 2
  • 3
  • 4

帧中继配置

DCE 配置

[R1]interface s1/0/0
[R1-Serial1/0/0]link-protocol fr
[R1-Serial1/0/0]fr interface-type dce  //接口类型
[R1-Serial1/0/0]fr dlci 100
[R1-Serial1/0/0]ip add 192.168.1.1 24

  
 
  • 1
  • 2
  • 3
  • 4
  • 5

DTE 配置

[R2]interface s1/0/0
[R2-Serial1/0/0]link-protocol fr
[R2-Serial1/0/0]fr interface-type dte

  
 
  • 1
  • 2
  • 3

L3 路由转发配置

查看 IP 地址池

dis ip pool  //查看地址池地址分配情况

  
 
  • 1

浮动静态路由

[Huawei]ip route-static 192.168.1.0 24(目标网络) 192.168.2.1(下一跳IP) preference 80

  
 
  • 1

默认(缺省)路由

[R1]ip route-static 0.0.0.0 0.0.0.0 10.0.13.3

  
 
  • 1

前缀列表

[R1]ip ip-prefix 1 deny 11.1.1.0 25 greater-equal 25 less-equal 25  //在RIP里面过滤掉11.1.1.0/25
[R1]ip ip-prefix 1 permit 0.0.0.0 0 less-equal 32
[R1-rip-1]filter-policy ip-prefix 1 import

  
 
  • 1
  • 2
  • 3

IPv6 配置

[R1]ipv6  //开启全局IPv6功能
[R1-E0/0/0]ipv6 enable  //在接口(连接PC)下开启IPv6功能
[R1-E0/0/0]ipv6 address auto link-local  //自动生成链路本地地址
[R1-G0/0/0]ipv6 enable  //在接口(连接路由器)下开启IPv6功能
[R1-G0/0/0]ipv6 add 2031:0:130F::1 64  //配置全球单播地址

[R1-E0/0/0]ipv6 add 2001:3:FD:: 64 eui-64  //用EUI-64配置地址

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

配置单臂路由

配置路由器

[R1]int g0/0/0.1  //创建并进入g0/0/0的0.1子接口
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 10  //封装dot1q协议
[R1-GigabitEthernet0/0/0.1]ip address 192.168.10.254 24  //配置IP地址
[R1-GigabitEthernet0/0/0.1]arp broadcast enable  //开启arp广播
[R1-GigabitEthernet0/0/0.1]dhcp select global  //开启DHCP全局模式

[R1-GigabitEthernet0/0/0.1]int g0/0/0.2
[R1-GigabitEthernet0/0/0.2]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.2]ip address 192.168.20.254 24
[R1-GigabitEthernet0/0/0.2]arp broadcast enable
[R1-GigabitEthernet0/0/0.2]dhcp select global

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

配置交换机

[SW1]vlan batch 10 20  //创建vlan 10和vlan 20
[SW1-GigabitEthernet0/0/1]int g0/0/1  //进入g0/0/1接口
[SW1-GigabitEthernet0/0/1]port link-type access  //修改端口为access模式
[SW1-GigabitEthernet0/0/1]port default vlan 10  //将端口划分到vlan 10[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 20

[SW1-GigabitEthernet0/0/2]int g0/0/24  //交换机与路由器相连的接口需要修改为trunk模式
[SW1-GigabitEthernet0/0/24]port link-type trunk  //修改端口为trunk模式
[SW1-GigabitEthernet0/0/24]port trunk allow-pass vlan 10 20  //允许vlan 10和vlan 20的数据通过

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

VRRP 配置

[SW1-Vlanif10]vrrp vrid 1 virtual-ip 10.1.1.254  //配置虚拟网关
[SW1-Vlanif10]vrrp vrid 1 priority 150  //更改优先级
[SW1-Vlanif10]vrrp vrid 1 preempt-mode disable  //关闭抢占模式
[SW1-Vlanif10]vrrp vrid 1 track interface g0/0/24 reduced 60  //跟踪上层端口
[R1-Serial2/0/0]ospf network-type p2mp  //配置接口的网络类型为Point-to-multipoint
[S1] display vrrp  //查看VRRP信息

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

DHCP 配置

基于接口配置 DHCP 功能

[R1]dhcp enable  //开启DHCP功能
[R1-GigabitEthernet0/0/0]dhcp select interface  //开启接口DHCP功能
[R1-GigabitEthernet0/0/0]dhcp server lease day 2【可选】    //设置租用有效期限为2天
[R1-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8    //为PC自动分配DNS服务器地址
[R1-GigabitEthernet0/0/1]dhcp server excluded-ip-address 192.168.2.250 192.168.2.253    //配置不参与自动分配的IP地址范围


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

基于全局配置 DHCP

[R1]dhcp enable  //开启DHCP功能
[R1]ip pool huawei1  //配置全局地址池
[R1-ip-pool-huawei1]network 192.168.1.0  //指定地址池范围
[R1-ip-pool-huawei1]lease day 2【可选】  //租期为2天,默认1天
[R1-ip-pool-huawei1]gateway-list 192.168.1.254  //出口网关地址
[R1-ip-pool-huawei1]excluded-ip-address 192.168.1.250 192.168.1.253  //不参与自动分配
[R1-ip-pool-huawei1]dns-list 8.8.8.8  //配置DNS服务器地址
[R1-GigabitEthernet0/0/0]dhcp select global  //开启接口的DHCP功能


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

DHCP 中继

[R1]dhcp enable  //开启DHCP功能

#面向PC的接口:
[R1-Ethernet0/0/0]dhcp select relay
[R1-Ethernet0/0/0]dhcp relay server-ip 100.1.1.1  //指定DHCP服务器IP地址

#面向PC的接口下调用全局定义的DHCP服务器组:
[R1]dhcp server group dhcp-group
[R1-dhcp-server-group-dhcp-group]dhcp-server 100.1.1.1
[R1-Ethernet0/0/0]dhcp select relay 
[R1-Ethernet0/0/0]dhcp relay server-select dhcp-group


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

FTP 配置

将路由器作为 FTP 服务器

[R1]ftp server enable
[R1]aaa
[R1-aaa]local-user winda password cipher aqx123456
[R1-aaa]local-user winda privilege level 15
[R1-aaa]local-user winda service-type ftp

# 指定目录
[R1-aaa]local-user winda ftp-directory flash:

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

登录 FTP 服务器,并传送文件

<R1>ftp 10.0.12.2
User(10.0.12.2:(none)):huawei
331 Password required for huawei.
Enter password:
230 User logged in.

# 上传文件
[R1-ftp]put portalpage.zip  

# 下载文件并改名字
[R1-ftp]get portalpage.zip portal.zip 

# 彻底删除该文件
<R1>delete /unreserved portal.zip  

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

文章来源: is-cloud.blog.csdn.net,作者:云物互联,版权归原作者所有,如需转载,请联系作者。

原文链接:is-cloud.blog.csdn.net/article/details/122548492

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200