# Aaa Auth Config

> This skill should be used when the user asks to configure or troubleshoot AAA (Authentication / Authorization / Accounting) on Huawei S / CE / USG series devices — including 802.1X, MAC authentication, Portal authentication, RADIUS, HWTACACS (TACACS+), local authentication, authentication profiles, free-rule, NAC unified-mode vs common-mode, AAA domains, EAP method selection (CHAP/PAP/EAP), reauthentication, accounting, and authentication failure troubleshooting. Applicable platforms S series switches V200R011C10+ / V200R022C00+ (including S5735S-L24T4S-A), CloudEngine V200R022C00+, USG6000E V500R005C20+ / V600R007C20+.

- Skill: `nanxiaoyao/aaa-auth-config` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add nanxiaoyao/aaa-auth-config`
- Raw SKILL.md: https://api.skillmd.com/api/skills/nanxiaoyao/aaa-auth-config/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Finance & Business
- Author: nanxiaoyao (https://skillmd.com/u/nanxiaoyao)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/nanxiaoyao/aaa-auth-config

---


# 华为 AAA 认证配置技能 (aaa-auth-config)

> **适用平台**：S 系列 V200R011C10+ / V200R022C00+（含 S5735S-L24T4S-A）/ CloudEngine V200R022C00+ / USG6000E V500R005C20+ / V600R007C20+
> **覆盖**：AAA 框架 / RADIUS / HWTACACS（TACACS+）/ 802.1X / MAC 认证 / Portal 认证 / 域管理 / 认证模板 / free-rule / 排错
> **文档来源**：《802.1X 认证基础》《802.1X 认证失败故障处理》《配置 RADIUS 和 HWTACACS（V200）》《什么是 TACACS，如何配置 TACACS？》

---

## 一、触发场景

**召唤关键词**：AAA / 802.1X / MAC 认证 / Portal / RADIUS / HWTACACS / TACACS+ / 认证 / 授权 / 计费 / 域管理 / authentication / authentication-profile / dot1x / free-rule / NAC / 统一模式 / 传统模式

**典型问题**：
- "S5735S 上接 802.1X 认证怎么配？"
- "RADIUS 服务器连不上怎么办？"
- "TACACS+ 认证失败 / 服务器不可达"
- "NAC 统一模式 vs 传统模式 区别"
- "客户端认证拒绝（Access-Reject）"
- "认证模板怎么用？认证域怎么配？"
- "free-rule 是什么？用户认证前能访问什么？"
- "EAP-CHAP / EAP-PAP / EAP 中继 怎么选？"

**不适用**：
- 防火墙 `security-policy` / `ipsec-vpn`（用对应 skill）
- 交换机二层 VLAN / 三层接口（用 `vlan-config` / `interface-config`）

---

## 二、AAA 框架速记

AAA = **Authentication（认证）+ Authorization（授权）+ Accounting（计费）**

### 5 大核心组件

| 组件 | 用途 | 关键命令 |
|---|---|---|
| **认证方案** authentication-scheme | 认证模式 + 备份 | `authentication-mode radius local` |
| **授权方案** authorization-scheme | 授权模式 + 备份 | `authorization-mode hwtacacs local` |
| **计费方案** accounting-scheme | 计费模式 + 失败策略 | `accounting-mode radius` + `accounting start-fail online` |
| **服务器模板** radius-server / hwtacacs-server | 服务器 IP / 端口 / 共享密钥 | `radius-server authentication 10.1.1.2 1812` + `shared-key cipher ...` |
| **域 domain** | 绑定上述 4 组件 | `domain huawei` + 在域下引用 4 方案 |

### 认证模式（`authentication-mode`）

| 模式 | 含义 | 备份 |
|---|---|---|
| `local` | 本地用户 | （无需备份） |
| `radius` | RADIUS 认证 | `local`（服务器挂掉时降级） |
| `hwtacacs` | HWTACACS / TACACS+ 认证 | `local` |
| `none` | 不认证（公开接入）| — |

### 推荐搭配（生产环境）

```
authentication-mode radius local       # RADIUS 优先 + 本地备份
authorization-mode hwtacacs local      # HWTACACS（命令授权）+ 本地备份
accounting-mode radius                  # 计费一般只用 RADIUS
accounting start-fail online            # 计费失败允许上线（推荐）
```

---

## 三、AAA 六步走配置

### 第 1 步：配置 RADIUS 服务器模板

```bash
<HUAWEI> system-view
[Switch] radius-server template rad1
[Switch-radius-rad1] radius-server authentication 10.23.100.200 1812
[Switch-radius-rad1] radius-server accounting 10.23.100.200 1813
[Switch-radius-rad1] radius-server shared-key cipher %^%#YourKey...%^%#
[Switch-radius-rad1] undo radius-server user-name domain-included
[Switch-radius-rad1] quit
```

**关键参数**：
- **端口 1812**：认证默认（Accounting 用 1813 或 1814）
- **shared-key cipher**：密文存储，**必须与 RADIUS 服务器一致**
- `undo user-name domain-included`：用户名不带域名（视服务器策略）
- **可选**：`radius-server retransmit 3 retry-timeout 5`

### 第 2 步：配置 HWTACACS 服务器模板（TACACS+）

```bash
[Switch] hwtacacs-server template tac1
[Switch-hwtacacs-tac1] hwtacacs-server authentication 10.23.100.200
[Switch-hwtacacs-tac1] hwtacacs-server authorization 10.23.100.200
[Switch-hwtacacs-tac1] hwtacacs-server accounting 10.23.100.200
[Switch-hwtacacs-tac1] hwtacacs-server shared-key cipher %^%#YourKey...%^%#
[Switch-hwtacacs-tac1] quit
```

**关键参数**：
- **端口 49**（默认）：HWTACACS 标准端口
- 三种 server 命令可指向同一台或不同服务器
- 与 Cisco ACS/Ise 对接时 HWTACACS 协议层兼容，**但私有属性不一定兼容**

### 第 3 步：配置 AAA 方案（认证 + 授权 + 计费）

```bash
[Switch] aaa

