CentOS7 搭建Radius认证服务器
创始人
2024-09-26 16:26:22
0

CentOS7 搭建Radius认证服务器

一. 概述

本手册是实现如下功能:CentOS7上部署 freeradius 服务、radius 简单使用、堡垒机实现radius用户认证。

二. CentOS7 环境准备

1. 设置网络

# 设置网络,使用的NetworkManager的nmtui自动分配的网络,这里不详细说明了,配好网络的可以跳过 # nmtui # 关闭防火墙、selinux systemctl stop firewalld  systemctl disable firewalld sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config  setenforce 0 

2. 安装基础工具

# 安装数据库、vim 等应用和工具 yum groupinstall "Development tools" -y yum install telnet net-tools -y yum install httpd mariadb-server -y yum install php php-mysql php-gd php-ldap php-odbc -y yum install php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap -y  yum install vim -y yum install lsof -y 

三. 安装 FreeRadius

安装 freeradius 并启动 mariadb、http

1. 安装 freeradius

yum install freeradius freeradius-mysql freeradius-utils -y 

2. 启动 mariadb、http 服务

# systemctl start mariadb systemctl restart mariadb systemctl restart httpd 

四. MySQL 数据库配置

1. 对 MySQL 数据库进行初始化

# Y Y N Y Y / Y Y N N Y mysql_secure_installation 

2. 创建 radius 数据库并设置密码

mysql -uroot -p  create database radius; grant all privileges on radius.* to radius@localhost identified by 'PASSWORD'; use radius; source /etc/raddb/mods-config/sql/main/mysql/schema.sql; quit; 

3. 重启数据库- dailordius

systemctl restart mariadb ln -s /etc/raddb/mods-available/sql /etc/raddb/mods-enabled/ chgrp -h radiusd /etc/raddb/mods-enabled/sql 

4. 修改 freeradius 配置文件

4.1 修改radiusd.conf
vim /etc/raddb/radiusd.conf # 将下面三项内容修改为 yes auth = no auth_badpass = no auth_goodpass = no # 修改为 auth = yes auth_badpass = yes auth_goodpass = yes 
4.2 修改default
vim /etc/raddb/sites-available/default 1)将 -sql 修改为 sql 2)查找到 session { 中内容 去掉 sql 前面的注释 
4.3 修改sql
vim /etc/raddb/mods-available/sql 1)将 driver = "rlm_sql_null" 修改为 driver = "rlm_sql_mysql" (2)将  dialect = "sqlite" # server = "localhost" # port = 3306 # login = "radius" # password = "radpass" 修改为  dialect = "mysql"  server = "localhost"  port = 3306  login = "radius"  password = "passwd-radius" (3)将 # read_clients = yes 修改为  read_clients = yes 

5. debug 调试

radiusd -X 

出现以下情况表示正常:

Listening on auth address * port 1812 bound to server default Listening on acct address * port 1813 bound to server default Listening on auth address :: port 1812 bound to server default Listening on acct address :: port 1813 bound to server default Listening on auth address 127.0.0.1 port 18120 bound to server inner-tunnel Listening on proxy address * port 55876 Listening on proxy address :: port 44691 Ready to process requests 

6. 启动 radius

systemctl restart radiusd # 可能会出现启动失败地方情况,原因是端口被自己占用,以下方法解决 # lsof -i :1812 # kill 加上端口进程 ID # systemctl start radiusd 

五. 配置 daloradius

1. 上传文件解压移动

tar zxvf daloradius-0.9-9.tar.gz mv daloradius-0.9-9 /var/www/html/daloradius chown -R apache:apache /var/www/html/daloradius/ chmod 664 /var/www/html/daloradius/library/daloradius.conf.php cd /var/www/html/daloradius/ 

2. 导入数据库

mysql -u radius -p radius < contrib/db/fr2-mysql-daloradius-and-freeradius.sql 输入密码:PASSWORD mysql -u radius -p radius < contrib/db/mysql-daloradius.sql 输入密码:PASSWORD 

3. 修改 daloradis 数据库连接文件

vim /var/www/html/daloradius/library/daloradius.conf.php 将 $configValues['FREERADIUS_VERSION'] = '2'; $configValues['CONFIG_DB_USER'] = 'root'; $configValues['CONFIG_DB_PASS'] = ''; 修改为: $configValues['FREERADIUS_VERSION'] = '2'; $configValues['CONFIG_DB_USER'] = 'radius'; $configValues['CONFIG_DB_PASS'] = 'passwd-radius'; # 注意:如果版本修改为3的话,将不显示连接日志 

4. 安装 php-pear-DB

# 说明:Centos 7 默认没有 php-pear-DB 安装包,否则无法进入 daloradius 为空白 yum -y install epel-release yum -y install php-pear-DB 

5. 重启服务

systemctl restart mariadb.service  systemctl restart radiusd.service systemctl restart httpd 

6. 配置日志查询

chmod 644 /var/log/messages chmod 755 /var/log/radius/ chmod 644 /var/log/radius/radius.log touch /tmp/daloradius.log chmod 644 /tmp/daloradius.log chown -R apache:apache /tmp/daloradius.log 

7. 访问 daloradius

http://IP/daloradius 访问 用户名:administrator 密码:radius 

六. 使用

Daloradius 配置用户及 NAS

