CentOS7 搭建Radius认证服务器

打印 上一主题 下一主题

主题 887|帖子 887|积分 2661

CentOS7 搭建Radius认证服务器

一. 概述

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

1. 设置网络

  1. # 设置网络,使用的NetworkManager的nmtui自动分配的网络,这里不详细说明了,配好网络的可以跳过
  2. # nmtui
  3. # 关闭防火墙、selinux
  4. systemctl stop firewalld
  5. systemctl disable firewalld
  6. sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
  7. setenforce 0
复制代码
2. 安装基础工具

  1. # 安装数据库、vim 等应用和工具
  2. # yum不行可以切换阿里源
  3. yum groupinstall "Development tools" -y
  4. yum install telnet net-tools -y
  5. yum install httpd mariadb-server -y
  6. yum install php php-mysql php-gd php-ldap php-odbc -y
  7. yum install php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap -y
  8. yum install vim -y
  9. yum install lsof -y
复制代码
三. 安装 FreeRadius

安装 freeradius 并启动 mariadb、http
1. 安装 freeradius

  1. yum install freeradius freeradius-mysql freeradius-utils -y
复制代码
2. 启动 mariadb、http 服务

  1. # systemctl start mariadb
  2. systemctl restart mariadb
  3. systemctl restart httpd
复制代码
四. MySQL 数据库配置

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

  1. # Y Y N Y Y / Y Y N N Y
  2. mysql_secure_installation
复制代码
2. 创建 radius 数据库并设置暗码

  1. mysql -uroot -p
  2. create database radius;
  3. # 这个PASSWORD是密码,可以自定义换成自己的
  4. grant all privileges on radius.* to radius@localhost identified by 'PASSWORD';
  5. use radius;
  6. source /etc/raddb/mods-config/sql/main/mysql/schema.sql;
  7. quit;
复制代码
3. 重启数据库- dailordius

  1. systemctl restart mariadb
  2. ln -s /etc/raddb/mods-available/sql /etc/raddb/mods-enabled/
  3. chgrp -h radiusd /etc/raddb/mods-enabled/sql
复制代码
4. 修改 freeradius 配置文件

4.1 修改radiusd.conf

  1. vim /etc/raddb/radiusd.conf
  2. # 将下面三项内容修改为 yes
  3. auth = no
  4. auth_badpass = no
  5. auth_goodpass = no
  6. # 修改为
  7. auth = yes
  8. auth_badpass = yes
  9. auth_goodpass = yes
复制代码
4.2 修改default

  1. vim /etc/raddb/sites-available/default
  2. 1)将
  3. -sql
  4. 修改为
  5. sql
  6. 2)查找到 session { 中内容
  7. 去掉 sql 前面的注释
复制代码
4.3 修改sql

  1. vim /etc/raddb/mods-available/sql
  2. 1)将
  3. driver = "rlm_sql_null"
  4. 修改为
  5. driver = "rlm_sql_mysql"
  6. (2)将
  7. dialect = "sqlite"
  8. # server = "localhost"
  9. # port = 3306
  10. # login = "radius"
  11. # password = "radpass"
  12. 修改为
  13. dialect = "mysql"
  14. server = "localhost"
  15. port = 3306
  16. login = "radius"
  17. # PASSWORD输入上面MySQL里设置的密码
  18. password = "PASSWORD"
  19. (3)将
  20. # read_clients = yes
  21. 修改为
  22. read_clients = yes
复制代码
5. debug 调试

  1. radiusd -X
复制代码
出现以下情况表现正常:
  1. Listening on auth address * port 1812 bound to server default
  2. Listening on acct address * port 1813 bound to server default
  3. Listening on auth address :: port 1812 bound to server default
  4. Listening on acct address :: port 1813 bound to server default
  5. Listening on auth address 127.0.0.1 port 18120 bound to server inner-tunnel
  6. Listening on proxy address * port 55876
  7. Listening on proxy address :: port 44691
  8. Ready to process requests
