MYSQL 5.7 以后须要sudo,这一块坑我好久。php
sudo mysql --user=root mysql
复制代码
这样是不行的,无论口令对不对都是不行的:html
mysql -u root -p
复制代码
网上给出一堆的改口令的方法,都没有啥用。 ref:stackoverflow.com/a/52742386/…mysql
其中的最直接的答案,并无被选中打钩的,建议你们去点击提示此答案。git
全家桶包括LAMP,FreeRadius,DaloRadius。github
DaloRadius - manage FreeRADIUS from the web browser. FreeRadius - A free AAA Server LAMP - 其中包括了Apache ,Mysql ,PHP .L = Linux.web
最佳的选择的Linux发行版本是安装ubuntu server ,记得选择LAMP,其中包括了Apache ,Mysql ,PHP .L = Linux.sql
我最开始使用的是WSL(Windows Linux Subsystem),当输入service mysql start 时,老是提示,无解。好处就是这个玩意是在Windows Store内的,下载速度奇快。数据库
mysql: unrecognized service
复制代码
LAMP安装好后,须要记得安装php的Pear和它的DB模块,由于DaloRadius要用此模块:apache
sudo apt install php-pear
sudo pear install DB
复制代码
如今,LAMP咱们都有了,其中包括Mysql。能够执行命令:ubuntu
sudo mysql -u root -p
复制代码
必定要加sudo,不然一直报错。是5.7以来的一个新的安全机制,必须这样作。
进入mysql控制台,而后执行命令建立radiusdb,和radius用户,而后刷新受权,退出:
CREATE DATABASE radiusdb;
GRANT ALL ON radiusdb.* TO radius@localhost IDENTIFIED BY "1";
FLUSH PRIVILEGES;
EXIT;
复制代码
一个空的数据库和对应的权限准备完毕。后面的FreeRadius和DaloRadius要用。
接着安装freeradius套件:
apt-get install freeradius freeradius-mysql freeradius-utils
复制代码
这里竟然说找不到包。在网站https://packages.ubuntu.com/是能够找到的。怎么办?先更新下再说:
sudo apt-get update
复制代码
执行update的目的,是得到最新的包列表,这样咱们就能够找到包了。
完成后,把数据库模式sql导入到radiusdb内:
mysql -u root -p radiusdb < /etc/freeradius/3.0/mods-config/sql/main/mysql/schema.sql
复制代码
可能会提示你不能有权限访问...../schema.sql文件。那么能够:
sudo su
复制代码
而后在执行此命令行。
而后建立一个符号连接(symbolic link),把mods-available的sql连接到mods-enabled内:
ln -s /etc/freeradius/3.0/mods-available/sql /etc/freeradius/3.0/mods-enabled/
复制代码
再次登陆mysql,切换数据库,而后显示表清单:
mysql -u root -p
use radiusdb;
show tables;
复制代码
能够看到这样的输出:
+--------------------+
| Tables_in_radiusdb |
+--------------------+
| nas |
| radacct |
| radcheck |
| radgroupcheck |
| radgroupreply |
| radpostauth |
| radreply |
| radusergroup |
+--------------------+
复制代码
说明数据库模式导入成功。
编辑/etc/freeradius/3.0/mods-enabled/sql 文件,设置数据库访问:
nano /etc/freeradius/3.0/mods-enabled/sql
复制代码
内容以下:
sql {
driver = "rlm_sql_mysql"
dialect = "mysql"
# Connection info:
server = "localhost"
port = 3306
login = "radius"
password = "1"
# Database table configuration for everything except Oracle
radius_db = "radiusdb"
}
read_clients = yes
client_table = "nas"
复制代码
修改模块文件的权属:
chgrp -h freerad /etc/freeradius/3.0/mods-available/sql
chown -R freerad:freerad /etc/freeradius/3.0/mods-enabled/sql
复制代码
启动服务:
systemctl restart freeradius
复制代码
查看状态:
systemctl status freeradius
复制代码
BOOM! 出错了。
sudo service freeradius restart
OUTPUT: Job for freeradius.service failed because the control process exited with error code. See "systemctl status freeradius.service" and "journalctl -xe" for details.
复制代码
按照错误提示,执行它说的命令:
journalctl -xe"
复制代码
能够看到详细错误信息:MySql Error:Access Deny for user'freerad' .
管他的,重启大法启动一下。再查状态就对了。
systemctl status freeradius
freeradius.service - FreeRADIUS multi-protocol policy server
复制代码
若是你没有sytemctl ,也能够调试模式启动。首先找到freeradius的位置:
whereis freeredius
复制代码
执行调试模式:
/usr/sbin/freeradius -X
复制代码
看到消息Ready to process request.说明这一步成功。
首先下下载安装包:
wget https://github.com/lirantal/daloradius/archive/master.zip
复制代码
解压:
unzip master.zip
复制代码
把解压内容放到Apache的public内:
mv daloradius-master /var/www/html/daloradius
复制代码
导入Dalo的数据库表:
cd /var/www/html/daloradius
mysql -u root -p radiusdb < contrib/db/fr2-mysql-daloradius-and-freeradius.sql
mysql -u root -p radiusdb < contrib/db/mysql-daloradius.sql
复制代码
设置权限:
chown -R www-data:www-data /var/www/html/daloradius/
chmod 664 /var/www/html/daloradius/library/daloradius.conf.php
复制代码
编辑数据库链接文件:
nano /var/www/html/daloradius/library/daloradius.conf.php
复制代码
属于内容以下,一遍能够链接数据库:
$configValues['DALORADIUS_VERSION'] = '1.1-1';
$configValues['DALORADIUS_DATE'] = '28 Jul 2019';
$configValues['FREERADIUS_VERSION'] = '2';
$configValues['CONFIG_DB_ENGINE'] = 'mysqli';
$configValues['CONFIG_DB_HOST'] = 'localhost';
$configValues['CONFIG_DB_PORT'] = '3306';
$configValues['CONFIG_DB_USER'] = 'radius';
$configValues['CONFIG_DB_PASS'] = '1';
$configValues['CONFIG_DB_NAME'] = 'radiusdb';
复制代码
重启FreeRadius和apache2,或者就重启电脑:
systemctl restart freeradius
systemctl restart apache2
复制代码
查看apache2状态:
systemctl status apache2
复制代码
You should see the following command:
? apache2.service - The Apache HTTP Server
复制代码
访问Web页面,能够输入地址: http://your-server-ip/daloradius/login.php.
便可看到登陆页面。
此时若是是虚拟机,如何在主机访问虚拟内的apache呢?请看:
提供用户名和密码,而后登陆:
administrator / radius
复制代码
能够看到dashboard。
成功。
www.howtoforge.com/how-to-inst…
访问Web的时候,若是遇到了HTTP 500 ,查看
/var/log/apache2/error.log
得到具体报错: failed open 'db.php' class DB
须要安装pear-db库:
sudo apt install php-pear
sudo pear install DB
复制代码
再次登陆,终于...............
NTRadPing能够模拟NAS等RADIUS Client ,发起登陆(Authenication),记帐(Account)。
首先,在Web内添加用户,并保存:
UserName:a
Password:a
复制代码
再添加NAS,并保存:
NAS IP/Host:192.168.1.189 // 你的NTRadPing所在电脑的IP,设置错了的话,从这里发来的包会被服务器丢弃
NAS Secret:sharedkey
NAS Type:other
Short Name:ClientNew
复制代码
而后启动NTRadPing,填写:
Server 192.168.1.165 //Radius Address
Port :1812 // 1812 认证端口,若是是记帐Account,须要改成1813
Secret :sharedkey // 和你添加的NAS的secret同样
User-Name : a
Password :a
Require type : Authentication Request
复制代码
点击Send,应该看到Access-Accept。
成功
在软件界面内,修改以下内容:
Port :1813 // 1812 认证端口,若是是记帐Account,须要改成1813
Require type : Accounting Start
复制代码
点击Send,发现没有接到响应。查看后台,发现调试模式的FreeRadius在控制台打印:
rlm_sql_mysql: MySQL error 'Unknown column 'acctupdatetime' in 'field list''
复制代码
添加须要的字段:
ALTER TABLE radacct ADD acctupdatetime datetime NULL default NULL AFTER acctstarttime;
ALTER TABLE radacct ADD acctinterval int(12) default NULL AFTER acctstoptime;
ALTER TABLE radacct ADD KEY(acctinterval);
ALTER TABLE radacct ADD UNIQUE KEY(acctuniqueid);
ALTER TABLE radacct DROP column acctstartdelay;
ALTER TABLE radacct DROP column acctstopdelay;
ALTER TABLE radacct DROP column xascendsessionsvrkey;
复制代码
再次发起记帐消息,应看到Accounting-Response。
成功。