# 认证方案：RADIUS 优先 + 本地备份
[Switch-aaa] authentication-scheme auth1
[Switch-aaa-authen-auth1] authentication-mode radius local
[Switch-aaa-authen-auth1] quit

# 授权方案：HWTACACS + 本地备份
[Switch-aaa] authorization-scheme authz1
[Switch-aaa-authen-authz1] authorization-mode hwtacacs local
[Switch-aaa-authen-authz1] quit

# 计费方案：RADIUS
[Switch-aaa] accounting-scheme acct1
[Switch-aaa-accounting-acct1] accounting-mode radius
[Switch-aaa-accounting-acct1] accounting start-fail online
[Switch-aaa-accounting-acct1] quit

[Switch-aaa] quit
```

### 第 4 步：配置本地用户（备份认证用）

```bash
[Switch] aaa
[Switch-aaa] local-user admin privilege level 15
[Switch-aaa] local-user admin password irreversible-cipher YourPassword@123
[Switch-aaa] local-user admin service-type telnet ssh terminal http
[Switch-aaa] quit
```

**关键参数**：
- **privilege level 0-15**（15 为最高管理员）
- **service-type**：telnet / ssh / terminal / http / ftp / ppp
- 默认有 `admin` 用户（密码 `admin@huawei.com`，level 15）

### 第 5 步：配置域 domain

```bash
[Switch] domain huawei
[Switch-isp-huawei] authentication-scheme auth1
[Switch-isp-huawei] authorization-scheme authz1
[Switch-isp-huawei] accounting-scheme acct1
[Switch-isp-huawei] radius-server rad1
[Switch-isp-huawei] hwtacacs-server tac1         # 如果用 HWTACACS
[Switch-isp-huawei] quit
```

**域（domain）的作用**：
- 不同用户可走不同服务器（按用户名 @域名 区分）
- **全局默认域**：`domain default`（所有未匹配用户）
- **强制域**：`access-domain xxx force`（无论用户名都走此域）

### 第 6 步：保存配置

```bash
save                                          # S 系列
# 或
commit                                        # CE 二阶段提交（教训 #12）
```

---

## 四、802.1X 接入认证配置（核心）

### 4.1 NAC 模式确认（必查）

```bash
display authentication mode
# Current authentication mode is unified-mode  ← V200R022C10+ 默认
# Current authentication mode is common-mode   ← 旧版，传统模式
```

> **统一模式**（unified-mode）：用 **authentication-profile 模板**（推荐）
> **传统模式**（common-mode）：直接接口下 `dot1x enable`（老配置）

### 4.2 统一模式配置 802.1X（S5735S 推荐）

```bash
# 1. 802.1X 接入模板（定义 EAP 方法）
[Switch] dot1x-access-profile name dot1x1
[Switch-dot1x-access-profile-dot1x1] dot1x authentication-method eap
#  ↑ eap（EAP 中继，推荐）/ chap（EAP 终结）/ pap（EAP 终结）
[Switch-dot1x-access-profile-dot1x1] quit