复制代码
  报错可以使用radiusd -C 检查配置文件或者查看日志/var/log/radius/radius.log,查看端口netstat -tunlp | grep radius等方法处置处罚
  6. 启动 radius

  1. systemctl restart radiusd
  2. # 可能会出现启动失败地方情况,原因是端口被自己占用,以下方法解决
  3. # lsof -i :1812
  4. # kill 加上端口进程 ID
  5. # systemctl start radiusd
复制代码
五. 配置 daloradius

1. 上传文件解压移动

  1. tar zxvf daloradius-0.9-9.tar.gz
  2. mv daloradius-0.9-9 /var/www/html/daloradius
  3. chown -R apache:apache /var/www/html/daloradius/
  4. chmod 664 /var/www/html/daloradius/library/daloradius.conf.php
  5. cd /var/www/html/daloradius/
复制代码
2. 导入数据库

  1. mysql -u radius -p radius < contrib/db/fr2-mysql-daloradius-and-freeradius.sql
  2. 输入密码:PASSWORD
  3. mysql -u radius -p radius < contrib/db/mysql-daloradius.sql
  4. 输入密码:PASSWORD
复制代码
3. 修改 daloradis 数据库连接文件

  1. vim /var/www/html/daloradius/library/daloradius.conf.php
  2. $configValues['FREERADIUS_VERSION'] = '2';
  3. $configValues['CONFIG_DB_USER'] = 'root';
  4. $configValues['CONFIG_DB_PASS'] = '';
  5. 修改为:
  6. $configValues['FREERADIUS_VERSION'] = '2';
  7. $configValues['CONFIG_DB_USER'] = 'radius';
  8. $configValues['CONFIG_DB_PASS'] = 'PASSWORD';
  9. # 注意:如果版本修改为3的话,将不显示连接日志
复制代码
4. 安装 php-pear-DB

  1. # 说明:Centos 7 默认没有 php-pear-DB 安装包,否则无法进入 daloradius 为空白
  2. yum -y install epel-release
  3. yum -y install php-pear-DB
复制代码
5. 重启服务

  1. systemctl restart mariadb.service
  2. systemctl restart radiusd.service
  3. systemctl restart httpd
复制代码
6. 配置日志查询

  1. chmod 644 /var/log/messages
  2. chmod 755 /var/log/radius/
  3. chmod 644 /var/log/radius/radius.log
  4. touch /tmp/daloradius.log
  5. chmod 644 /tmp/daloradius.log
  6. chown -R apache:apache /tmp/daloradius.log
复制代码
7. 访问 daloradius

  1. http://IP/daloradius 访问
  2. 用户名:administrator
  3. 密码:radius
复制代码
六. 使用

Daloradius 配置用户及 NAS
1. 增加 vpn 账号及暗码


2. 增加 nas 信息

  1. NAS IP 0.0.0.0/0
  2. NAS-Secert:testing123
  3. NAS Type:other
  4. NAS Shortname :radius-network
  5. 其中0.0.0.0/0 表示任意 IP 都可以连接到 radius
  6. testing123 设置连接 radius 的共享密钥
复制代码

  1. #上面 nas 配置完成需要重启 radiusd 才能生效
  2. systemctl restart radiusd
复制代码
3. 测试账号连通性

测试之前添加一个用户
  1. radtest [用户] [密码] [访问的 ip] [端口] [密钥]
  2. radtest jack 1234567890 127.0.0.1 1812 testing123
复制代码
出现下面表现,代表连接乐成:
  1. Sent Access-Request Id 63 from 0.0.0.0:38938 to 127.0.0.1:1812 length 74
  2. User-Name = "jack"
  3. User-Password = "1234567890"
  4. NAS-IP-Address = 127.0.0.1
  5. NAS-Port = 1812
  6. Message-Authenticator = 0x00
  7. Cleartext-Password = "1234567890"
  8. Received Access-Accept Id 63 from 127.0.0.1:1812 to 0.0.0.0:0 length 20
复制代码
七. Radius 应用

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

   

  • AAA 服务 可提供认证、授权、计费等功能
  • 同一认证 对于工作人员的同一认证管理
  • 双因素认证 使用radius和OTP认证方式实现口令+动态暗码的方式实现双因素认证
  以上就是本次分享的内容,有错误的地方接待指出

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

滴水恩情

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表