【华为_数通】常用命令备忘

  • 1 前言
  • 2 测试命令
  • 2.1 测试某个端口是否开启
  • 2.2 看跳数
  • 2.3 清除配置
  • 2.4 重启服务
  • 2.5 定时保存
  • 3 查看命令
  • 3.1 日常设备状况
  • 3.2 升级查看
  • 4 配置模板
  • 4.1 开启HTTP
  • 4.2 远程登录(SSH)
  • 4.3 SFTP
  • 4.4 VRRP+MSTP
  • 4.5 VRRP+DHCP中继
  • 4.6 STP
  • 4.7 BFD
  • 4.8 DHCP
  • 4.9 链路聚合
  • 4.10 单臂路由+DHCP接口地址池
  • 4.11 接口配置+NAT
  • 4.12 802.1X
  • 4.13 Portal


1 前言

备忘用的、方便复制套模板

2 测试命令

2.1 测试某个端口是否开启

(telnet是一种登录远程主机的标准协议)

telnet 10.0.0.1 80
telnet 10.1.229.9 1022

2.2 看跳数

tracert 114.114.114.114

-a	:指明本次tracert命令配置的报文源地址。如果不指定源地址,将采用出接口的IP地址作为tracert报文发送的源地址。
-f	:指定初始TTL。设置first-TTL,当经过的跳数小于此参数值,由于TTL字段  的值大于0,经过的这几个节点不会返回ICMP超时报文给源主机。
-m	:指定最大TTL。通常情况下,max-TTL的值被设置为经过站点的跳数。
-q	:指定每次发送的UDP探测数据包个数。当网络质量不高时,可以增加发送探测数据包数目,保证探测报文能够到达目的节点。
-w	:等待响应报文的超时时间。当发送数据包到达某网关超时,则输出“ * ”。如果网络质量不高且速度很慢,建议增加发送数据包的超时时间。
host	:可以是IP地址或域名。
name	:使能显示每一跳的主机名。
p 		:port指定目的主机的UDP端口号。

2.3 清除配置

# 清除配置,恢复成出厂配置
reset saved-configuration

# 清除接口下的配置	 , [HUAWEI] 下执行, 执行后接口变shutdown
clear configuration interface gigabitethernet 1/0/1

2.4 重启服务

# 重新启动BGP进程
refresh bgp all export

2.5 定时保存

# 命令用来设置系统定时保存配置的功能
set save-configuration


# 配置系统定时保存新配置的时间间隔为60分钟
[usg6300] set save-configuration interval 60

# 设置系统配置发生变化3分钟后,以10小时为保存间隔,自动保存新配置,且CPU使用率上限为60%
[usg6300] set save-configuration interval 600 delay 3 cpu-limit 60

3 查看命令

3.1 日常设备状况

# 查看当前主用主控板的内存占用率信息
display memory-usage

# 命令用来查看设备的部件类型及状态信息
display device

# 查看设备的CPU占用率的统计信息
display cpu-usage

3.2 升级查看

# 查看设备的序列号
display esn

# 查看设备的补丁信息
display patch-information

#  查看设备的版本信息和运行时间
display version

4 配置模板

4.1 开启HTTP

[5328_1]http server load s5300hi-v200r005c00spc500.web.7z
[5328_1]http secure-server enable
[5328_1]http server enable 

aaa
local-user admin service-type http ssh ftp 


[5328_1]
[5328_1]dis http server
   HTTP Server Status              : enabled
   HTTP Server Port                : 80(80)
   HTTP Timeout Interval           : 20
   Current Online Users            : 0
   Maximum Users Allowed           : 5
   HTTP Secure-server Status       : enabled
   HTTP Secure-server Port         : 443(443)
   HTTP SSL Policy                 : Default
[5328_1]

4.2 远程登录(SSH)

user-interface vty 0 4
 ## 配置VTY用户界面的验证方式为aaa
 authentication-mode aaa
 ## 配置VTY用户界面支持的协议为Telnet
 protocol inbound ssh


# 启用ssh服务
stelnet server enable


# 创建ssh用户的 认证方式
ssh user 用户名 authentication-type password
ssh user 用户名 service-type stelnet


# 创建aaa用户
aaa
 local-user 用户名 password cipher 密码
 local-user 用户名 privilege level 3
 local-user 用户名 service-type ssh

4.3 SFTP

#
aaa
 local-user client001 password cipher 12345
 local-user client001 privilege level 15
 local-user client001 service-type ssh