# 2. 认证模板（绑定接入方式 + 强制域）
[Switch] authentication-profile name authen1
[Switch-authen-profile-authen1] dot1x-access-profile dot1x1
[Switch-authen-profile-authen1] access-domain huawei dot1x
#  ↑ dot1x：802.1X 用户走 huawei 域
[Switch-authen-profile-authen1] quit

# 3. 接口绑定认证模板
[Switch] interface gigabitethernet 0/0/1
[Switch-GigabitEthernet0/0/1] authentication-profile authen1
[Switch-GigabitEthernet0/0/1] quit
```

### 4.3 关键参数速记

| 参数 | 命令 | 默认值 | 适用场景 |
|---|---|---|---|
| EAP 方法 | `dot1x authentication-method {chap \| pap \| eap}` | chap (传统) / eap (统一) | 视客户端和服务器 |
| 重认证周期 | `dot1x reauthenticate` + `dot1x timer reauthenticateperiod <sec>` | 关闭 | 服务器端权限变更 |
| 静默时间 | `dot1x quiet-times fail-times` | 10 次/60 秒 | 防暴力破解 |
| 重传次数 | `dot1x retry max-retry-value` | 2 | EAP-Request 重传 |
| 重传间隔 | `dot1x timer tx-period tx-period` | 20 秒 | EAP-Request 重传 |
| MAC 旁路 | `dot1x timer mac-bypass-delay <sec>` | 关闭 | 802.1X 失败后 MAC 认证 |

### 4.4 Free-rule（认证前放行）

**用户认证前可访问的目的地址**（如认证页面、补丁服务器）：

```bash
# 方式 1：直接指定
[Switch] free-rule-template name free1
[Switch-free-rule-free1] free-rule 1 destination ip 8.8.8.8 mask 24
[Switch-free-rule-free1] quit

# 方式 2：通过 ACL
[Switch] acl 3000
[Switch-acl-adv-3000] rule permit ip destination 8.8.8.8 0
[Switch-acl-adv-3000] quit
[Switch] free-rule-template name free2
[Switch-free-rule-free2] free-rule 2 acl 3000
```

**引用 free-rule**：
```bash
[Switch] authentication-profile name authen1
[Switch-authen-profile-authen1] free-rule-template free1
[Switch-authen-profile-authen1] quit
```

### 4.5 802.1X 完整 6 步走（生产部署）

```bash
# 1. RADIUS 服务器模板（参上）
# 2. 认证 / 授权 / 计费方案（参上）
# 3. 域 domain（参上）
# 4. 802.1X 接入模板
[Switch] dot1x-access-profile name dot1x1
[Switch-dot1x-access-profile-dot1x1] dot1x authentication-method eap
[Switch-dot1x-access-profile-dot1x1] quit

