「RADIUS」- 远程认证拨号用户服务 | Remote Authentication Dial In User Service

认识

RADIUS,Remote Authentication Dial-In User Service,远程认证拨号用户服务)是一种网络协议,用于集中化管理 AAA,通常用于企业网络、ISP、Wi-Fi 和 VPN 接入等场景

RADIUS 是一种分布式的、C/S 架构的信息交互协议,能保护网络不受未授权访问的干扰,常应用在既要求较高安全性、又允许远程用户访问的各种网络环境中。

组成

At the time RADIUS was created, network access systems were distributed across a wide area and were run by multiple independent organizations. Central administrators wanted to prevent problems with security and scalability, and thus did not want to distribute user names and passwords; instead, they wanted the remote access servers to contact a central server to authorize access to the requested system or service. In response to contact from the remote access server, the central server would return a “success” or “failure” message, and the remote machines would be in charge of enforcing this response for each end user.

基本架构

其采用 Client/Server 模型,主要包含如下角色:

User | Device | Terminal | …

构造:Laptop; ADSL Modem; VOIP Phone;

性质:Requests access to the network.

Network Access Server | NAS | RADIUS Client | …

构造:通常是网络设备(例如,Switch、AP、VPN Gateway、……),Switch; Wireless AP; DSLAM; VPN Terminator,Common RADIUS server products include Cisco ACS, Microsoft IAS, Funk (now Juniper) Steel Belted RADIUS, Open Systems Radiator, and FreeRADIUS. Common NAS products include wireless access points such as the Linksys WRT54G and dial-up equipment commonly available from large network manufacturers.

性质:负责转发用户认证请求到服务器。Provides access to the network for the user/device;该转发过程使用 Authentication Session 术语来描述;用户或设备的登陆操作将触发 Authentication Session 的建立;A RADIUS client (also called a Network Access Server, or NAS) sends requests to a RADIUS server. The RADIUS server then processes the request and sends back a response.

Authentication Server | RADIUS Server | …

构造:FreeRADIUS; Radiator; IAS; Microsoft NPS; ACS;

性质:集中处理认证请求,返回认证结果;Receives authentication requests from the NAS; Returns authentication results to the NAS; ptionally requests user and configuration information from the database or directory; May return configuration parameters to the NAS; Receives accounting information from the NAS;

Data Store

构造:用户数据库存储用户凭证(例如 LDAP、Active Directory、MySQL、……);SQL Database; Kerberos Service Server; LDAP Directory;

性质:Optional database or directory with user authentication and authorisation information. RADIUS server communicates with the data store using DB API or LDAP.

交互流程

其核心工作原理可分为两大流程:

  • Authentication && Authorization
  • Accounting

针对 Authentication && Authorization 阶段:

  1. 用户发起连接请求。
    1. 用户设备发送认证请求(例如,输入 Username/Password 或触发 802.1X EAP 认证)。

  1. NAS 发送 RADIUS Access-Request 消息
    1. NAS 使用预共享密钥来认证,否则 RADISU Server 拒绝 NAS 访问
    2. NAS 将用户信息(用户名、密码或 EAP 响应)封装为 Access-Request 报文,发送给 RADIUS Server
    3. NAS 选择一种认证协议(例如,PAP、CHAP、EAP、……)来提交 Device 的认证信息。如果 RADIUS Server 不支持该认证协议,则请求会被拒绝。
    4. 发送到 RADIUS Server 的所有信息均由 NAS 自行决定,RADIUS Server 不控制 NAS 发送的内容。
    5. 关键字段:User-Name;User-Password(加密密码,使用 PSK + MD5 哈希);NAS-IP-Address;NAS-Identifier;EAP-Message(若使用 EAP 认证,如 WPA2-Enterprise)

  1. RADIUS Server 处理请求
    1. 服务器检查共享密钥是否匹配,解密密码(若为 PAP 认证)。
    2. 查询数据库(例如,LocalDB、LDAP、AD、Kerberos、Database、……)来验证用户身份。
    3. 决定授权策略(例如,该用户的 VLAN 信息、该用户的带宽限制、……)。

  1. RADIUS Server 发送响应
    1. 成功:返回 Access-Accept 信息,附带授权属性(例如,VLAN-ID、Session-Timeout、……)。
    2. 失败:返回 Access-Reject 信息,拒绝接入。
    3. Access Challenge:当服务器需要用户提供更多信息时,就会发生 Access Challenge。由于 RADIUS 数据包的大小有限,Access Challenge 允许交换大量数据。

针对 Accounting 阶段:

  1. 当会话开始时,
    1. NAS 发送 Accounting-Request (Start) 到 RADIUS Server
    2. 包含:Acct-Session-Id(会话唯一标识)、Framed-IP-Address(用户 IP)、NAS-Port(物理端口号);

  1. 会话进行中(可选)
    1. 定期发送 Accounting-Request (Interim-Update),更新在线状态。

  1. 会话结束时,
    1. NAS 发送 Accounting-Request (Stop),
    2. 包含:Acct-Session-Time(在线时长)、Acct-Input-Octets(上行流量)、

协议报文

该协议定义基于 UDP 的 RADIUS 报文格式及其传输机制。

  • 默认认证端口:1812
  • 默认计费端口:1813

针对早期版本的协议,其使用 1645/1646,但已被 IANA 重新分配。

属性值对 | AVP | Attribute Value Pair

