FreeRADIUS是GNU通用公共许可证开发的高性能开源RADIUS服务器。
FreeRADIUS是世界上使用最多的RADIUS服务器。FreeRADIUS带有基于Web的用户管理工具,是模块化,可扩展性和丰富的功能集。
亲测成功在CentOS 7上安装FreeRADIUS和Daloradius使用。
注意:本文所有命令均在root命令下执行。
在开始安装之前,建议关闭SELinux或将其设置为disabled,最好建议永久关闭SELinux:
# sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
重启系统:reboot,重启完成后查看SELinux
# /usr/sbin/sestatus -v
注意使用腾讯YUM源,如下:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
安装工具:wget和vim
# yum -y install wget vim
安装Apache服务器
# yum -y install httpd httpd-devel
- 设置开机启动和启动Apache服务
# systemctl enable httpd # systemctl start httpd
启动之后浏览器中输入本机ip,可以看到Apache主页。如果打不开网页,提示空白或者网站错误,就是防火墙的问题,Centos7默认防火墙是开的,不要关闭防火墙,只要在防火墙里把80端口放行就可以了。
# firewall-cmd --permanent --add-port=80/tcp
# firewall-cmd --reload
刷新网页就打开了。
安装MariaDB
-
为什么不用Mysql?
答:MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。
-
安装
# yum install -y mariadb-server mariadb
-
设置MariaDB开机启动和启动MariaDB服务
# systemctl start mariadb # systemctl enable mariadb
-
查看MariaDB状态,running已经运行
# systemctl status mariadb
-
初始设置MariaDB,设置root密码,出于安全考虑,考虑删除匿名用户和禁用远程根登录,参见下面的示例配置。
# mysql_secure_installation
Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
-
创建Radius数据库和用户名密码
# mysql -u root -p MariaDB [(none)]> CREATE DATABASE radius; MariaDB [(none)]> GRANT ALL ON radius.* TO radius@localhost IDENTIFIED BY "radius"; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
安装PHP7
-
安装
# yum install -y php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis
- 查看php版本
# php -v
-
测试PHP,Apache网站跟目录下新建info.php网页,按Ins输入内容后按esc,:wq 保存退出。
# vim /var/www/html/info.php <?php phpinfo(); ?>
-
重启Apache服务器,打开info.php网页,显示php信息即正常。
# systemctl restart httpd.service
安装FreeRadius
-
安装
# yum -y install freeradius freeradius-utils freeradius-mysql
提示:安装到第9个时会卡住5分钟,请待心等待安装完成。
验证中 : freeradius-mysql-3.0.13-15.el7.x86_64 9/11
验证中 : log4cxx-0.10.0-16.el7.x86_64 10/11
验证中 : freeradius-utils-3.0.13-15.el7.x86_64 11/11
已安装:
freeradius.x86_64 0:3.0.13-15.el7
freeradius-mysql.x86_64 0:3.0.13-15.el7
freeradius-utils.x86_64 0:3.0.13-15.el7
作为依赖被安装:
boost-system.x86_64 0:1.53.0-28.el7 boost-thread.x86_64 0:1.53.0-28.el7
libtalloc.x86_64 0:2.1.16-1.el7 log4cxx.x86_64 0:0.10.0-16.el7
tncfhh.x86_64 0:0.8.3-16.el7 tncfhh-libs.x86_64 0:0.8.3-16.el7
tncfhh-utils.x86_64 0:0.8.3-16.el7 xerces-c.x86_64 0:3.1.1-10.el7_7
完毕!(第9个文件耗时5分钟)
-
等待下载完成之后出现:Complete,即完整完成。
-
启动radius和设置开机启动
# systemctl start radiusd.service # systemctl enable radiusd.service
-
查看Radius使用的端口,然后添加Radius服务到防火墙中;
# cat /usr/lib/firewalld/services/radius.xml
-
查看防火墙状态,启动状态才能添加规则,centos7中默认防火墙就是firewalld,一般不需要额外设置。
# firewall-cmd --state
-
添加Radius服务到firewalld中。
# firewall-cmd --add-port=80/tcp --permanent success # firewall-cmd --add-service=radius --permanent success # firewall-cmd --reload success # firewall-cmd --list-services radius
配置FreeRadius
-
导入Radius数据库到maiadb数据库中
# mysql -u root -p radius < /etc/raddb/mods-config/sql/main/mysql/schema.sql
-
为/etc/raddb/mods-enabled创建软连接
# ln -s /etc/raddb/mods-available/sql /etc/raddb/mods-enabled/
-
配置SQL模块/ raddb/mods-available/ SQL,并更改数据库连接参数,以适合您的环境:
# vim /etc/raddb/mods-available/sql
sql { # The sub-module to use to execute queries. This should match # the database you're attempting to connect to. # # * rlm_sql_mysql # * rlm_sql_mssql # * rlm_sql_oracle # * rlm_sql_postgresql # * rlm_sql_sqlite # * rlm_sql_null (log queries to disk) # driver = "rlm_sql_mysql" dialect = "mysql" # Connection info: # server = "localhost" port = 3306 login = "radius" password = "radius" # 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
其他配置默认无需更改。
-
然后,将/etc/raddb/mods-enabled/sql所属组更改为radiusd:
# chgrp -h radiusd /etc/raddb/mods-enabled/sql
-
添加启动服务,调整FreeRadius与MariaDB的启动顺序,FreeRadius必须在MariaDB启动之后启动,在[Unit]部分,增加After=mariadb.service,如下图所示:
# systemctl enable radiusd.service # vim /etc/systemd/system/multi-user.target.wants/radiusd.service After=mariadb.service
-
添加客户端连接设置,添加允许所有用户接入,如需特定ip访问,ip可以自由更改。
# vim /etc/raddb/clients.conf client all_client { ipaddr = 0.0.0.0/0 secret = testing123 require_message_authenticator = no }
安装FreeRADIUS管理界面Daloradius
-
进入Apache网站根目录,下载源文件
# cd /var/www/html/ # wget http://www.asiaitell.com/soft/master.zip
如出现 -bash: wget: command not found 等就安装相应软件,没出现忽略这步。
# yum -y install unzip zip
-
解压压缩包,修改文件夹名称
# unzip master.zip # mv daloradius-master/ daloradius
-
下载daloradius-0.9-9.tar.gz,解压后合并到daloradius文件夹中
# wget http://www.asiaitell.com/soft/daloradius-0.9-9.tar.gz # tar -zxvf daloradius-0.9-9.tar.gz # mv daloradius-0.9-9/ daloradius
-
进入daloradius目录,导入daloradius数据库
# cd daloradius # mysql -u root -p radius < contrib/db/fr2-mysql-daloradius-and-freeradius.sql # mysql -u root -p radius < contrib/db/mysql-daloradius.sql
-
设置daloradius目录用户组和用户,设置daloradius.conf.php权限
# chown -R apache:apache /var/www/html/daloradius/ # chmod 664 /var/www/html/daloradius/library/daloradius.conf.php
-
设置daloradius数据库连接信息,打开daloradius.conf.php文件,修改CONFIG_DB_USER,CONFIG_DB_PASS,CONFIG_DB_NAME。
# vim /var/www/html/daloradius/library/daloradius.conf.php
-
重启服务
# systemctl restart radiusd.service # systemctl restart mariadb.service # systemctl restart httpd
如果提示:Warning: radiusd.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
![这里写图片描述]!
没有上面提示就忽略此步
# systemctl daemon-reload # systemctl restart radiusd.service
- 安装php-pear
# yum install php-pear # pear install DB
上面安装报错,提示版本太低,可用下面的安装:
安装Pear
首先要安装最新的pear。安装命令如下:
wget http://www.asiaitell.com/soft/go-pear.phar
php go-pear.phar
安装时直接回车
# pear install DB
downloading DB-1.12.2.tgz ...
Starting to download DB-1.12.2.tgz (137,662 bytes)
.............................done: 137,662 bytes
install ok: channel://pear.php.net/DB-1.12.2
-
登录web界面
默认用户名: administrator
密码: radius
http://ip-address/daloradius/login.php
至此FreeRadius+Daloradius+web管理界面已经安装成功,下面是web界面汉化教程。无需求的可不看。
Daloradius 中文版设置
-
进入Daloradius 文件目录,修改config-lang.php,添加中文选项:
# cd /var/www/html/daloradius # vim config-lang.php <option value="zh"> Simplified Chinese </option>
-
进入lang目录,修改main.php,增加简体中文文件:
# cd lang/ # vim main.php case "zh": include (dirname(__FILE__)."/zh.php"); break;
- 返回lang目录,将下载的zh.php文件放入lang目录,重启radius服务;
# cd /var/www/html/daloradius/lang # wget http://www.asiaitell.com/soft/zh.zip # unzip zh.zip 解压出来就在lang目录,即:将下载的zh.php上传至此目录。 # systemctl restart radiusd.service # systemctl restart httpd
-
设置Config -> Language Settings ->Simplified Chinese