# 5. 认证模板
[Switch] authentication-profile name authen1
[Switch-authen-profile-authen1] dot1x-access-profile dot1x1
[Switch-authen-profile-authen1] mac-access-profile mac1           # 可选：MAC 旁路
[Switch-authen-profile-authen1] portal-access-profile portal1     # 可选：Portal 备份
[Switch-authen-profile-authen1] access-domain huawei
[Switch-authen-profile-authen1] free-rule-template free1          # 可选
[Switch-authen-profile-authen1] quit

# 6. 接口绑定
[Switch] interface range gigabitethernet 0/0/1 to 0/0/24
[Switch-GigabitEthernet0/0/1] authentication-profile authen1
[Switch-GigabitEthernet0/0/1] quit
save
```

---

## 五、MAC 认证 / Portal 认证

### 5.1 MAC 认证（哑终端接入：打印机/IP 话机/摄像头）

```bash
# MAC 接入模板
[Switch] mac-access-profile name mac1
[Switch-mac-access-profile-mac1] mac-authen username mac-address format with-hyphen
#                          ↑ MAC 作为用户名（带连字符 00e0-fc12-3456）

# 认证模板
[Switch] authentication-profile name mac-auth
[Switch-authen-profile-mac-auth] mac-access-profile mac1
[Switch-authen-profile-mac-auth] access-domain huawei mac-authen
[Switch-authen-profile-mac-auth] quit

# 接口绑定
[Switch] interface gigabitethernet 0/0/2
[Switch-GigabitEthernet0/0/2] authentication-profile mac-auth
```

**RADIUS 服务器侧**：
- 用户名：`00e0-fc12-3456`（不带密码 / 默认密码 `huawei`）
- 或用 MAC 末 3 位（视策略）

### 5.2 Portal 认证（Web 认证 / 访客认证）

```bash
# Portal 接入模板
[Switch] portal-access-profile name portal1
[Switch-portal-access-profile-portal1] portal url http://10.23.100.100:8080/portal
[Switch-portal-access-profile-portal1] portal authentication-method chap

# 认证模板
[Switch] authentication-profile name portal-auth
[Switch-authen-profile-portal-auth] portal-access-profile portal1
[Switch-authen-profile-portal-auth] access-domain huawei portal
[Switch-authen-profile-portal-auth] quit