RADIUS 使用 Attribute(属性)传递信息,Attribute List,https://www.freeradius.org/rfc/attributes.html
Basic RADIUS attribute types are defined in RFC 2865 | http://tools.ietf.org/html/rfc2865

属性编号名称用途
1 User-Name 用户名(如 user@domain)
2 User-Password 加密的密码(使用共享密钥保护)
8 Framed-IP-Address 分配给用户的 IP 地址
26 Vendor-Specific 厂商自定义属性(如 Cisco、华为)
79 EAP-Message 封装 EAP 认证数据(用于 WPA2-Enterprise)

针对 Attribute 名称,平时,我们使用文本来表示,在报文中,则使用二进制数值来表示。当 RADIUS Server 处理报文时,通过该二进制数值,在“字典文件”中查找对应的 Attribute 信息(例如,名称、类型、……)。同样,当 RADIUS Server 发送报文时,同样使用该“字典文件”来编码数据。

Server-Side Attributes | Non-Protocol Attributes | 其指在 RADIUS Server 内部使用的标签,不会在网络中进行传递的标签。这些标签用于在 RADIUS Server 内部传递,控制 RADIUS Server 的行为。该类标签与 RAIDUS Server 实现相关,针对不同厂商的 RADIUS Server 实现,其通常具有不同的内部标签。

当处理请求时,RADIUS Server 会根据本地策略,进行 Attribute 的处理,

且通常(并非所有)RADIUS Server 会维护多个标签列表,

  • Request Attribute List:该列表包含请求报文的标签;
  • Reply Attribute List:该列表包含响应报文的标签;
  • Config Attribute List:该列表包含内部的标签,该类标签控制 RADIUS Server 行为;

构建

FreeRADIUS(开源,最流行)
Windows NPS(Windows Network Policy Server,集成 AD)
Cisco ISE(企业级 AAA 解决方案)
JumpCloud(云 RADIUS 服务)

性质

  • An open and scalable solution —— 其易于修改的特性使得用户能够根据需求进行定制,以实现与各种安全系统的对接。
  • Broad support by a large vendor base ——
  • Easy modification
  • Separation of security and communication processes
  • Adaptable to most security systems
  • Workable with any communication device that supports RADIUS client protocol —— 支持 RADUIS 协议的设备都能够通过 RADIUS 进行认证和授权。

Change of Authorization (CoA)

  • 描述:Change of Authorization (CoA,授权变更) 是 RADIUS 协议的一个扩展功能,允许在会话进行中动态修改已认证用户的授权属性,而无需用户重新认证或断开连接。
  • 原理:CoA-Request:由 RADIUS 服务器发送给网络接入服务器(NAS),请求更改授权;CoA-Ack:NAS 成功执行变更后的确认响应;CoA-Nak:NAS 无法执行变更时的否定响应;
  • 应用:服务质量(QoS)策略的实时调整;VLAN 成员资格的变更;带宽限制的调整;……

核心功能

其主要是为了实现 AAA 模型,所以其核心功能即 AAA 模型:

  • 认证(Authentication):验证用户身份(如用户名 / 密码、证书、OTP)。
  • 授权(Authorization):决定用户可访问的资源(如 VLAN、带宽限制)。
  • 计费(Accounting):记录用户会话信息(如在线时长、流量使用)。

可扩展性

RADIUS 协议具有良好的可扩展性,协议(RFC2865)中定义的 26 号属性(Vendor-Specific)用于设备厂商对 RADIUS 进行扩展,以实现标准 RADIUS 没有定义的功能。华为公司的 RADIUS 扩展属性可参考具体产品文档。

安全特性

共享密钥(Shared Secret)

  • RADIUS 客户端和服务器之间使用共享密钥加密敏感数据(如密码)。
  • User-Password 字段使用 MD5 + 共享密钥加密(安全性较弱,建议结合 EAP 使用)。

EAP 集成(更安全)

  • 在 WPA2/WPA3-Enterprise 中,RADIUS 通过 EAP-Message 属性传输 EAP 认证数据(如 EAP-TLS、PEAP)。
  • 相比传统密码认证,EAP 支持证书、双因素认证等更安全的方式。

IPsec 或 TLS 保护(RadSec)

  • 传统 / 标准 RADIUS 使用 UDP 报文,可能被窃听。
  • RadSec(RADIUS over TLS)通过 TCP/2083 加密整个通信。

应用

Commonly used by Internet Service Providers (ISPs), cellular network providers, and corporate and educational networks.

作为 AAA Server 运行,提供认证与计费功能;

企业 Wi-Fi(WPA2/WPA3-Enterprise)

  • 员工连接 Wi-Fi 时,AP(RADIUS 客户端)将认证请求转发至 RADIUS 服务器。
  • 服务器验证用户身份(如 Active Directory),并返回 VLAN、带宽策略等;

VPN 远程接入

  • 用户登录 VPN 时,防火墙(RADIUS 客户端)向 RADIUS 服务器请求认证。

ISP 拨号 /PPPoE

  • 传统拨号上网场景,BRAS 设备通过 RADIUS 验证用户并记录流量。

网络设备管理

  • 通过使用 RADIUS 认证,交换机、路由器来允许管理员登录(替代本地账号)。

参考

DeepSeek / 介绍 RADIUS
DeepSeek / 介绍 RADIUS 协议的工作原理
DeepSeek / 介绍 RADIUS 的 Change of Authorization