欢迎,来自IP地址为:3.133.144.217 的朋友


RADIUS (Remote Authentication and Dial-In User Service)是用于拨号用户接入认证及服务请求认证的网络协议和软件。RADIUS会提供中心式认证、签权和计费(AAA)服务,用于管理接入用户使用网络资源。RADIUS允许使用集中式数据库来保存所有用户的配置信息,以供所有用户共享使用。

RADIUS 常常被 ISP (互联网服务提供商)用于管理互联网用户接入。

freeRADIUS  是一款免费开源RADIUS服务软件。由于  freeRADIUS  并不具有原生的web界面,使用起来相对麻烦,但是我们可以采用许多第三方web界面来管理和使用 freeRADIUS。

daloRADIUS便是一款功能强大且易于使用的RADIUS web界面,主要用于提供运营级热点及接入管理。daloRADIUS  使用PHP语言开发,并且支持多种数据库系统。

本文将详细演示如何在CentOS 7 系统安装 freeRADIUS  和  daloRADIUS。

需要强调的是,本文只侧重于  freeRADIUS  和  daloRADIUS 的安装和初始设置,对于如何使用则涉及较少。有兴趣了解  freeRADIUS  和  daloRADIUS  的话,可以参考  FreeRADIUS Beginner’s Guide daloRADIUS User Guide (Volume 1)

1.  系统说明

IP地址: 172.16.200.1/24
操作系统: CentOS 7.6
freeRADIUS版本: 3.0
daloRADIUS版本: 1.0

2. 安装必要软件包

我们首先需要安装一些必要的软件包,以便之后的安装顺畅执行,使用 yum命令安装相关软件:

# yum install -y wget unzip

一些必要软件会在额外软件库中找到,于是我们需要安装EPEL软件库:

# yum install -y epel-release

之后就可以如下命令重新缓存一下软件库信息:

# yum makecache fast

3. 安装MariaDB数据库并创建  freeRADIUS  使用的数据库

安装MariaDB数据库比较简单,这里不再赘述,使用如下命令安装、启动并到数据进行初始安全设置:

# yum install -y mariadb-server mariadb
# systemctl start mariadb
# mysql_secure_installation

数据库安装完成后,登录到数据库并创建”radius”数据库和同名用户:

# mysql -u root -p
MariaDB [(none)]> create database radius;
MariaDB [(none)]> grant all on radius.* to radius@localhost identified by 'daehub';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

4.  安装Apache Web服务器

由于daloRADIUS是PHP开发的Web应用,我们当然需要安装Apach Web服务器和PHP。首先使用如下命令安装Apache Web服务器并将其设置为开机启动:

# yum install -y httpd
# systemctl enable httpd
# systemctl start httpd

Yum 方式安装的Apache Web服务器默认设置已经非常完善,可以直接启动成功。如果想进一步增强其安全性,可以参考相关手册

5.  安装PHP

使用yum命令安装PHP以及相关的软件包:

# yum install -y php php-mysql php-pear php-devel php-common php-gd php-mbstring php-mcrypt php-xml php-pear-DB

安装成功后,使用如下命令重新启动Apache Web服务器以使PHP生效:

# systemctl restart httpd

6. 安装freeRADIUS

freeRADIUS 及其相关支持软件包已经在软件库中存在,所以可以使用yum工具方便的安装:

# yum install -y freeradius freeradius-utils freeradius-mysql

安装成功后,使用如下命令启动服务,并将radius服务添加至防火墙允许:

# systemctl start radiusd.service
# systemctl systemctl enable radiusd.service
# firewall-cmd --permanent --add-service=radius
# firewall-cmd --reload

7.   配置 freeRADIUS  连接  MariaDB数据库

freeRADIUS  默认直接使用文件来存储用户数据,我们需要配置 freeRADIUS 使用 MariaDB 来存储数据。首先,使用如下命令将 freeRADIUS 脚本导入数据库执行:

# mysql -u root -p radius < /etc/raddb/mods-config/sql/main/mysql/schema.sql

查看这个SQL脚本内容,知道该脚本会创建  freeRADIUS  需要使用的数据表。

然后我们需要修改 freeRADIUS 的配置文件”/etc/raddb/mods-available/sql”,用于指明 freeRADIUS 使用MariaDB数据库时所采用的基本配置。修改内容如下:

sql {
 driver = "rlm_sql_mysql"
 dialect = "mysql"
 
 # Connection info:
 server = "localhost"
 port = 3306
 login = "radius"
 password = "daehub"

 # Database table configuration for everything except Oracle
 radius_db = "radius"
 }

# Set to "yes" to read radius clients from the database ("nas" table)
# Clients will ONLY be read on server startup.
read_clients = yes
# Table to keep radius client info
client_table = "nas"

修改完成后,使用以下命令设置配置文件权限并重新启动 radiusd 服务:

# chgrp -h radiusd /etc/raddb/mods-available/sql
# systemctl restart radiusd.service

8.  安装daloRADIUS

daloRADIUS 是遵守  GPL 2.0  协议的开源软件,可以从Github获取完整的源代码。使用如下命令下载源代码、解压缩并将文件夹移动到Apache Web 服务器的工作目录:

# wget https://github.com/lirantal/daloradius/archive/master.zip
# unzip master.zip
# rm -f master.zip
# mv daloradius-master/ /var/www/html/daloradius

未关闭SELinux的系统需要使用如下命令还原SELinux的安全上下文:

# restorecon -Rv /var/www/html/daloradius/

现在,设置daloRADIUS目录的权限和属主信息:

# chown -R apache:apache /var/www/html/daloradius
# chmod -R 664 /var/www/html/daloradius/library/daloradius.conf.php

之后,就是打开防火墙的http服务:

# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload

然后,在MariaDB 的 radius 数据库中创建 daloRADIUS 需要使用的数据对象,直接导入源代码中的 SQL 脚本即可:

# mysql -u root -p radius < /var/www/html/daloradius/contrib/db/fr2-mysql-daloradius-and-freeradius.sql
# mysql -u root -p radius < /var/www/html/daloradius/contrib/db/mysql-daloradius.sql

最后,修改 daloRADIUS 的配置文件”/var/www/html/daloradius/library/daloradius.conf.php”,将其中的连接数据库密码设置为之前设置的密码:

$configValues['CONFIG_DB_USER'] = 'radius';
$configValues['CONFIG_DB_PASS'] = 'daehub';

现在,通过浏览器访问”http://172.16.200.1/daloradius”,就会看出如下页面:

使用默认的用户名”administrator”和密码”radius”就可以顺利登录到系统中,使用该程序进行freeRADIUS 的管理:

至此,CentOS 7 系统安装 freeRADIUS 以及 daloRADIUS  就全部完成了。

One thought on “CentOS 7 系统安装 freeRADIUS 以及 daloRADIUS”

  1. 到最后显示数据库无法链接 是怎么回事 希望得到 大佬的指点
    Database connection error
    Error Message: DB Error: connect failed

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注