# 接口绑定
[Switch] interface gigabitethernet 0/0/3
[Switch-GigabitEthernet0/0/3] authentication-profile portal-auth
```

---

## 六、命令授权 / 用户级别

### 6.1 本地用户级别（0-15）

```bash
[Switch] aaa
[Switch-aaa] local-user ops privilege level 3        # 监控级
[Switch-aaa] local-user netadmin privilege level 15  # 管理员级
[Switch-aaa] quit
```

### 6.2 HWTACACS 命令授权

```bash
[Switch] aaa
[Switch-aaa] authorization-scheme authz1
[Switch-aaa-authen-authz1] authorization-mode hwtacacs local
[Switch-aaa-authen-authz1] authorization-cmd 15 hwtacacs local
#                              ↑ 对 level 15 用户执行命令时送 TACACS 授权
[Switch-aaa-authen-authz1] quit
```

> **坑**：启用 `authorization-cmd` 后，用户执行命令全要经过 TACACS 授权。服务器挂掉时降级 local。

### 6.3 命令记录（审计）

```bash
[Switch] aaa
[Switch-aaa] recording-scheme rec1
[Switch-aaa-recording-rec1] recording-mode hwtacacs t1
[Switch-aaa-recording-rec1] cmd recording-scheme rec1          # 命令记录
[Switch-aaa-recording-rec1] system recording-scheme rec1        # 系统事件
[Switch-aaa-recording-rec1] outbound recording-scheme rec1      # 用户登出
[Switch-aaa-recording-rec1] quit
```

---

## 七、监控 / 排错命令速查

### 用户状态
```bash
display aaa online-user                       # 在线用户
display aaa online-user username <name>       # 指定用户
display aaa online-fail-record                # 上线失败记录
display aaa online-fail-record all            # 所有失败记录（看 reject 原因）
display aaa offline-record                    # 下线记录
display aaa user-record <user>                # 单用户记录
```

### 认证模板
```bash
display authentication-profile configuration name authen1
display authentication-profile configuration all
display authentication mode
```

### 服务器状态
```bash
display radius-server configuration template rad1
display radius-server accounting-stop-packet all
display hwtacacs-server template t1
```

### 802.1X 专项
```bash
display dot1x-access-profile configuration all
display dot1x                               # 接口 802.1X 状态
display dot1x interface gigabitethernet 0/0/1
```

### MAC 认证
```bash
display mac-authen                          # 接口 MAC 认证状态
display mac-authen interface gigabitethernet 0/0/2
```

### Portal
```bash
display portal interface gigabitethernet 0/0/3
display portal user all
```

### 802.1X 失败诊断（必查）
```bash
display aaa online-fail-record all           # User online fail reason 字段
#   - Radius authentication reject  → RADIUS 服务器拒绝（用户名/密码错）
#   - Radius server is unreachable   → 服务器不可达（网络/端口/密钥错）
#   - EAP timeout                    → 客户端 EAP 响应超时
display trapbuffer | include AAA             # AAA 相关 trap
display logbuffer | include RADIUS           # RADIUS 日志
```

---

## 八、平台差异

### S 系列 V200R022C00 vs V200R011C10
- **NAC 模式**：V200R022C10+ 默认 **unified-mode**（认证模板）；V200R011C10 默认 **common-mode**（接口下直接配置）
- **统一模式认证模板**：`authentication-profile`（新）
- **传统模式接口配置**：`dot1x enable` / `mac-authen enable`（旧）

### S 系列 vs CE 系列
- **CE 二阶段提交**（教训 #12）：配置改动后必须 `commit` 才生效
- **视图提示符**：CE 系列多 `<HUAWEI>` 用户视图外还有 `<......>` 子视图

### USG 防火墙
- USG 没有 802.1X（防火墙是网络层设备）
- USG 的 AAA 用于管理员登录认证（SSH / HTTPS / Console）
- USG 不支持 free-rule / Portal

### V200 vs V500/V600 防火墙 AAA
- **V500** 起 RADIUS / TACACS 标准命令
- **V600R007C20+** 增加 `access-domain force dot1x/mac/portal` 细化

---

## 九、常见排错（速查表）

> 详细排错见 `references/troubleshooting.md`

| 现象 | 根因 | 修法 |
|---|---|---|
| 用户反复认证失败 | `access-domain` 配错 / RADIUS 密钥不匹配 | 查 `display authentication-profile` + `display aaa online-fail-record` |
| 客户端收不到 EAP-Request | 接口没绑认证模板 / dot1x 没开 | `display authentication-profile configuration all` |
| EAP 中继 vs 终结 | 客户端或服务器不兼容 | 切换 `dot1x authentication-method {chap \| pap \| eap}` |
| 服务器不可达 | 网络 / 端口 / 密钥 | ping + telnet 服务器 1812 端口 + 比对密钥 |
| 认证通过但无网络 | 授权 ACL / 安全策略缺 | 查授权 ACL 是否下发正确 |

---

## 十、相关 skill

- **无线配置**：`network-huawei/wlan-ac-config/`（无线用户认证用 RADIUS）
- **防火墙**：`network-huawei/security-policy/`（USG 管理员登录 AAA）
- **设备登录**：`network-huawei/health-check/`（巡检）

---

## 十一、版本与文档

| 项 | 值 |
|---|---|
| 适用版本 | S V200R011C10+ / V200R022C00+ / CE V200R022+ / USG V500/V600 |
| 主文档 | 《802.1X 认证基础》02（2025-01-23）+《802.1X 认证失败故障处理》02（2020-12-30）+《配置 RADIUS 和 HWTACACS（V200）》01（2025-08-13）+《什么是 TACACS，如何配置 TACACS？》01 |
| 案例覆盖 | 802.1X + MAC + Portal + RADIUS + HWTACACS + 本地认证 |

---

> **版权**：本 skill 基于华为公开技术文档整理。所有命令引用均标注来源文档版本。
