yum install -y freeradius freeradius-utils freeradius-mysql mariadb-server
rpm -qa |grep mariadb
rpm -qa |grep freeradius
systemctl start mariadb.service #启动数据库
systemctl enable mariadb.service #添加开机自启动
systemctl start radiusd.service #启动 radiusd 服务
systemctl enable radiusd.service # 添加开启自启动
vi /usr/lib/systemd/system/radiusd.service
1)设置数据库密码、远程访问
设置 mysql 数据库密码,执行以下命令
mysql
MariaDB [(none)]> SET password for 'root'@'localhost'=password('123456'); # 123456 为数据库密码
MariaDB[(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
MariaDB [(none)]> flush privileges;
mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.3.2-MariaDB-log MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database radius;
Query OK, 1 row affected (0.09 sec)
MariaDB [(none)]> exit;
Bye
mysql -u root -p123456 radius < /etc/raddb/mods-config/sql/main/mysql/schema.sql
mysql -uroot -p123456
MariaDB [(none)]> show databases;
MariaDB [(none)]> use radius;
MariaDB [radius]> show tables;
MariaDB [radius]> exit
radcheck 用户检查信息表
radreply 用户回复信息表
radgroupcheck 用户组检查信息表
radgroupreply 用户组检查信息表
radusergroup 用户和组关系表
radacct 计费情况表
radpostauth 认证后处理信息,可以包括认证请求成功和拒绝的记录
cd /etc/raddb/mods-enabled
ln -s ../mods-available/sql
vi /etc/raddb/mods-available/sql
找到 driver = “rlm_sql_null” 这一行,修改为 driver = “rlm_sql_mysql” 保存并退出,保持与截图一致
找到 dialect = “sqlite” 这一行,修改为 dialect = “mysql” 保存并退出,保持与截图一致
server : MariaDB 数据库IP地址,若Radius和 MariaDB 同一服务器可默认为 “localhost“
port : MariaDB 数据库端口默认为”3306”
login : MariaDB数据库登录用户名”root”
password : MariaDB数据库root用户登录密码
mysql -uroot -p123456
use radius;
insert into radgroupreply (groupname,attribute,op,value) values ('user','Auth-Type',':=','Local');
insert into radgroupreply (groupname,attribute,op,value) values ('user','Service-Type',':=','Framed-User');
insert into radgroupreply (groupname,attribute,op,value) values ('user','Framed-IP-Address',':=','255.255.255.255');
insert into radgroupreply (groupname,attribute,op,value) values ('user','Framed-IP-Netmask',':=','255.255.255.0');
insert into radcheck (username,attribute,op,value) values ('test','Cleartext-Password',':=','testpwd');
insert into radusergroup (username,groupname) values ('test','user');
systemctl stop radiusd.service
radiusd -X
radtest test testpwd localhost 1812 testing123
systemctl start firewalld.service #启动
systemctl enable firewalld.service #开机自启
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=1812/tcp --permanent
firewall-cmd --zone=public --add-port=1812/udp --permanent
firewall-cmd --reload
vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port=3307 #修改此处
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
若 mysql 启动失败可在 该目录查看 报错日志 /var/log/mariadb/mariadb.log
Radius 日志默认路径为 /var/log/radius/radius.log
使用第三方 Radius 工具测试 如 RadiusTest 需要在 Radius 服务器中的 /etc/raddb/clients.conf 配置文件中增加 clients 的请求地址和标示
文中提及的替换文件下载地址 链接: https://pan.baidu.com/s/1IvOlAw53_k9B4LpY841nnw 提取码: hyje