「FreeRADIUS」- 开源 RADIUS 实现 | The Open Source Implementation of RADIUS

认识

官网:https://www.freeradius.org
文档:https://www.freeradius.org/documentation
仓库:https://github.com/FreeRADIUS/freeradius-server

FreeRADIUS,是个开源的 RADIUS 服务,是功能强大且灵活的 RADIUS 服务器,其适用于各种网络认证场景,广泛用于网络 AAA。它是目前最流行的 RADIUS 服务器之一,其适用于多种场景,例如、企业、ISP(互联网服务提供商)、Wi-Fi 热点、VPN、……。无论是小型企业还是大型运营商,都能通过其模块化设计满足定制化需求。学习曲线较陡,但丰富的文档和社区支持降低了使用门槛。简而言之,FreeRADIUS 是开源、功能强大的 RADIUS Server 实现,我们能够用它来提供 RADIUS 服务。

组成

程序文件

radiusd:服务端程序
freeradius:

配置文件

针对配置文件路径,其通常位于:

  • Linux: /etc/freeradius/
  • FreeBSD: /usr/local/etc/raddb/

radiusd.conf:主配置文件,定义全局设置,并引用其他配置文件。

clients.conf:定义允许连接的 RADIUS Client 信息(例如,交换机、AP、IP Address、Pre-shared Key、……)。

  • 该配置文件被 radiusd.conf 引用。

dictionary:包含 RADIUS Server 需要使用的 Attribute 信息。

proxy.conf:包含上游服务器的配置信息(例如,IP Address、Pre-shared Key、……)。

  • 该配置文件被 radiusd.conf 引用。

sites-available/default

  • 默认的 Virtual Server 配置,该配置文件被 radiusd.conf 引用。
  • 处理认证、计费;定义认证流程的处理方式(例如,EAP 处理方式、……)。

sites-enabled/inner-tunnel

  • 该 Virtual Server 负责处理在 TLS Tunnel 内传输的认证方法,作为 PEAP 或 EAP-TTLS 认证的一部分。

users

  • 认识:本地用户认证文件(可替代数据库)。根据配置文件描述,模块 rlm_files 将使用该文件。The rlm_files module uses the ‘users’ file for accessing authorization information for users. —— https://www.freeradius.org/radiusd/man/rlm_files.html
  • 组成:参考 SDL_FreeRADIUS_Tech_Guide_5_Feb.recover.fm 文档,以获得关于该 users 配置文件的说明。

certs/ This sub-directory stores EAP certificates.

mods-available/ 模块配置(如 LDAP、SQL 集成)。A directory to store module configurations files that network administrators can enable on an optional basis. Each module is configured in a different file in the directory. The files in this directory are loaded from radiusd.conf.

mods-enabled/ A directory to store module configuration files. These are usually soft links to files in the mods-available/ directory.

sites-available/ A directory to store virtual servers that administrators can enable. Each virtual server encapsulates one logical set of functionality.

sites-enabled/ A directory to store virtual servers. These are usually soft links to files in the sites-available/ directory.

sql/ A directory to store more SQL configuration files for various types of databases, such as MySQL, PostgreSQL, or Oracle. There are sub-directories for each SQL database type.

acct_users A users file for Accounting-Request packets.

hints The traditional RADIUS configuration file for giving PPP or SLIP hints as part of a User-Name.

huntgroups The traditional RADIUS configuration file for groups of clients.

服务启动

The FreeRADIUS Server / Introduction / radiusd -X | https://www.freeradius.org/documentation/freeradius-server/3.2.8/radiusd_x.html | 该文档介绍 radiusd 服务的启动过程,例如配置文件加载、模块加载、消息处理、日志信息、……

构建

NetworkRADIUS —— We are the company behind FreeRADIUS. Led by Alan DeKok, Network RADIUS SARL provides FreeRADIUS system support and development to clients worldwide.

Building FreeRADIUS | https://wiki.freeradius.org/building/Home | 通过源码来构建 FreeRADIUS 的方法。

服务部署

Installing and upgrading | https://www.freeradius.org/documentation/freeradius-server/3.2.8/installation/index.html

Ubuntu RADIUS Server Setup | https://linuxhint.com/ubuntu-radius-server-setup

apt-get install -y \
    freeradius freeradius-common freeradius-config freeradius-utils freetds-common \
    libct4 libdbi-perl libfreeradius3