1. 增加 vpn 账号及密码

在这里插入图片描述

2. 增加 nas 信息

NAS IP 0.0.0.0/0  NAS-Secert:testing123 NAS Type:other NAS Shortname :radius-network 其中0.0.0.0/0 表示任意 IP 都可以连接到 radius testing123 设置连接 radius 的共享密钥 

在这里插入图片描述

#上面 nas 配置完成需要重启 radiusd 才能生效 systemctl restart radiusd 

3. 测试账号连通性

测试之前添加一个用户

radtest [用户] [密码] [访问的 ip] [端口] [密钥] radtest jack 1234567890 127.0.0.1 1812 testing123 

出现下面显示,代表连接成功:

Sent Access-Request Id 63 from 0.0.0.0:38938 to 127.0.0.1:1812 length 74 User-Name = "jack" User-Password = "1234567890" NAS-IP-Address = 127.0.0.1 NAS-Port = 1812 Message-Authenticator = 0x00 Cleartext-Password = "1234567890" Received Access-Accept Id 63 from 127.0.0.1:1812 to 0.0.0.0:0 length 20 

七. Radius 应用

1. radius 在尚思堡垒机中可以实现哪些功能

  1. AAA 服务 可提供认证、授权、计费等功能
  2. 统一认证 对于工作人员的统一认证管理
  3. 双因素认证 使用radius和OTP认证方式实现口令+动态密码的方式实现双因素认证

以上就是本次分享的内容,有错误的地方欢迎指出

相关内容

热门资讯

重大通报,金花房卡是正规的西兵... 重大通报,金花房卡是正规的西兵互娱/随意玩/房卡链接在哪购买西兵互娱/随意玩是一款非常受欢迎的游戏,...
ia攻略/金花房间怎么创建金牛... 金牛座厅/新西部是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:【3329006910】或QQ:33...
正规平台有哪些,牛牛房卡制作链... 天龙大厅房卡更多详情添加微:33549083、 2、在商城页面中选择房卡选项。 3、根...
头条推荐!金花房卡批发价小拇指... 头条推荐!金花房卡批发价小拇指大厅/正规房卡链接在哪购买小拇指大厅是一款非常受欢迎的游戏,咨询房/卡...
推荐一款!金花房间怎么创建黄帝... 推荐一款!金花房间怎么创建黄帝大厅/房卡是在哪里买的Sa9Ix苹果iPhone 17手机即将进入量产...
推荐一款!金花房卡是正规的海贝... 今 日消息,海贝大厅/新天道房卡添加微信33549083 苹果今日发布了 iOS 16.1 正式版更...
正规平台有哪些,牛牛房卡出售新... 正规平台有哪些,牛牛房卡出售新蜜瓜大厅/微信链接房卡从哪里购买新蜜瓜大厅是一款非常受欢迎的游戏,咨询...
正版授权!游戏推荐牛牛房卡出售... 芙蓉大厅是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:【3329006910】或QQ:332900...
ia攻略/牛牛房卡制作链接樱花... 您好!微信樱花大厅/新道游大厅链接获取房卡可以通过以下几种方式购买: 1.微信渠道:(樱花大厅/新...
一分钟了解!微信金花房卡怎么弄... 今 日消息,宝马系列/随意玩房卡添加微信33549083 苹果今日发布了 iOS 16.1 正式版更...
玩家攻略,金花房卡制作链接海米... 玩家攻略,金花房卡制作链接海米大厅/房卡购买批发价格海米大厅是一款非常受欢迎的游戏,咨询房/卡添加微...
我来教你/金花房卡官网钻石大厅... 我来教你/金花房卡官网钻石大厅/微信链接房卡充值购买Sa9Ix苹果iPhone 17手机即将进入量产...
正版授权!金花房卡专卖店新详心... 您好!微信新详心/飞鹰大厅大厅链接获取房卡可以通过以下几种方式购买: 1.微信渠道:(新详心/飞鹰...
正规平台有哪些,金花房卡批发价... 今 日消息,金牛座房卡添加微信33549083 苹果今日发布了 iOS 16.1 正式版更新,简单介...
玩家攻略,金花房卡出售九哥联盟... 玩家攻略,金花房卡出售九哥联盟/房卡在哪里购买九哥联盟是一款非常受欢迎的游戏,咨询房/卡添加微信:8...
推荐一款!如何购买金花房卡久久... 推荐一款!如何购买金花房卡久久大厅/微信链接房卡购买联系方式Sa9Ix苹果iPhone 17手机即将...
正版授权!斗牛房卡充值新详心/... 新详心/飞鹰大厅房卡更多详情添加微:33549083、 2、在商城页面中选择房卡选项。 ...
头条推荐!牛牛房卡代理新鸿狐大... 头条推荐!牛牛房卡代理新鸿狐大厅/随意玩/微信链接房卡从哪里获取新鸿狐大厅/随意玩是一款非常受欢迎的...
ia攻略/斗牛房卡充值海螺互娱... ia攻略/斗牛房卡充值海螺互娱/一张房卡多少钱微信链接Sa9Ix苹果iPhone 17手机即将进入量...
一分钟了解!斗牛房卡充值新道游... 新道游/新皇豪房卡更多详情添加微:33549083、 2、在商城页面中选择房卡选项。 ...