#
sftp server enable
ssh user client001
ssh user client001 authentication-type password
ssh user client001 service-type sftp
ssh user client001 sftp-directory flash:/
#
user-interface vty 0 4
 authentication-mode aaa
 protocol inbound ssh
#

4.4 VRRP+MSTP

# 进入MSTP域配置模式
stp region-configuration
 # 配置MSTP域名,默认为交换机的MAC地址
 region-name wakin
 # 配置MSTP修订级别,0~65535,默认为0
 revision-level 1
 # 配置实例与VLAN的映射,默认所有VLAN映射到Instance 0
 instance 10 vlan 10
 instance 20 vlan 20
 # 激活MSTP域的配置
 active region-configuration

# 配置MST实例的主或备根桥,自动修改并锁定优先级为0或4096
stp instance 10 root primary 
stp instance 20 root secondary 


int vlanif 10
 ip add 10.0.0.1 24
 vrrp vrid 10 vir 10.0.0.254
 vrrp vrid 10 priority 200

int vlanif 20
 ip add 20.0.0.1 24
 vrrp vrid 20 vir 20.0.0.254
[SW3]dis stp br
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        ROOT  FORWARDING      NONE
   0    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE
   0    GigabitEthernet0/0/3        DESI  FORWARDING      NONE
  10    GigabitEthernet0/0/1        ROOT  FORWARDING      NONE
  10    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE
  10    GigabitEthernet0/0/3        DESI  FORWARDING      NONE
  20    GigabitEthernet0/0/1        ALTE  DISCARDING      NONE
  20    GigabitEthernet0/0/2        ROOT  FORWARDING      NONE
[SW3]
[SW3]
[SW3]
[SW3]
[SW3]dis stp region-configuration
 Oper configuration
   Format selector    :0             
   Region name        :wakin             
   Revision level     :1

   Instance   VLANs Mapped
      0       1 to 9, 11 to 19, 21 to 4094
     10       10
     20       20
[SW3]

4.5 VRRP+DHCP中继

int vlanif 10
ip add 10.0.0.252 24
 vrrp vrid 1 virtual-ip 10.0.0.254
 dhcp select relay
 dhcp relay server-ip 24.0.0.254
 dhcp relay server-ip 34.0.0.254

int vlanif 20
ip add 20.0.0.252 24
 vrrp vrid 1 virtual-ip 20.0.0.254
 vrrp vrid 1 priority 110
 # 配置抢占延迟
 vrrp vrid 1 preempt-mode timer delay 10
 # 配置通告延迟
 vrrp vrid 1 timer advertise 5
 dhcp select relay
 dhcp relay server-ip 24.0.0.254
 dhcp relay server-ip 34.0.0.254

4.6 STP

#调整STP的模式,默认MSTP
stp mode (stp、mstp、rstp)

# 调整BID优先级值,0~61440,值 必须是 4096的倍数
stp priority 4096

# 指定主/备根桥,会自动修改优先级
stp root primary / secondary

# 修改STP开销   (接口的开销)
stp cost 10	

# 修改PID优先级,0~240 ,值 必须是16的倍数
stp port priority 144


# 显示STP配置信息和参数
display stp brief

4.7 BFD

bfd
 quit

bfd v10 bind peer-ip 10.0.0.253 
 discriminator local 12
 discriminator remote 13
 commit

bfd v20 bind peer-ip 20.0.0.253 
 discriminator local 22
 discriminator remote 23
 commit

int vlanif10 
 # 这里绑定的是 bfd 的本地标识符;实现 备10 快速成主
 vrrp vrid 1 track bfd-session 12 increased 55

4.8 DHCP

# 采用全局地址池时的配置
[HUAWEI] ip pool pool1


# 创建全局地址池
ip pool 地址池名称
 # 配置全局地址池的可分配网段地址
 network 10.0.0.0 mask 24
 # 配置全局地址池的网关地址
 gateway-list 10.0.0.254
 # 配置全局地址池的DNS服务器地址
 dns-list 223.5.5.5 114.114.114.114
 # 配置全局地址池下对端排除地址范围 
 excluded-ip -address 10.0.0.1 10.0.0.50
 excluded-ip -address 10.0.0.1 10.0.0.50

int vlanif10
 ip add 10.0.0.254 24
 # 关联接口 和 全局地址池 -绑定
 dhcp select global

4.9 链路聚合

# 创建聚合端口
interface eth-trunk 1
 mode lacp
 # 加入成员接口 
 trunkport gigabitethernet 0/0/1 to 0/0/3


# 进入接口,再加聚合口也行
interface gigabitethernet 0/0/1
 eth-trunk 1