on Kubernetes | with Helm Chart | by Startechnica | https://artifacthub.io/packages/helm/startechnica/freeradius

helm repo add startechnica https://startechnica.github.io/apps
helm repo update startechnica

helm pull startechnica/freeradius # appVersion: 3.2.7
helm show values ./freeradius-1.0.3.tgz > freeradius-1.0.3.tgz.helm-values.yaml

vim freeradius-1.0.3.tgz.helm-values.yaml
... fullnameOverride: "freeradius"
... nameOverride: "freeradius"
... auth.clientUser: "local-admin"
... auth.clientUser: "xxxxxxx"

测试调试

# radtest test password localhost 0 testing123

How to use radiusd -X (debug mode) | https://wiki.freeradius.org/guide/radiusd-X

性能调优

1.3 FreeRADIUS Case Studies

性质

认证(Authentication)

支持多种认证协议,如 PAP、CHAP、MS-CHAP、EAP(包括 EAP-TLS、EAP-PEAP、EAP-TTLS 等)。

可对接多种后端数据库(MySQL、PostgreSQL、LDAP、Active Directory、Redis 等)进行用户认证。

授权(Authorization)

根据用户或设备属性(如 MAC 地址、VLAN、IP 地址)分配网络权限。

支持动态 VLAN 分配、带宽限制、会话超时等策略。

计费(Accounting)

记录用户会话信息(登录 / 登出时间、数据流量、会话时长等)。

支持 RADIUS Accounting 标准,可生成日志或存储到数据库用于计费分析。

支持多种能够协议 | Authentication Protocol

兼容 RFC 2865(RADIUS)和 RFC 2866(RADIUS Accounting)。

支持扩展属性(Vendor-Specific Attributes, VSAs),适用于 Cisco、Juniper 等厂商设备。

虚拟服务器 | Virtual Server

The use of virtual servers means that complex implementations are simplified and ongoing support and maintenance costs for network administrators are greatly reduced; thus, the ability of FreeRADIUS to support virtual servers gives it a huge advantage over the competition.

可扩展性 | Scalability

A single RADIUS server can easily transition from handling one request every few seconds to handling thousands of requests per second, simply by reconfiguring a few default settings.

模块化架构 | Modularity

通过模块(如 rlm_ldap、rlm_sql)灵活扩展功能。

支持多种脚本语言(例如,Perl、Python、……)编写自定义逻辑。

其他特性

开源免费:无商业许可限制。
高度可定制:支持插件和脚本扩展。
广泛兼容:与大多数网络设备(Cisco、Huawei、Aruba)兼容。
活跃社区:文档丰富,问题易解决。

应用

ISP(互联网服务提供商)

管理 PPPoE、宽带拨号用户。

教育机构

对接校园网认证(如 Eduroam)。

云计算

与 OpenStack、Kubernetes 集成,提供网络访问控制。

企业网络

用于 VPN、Wi-Fi 认证(例如,802.1X、……)。

通过 LDAP 认证,实现 VPN 登陆:Windows 10 IKEv2 (User name and password) ⇒ pfSense IKEv2 (EAP-RADIUS) ⇒ RADIUS (modules/Rlm_ldap) ⇒ LDAP
https://www.freeradius.org/documentation/freeradius-server/3.2.8/concepts/modules/ldap/authentication.html

生态环境

RADIUS Client:radtest、NTRadPing(Windows)。
可视化管理:Daloradius、FreeRADIUS-WPE(用于教育测试)。
与 802.1X 集成:配合 Hostapd(Wi-Fi)、OpenVPN 使用。

改进

The FreeRADIUS Server/Developers | https://www.freeradius.org/documentation/freeradius-server/3.2.8/developers/index.html

参考

THE FREERADIUS TECHNICAL GUIDE | https://networkradius.com/doc/FreeRADIUS%20Technical%20Guide.pdf

The online documentation is automatically built from the doc directory which comes with the server. Every configuration file contains detailed documentation on what the file does, and what can be configured. | https://www.freeradius.org/documentation/freeradius-server/3.2.8/

The raddb/sites-available directory contains many example “virtual servers”. Each example has comments describing what it does, when it should be used, and how to configure it. | https://github.com/FreeRADIUS/freeradius-server/tree/v3.2.x/raddb/sites-available/