# 验证配置信息和状态
display [interface] eth-trunk 1	

# 验证成员信息
display trunkmembership eth-trunk 1

4.10 单臂路由+DHCP接口地址池

# 
interface GigabitEthernet0/0/0.1
 dot1q termination vid 1
 ip address 10.0.1.254 24
 dhcp select interface
 dhcp server excluded-ip-address 10.0.1.1 10.0.1.50 
 dhcp server excluded-ip-address 10.0.1.200 10.0.1.253 
 dhcp server dns-list 223.5.5.5
#
interface GigabitEthernet0/0/0.2
 dot1q termination vid 2
 ip address 10.0.2.254 24
 dhcp select interface
 dhcp server excluded-ip-address 10.0.2.1 10.0.2.50 
 dhcp server excluded-ip-address 10.0.2.200 10.0.2.253 
 dhcp server dns-list 223.5.5.5
 # 为客户端分配固定的IP 地址 [采用接口地址池时的配置]
 dhcp server static-bind ip-address 10.0.2.10 mac-address dcd2-fc96-e4c0

4.11 接口配置+NAT

acl number 2000  
 rule 100 permit source 10.0.0.11 24
 rule 105 permit source 10.0.0.12 24 
 rule 110 permit source 10.0.0.13 24

interface GigabitEthernet0/0/1
 ip address 10.0.0.1 24
 nat outbound 2000

4.12 802.1X

# 缺省是unified-mode,如未更改可无需执行该命令
authentication unified-mode

# RADIUS服务器模板
radius-server template radius_template  
  radius-server authentication 10.1.5.107 1812 source ip-address 10.1.3.3
  radius-server accounting 10.1.5.107 1813 source ip-address 10.1.3.3
  radius-server shared-key cipher Huawei@123
  quit

# 配置RADIUS授权服务器
 radius-server authorization 10.1.5.107 shared-key cipher Huawei@123


aaa  
 # 认证方案
 authentication-scheme auth_scheme
  authentication-mode radius
  quit

 # 计费方案
 accounting-scheme acco_scheme
  accounting-mode radius
  accounting realtime 15
  quit

 # 全局默认域内引用RADIUS服务器模板和认证计费方案
 domain default  
  authentication-scheme auth_scheme
  accounting-scheme acco_scheme
  radius-server radius_template
  quit
 quit

# 配置全局默认域
domain default

# 配置认证用户可以免认证访问服务器区域的资源
authentication free-rule 1 destination ip 10.1.5.107 mask 255.255.255.255 

# 在接口上使能802.1x认证。
interface gigabitethernet 0/0/10
 authentication dot1x




# 测试
test-aaa user2 Huawei@123 radius-template radius_template
test-aaa user4 Huawei@123 radius-template radius

4.13 Portal

# 缺省是unified-mode,如未更改可无需执行该命令
authentication unified-mode

# RADIUS服务器模板
radius-server template Radius
  radius-server authentication 10.1.5.107 1812 source ip-address 10.1.3.3
  radius-server accounting 10.1.5.107 1813 source ip-address 10.1.3.3
  radius-server shared-key cipher Huawei@123
  quit

# 配置RADIUS授权服务器
 radius-server authorization 10.1.5.107 shared-key cipher Huawei@123


aaa  
 # 认证方案
 authentication-scheme Radius
  authentication-mode radius
  quit

 # 计费方案
 accounting-scheme Radius
  accounting-mode radius
  accounting realtime 15
  quit

 # 全局默认域内引用RADIUS服务器模板和认证计费方案
 domain default  
  authentication-scheme Radius
  accounting-scheme Radius
  radius-server Radius
  quit
 quit

# 配置全局默认域
domain default

# 配置认证用户可以免认证访问服务器区域的资源
authentication free-rule 1 destination ip 10.1.5.107 mask 255.255.255.255 


# 配置与Portal服务器的对接参数
web-auth-server Portal
 server-ip 10.1.5.107
 port 50200
 shared-key cipher Huawei@123
 url http://10.1.5.107:8080/portal
 source-ip 10.1.3.3


# 因为 Vlanif2 是用户的网关,所以要在Vlanif2上配置【连接用户侧的物理接口就不需要再配置 authentication portal 了,实测配置了也能用】
interface Vlanif2
 # 在接口下绑定Portal服务器模板
 web-auth-server Portal layer3
 # 在接口下使能Portal认证
 authentication portal
# 测试
test-aaa user2 Huawei@123 radius-template Radius
test-aaa user4 Huawei@123 radius-template Radius







display access-user access-type portal