归档:Install FreeRadius+DaloRadius +UbuntuServer

957

IMPORTANT!!!

stackoverflow.com/a/52742386/…

21 MYSQL 5.7 CHANAGED THE SECURE MODEL:NOW MYSQL ROOT LOGIN REQUIRES A SUDO.

MySQL 5.7 changed the secure model: now MySQL root login requires a sudo

The simplest (and safest) solution will be create a new user and grant required privileges.

  1. Connect to mysql

    sudo mysql --user=root mysql

正文开始

www.howtoforge.com/how-to-inst…

安装ubuntu server ,记得选择LAMP,其中包括了Apache ,Mysql ,PHP .L = Linux.

配置数据库

Next, you will need to create a database and user for FreeRADIUS. To do so, log in to MariaDB shell with the following command:

mysql -u root -p Enter your root password when prompt then create a database and user with the following command:

CREATE DATABASE radiusdb;
GRANT ALL ON radiusdb.* TO radius@localhost IDENTIFIED BY "1";

Next, flush the privileges and exit from the MariaDB shell with the following command:

FLUSH PRIVILEGES;
EXIT;

Install FreeRADIUS

By default, FreeRADIUS is available in the Ubuntu 18.04 default repository. You can install it with the following command:

apt-get install freeradius freeradius-mysql freeradius-utils

这里居然说找不到包。在网站https://packages.ubuntu.com/是可以找到的。怎么办?先更新下再说:

sudo apt-get update

执行update的目的,是获得最新的包列表。apt-get update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies.

Once installed, import the freeradius MySQL database schema with the following command:

mysql -u root -p radiusdb < /etc/freeradius/3.0/mods-config/sql/main/mysql/schema.sql

可能会提示你不能有权限访问...../schema.sql文件。那么可以:

sudo su

然后在执行此命令行。

Provide your radius database user password when prompt and hit Enter to import the database schema.

Next, you will need to create a symbolic link for sql module. You can do it with the following command:

ln -s /etc/freeradius/3.0/mods-available/sql /etc/freeradius/3.0/mods-enabled/

Next, log in to MariaDB shell and check the created tables with the following command:

mysql -u root -p

Enter your root password when prompt. Once login, change the database to radiusdb with the following command:

MariaDB [(none)]> use radiusdb;

Next, list the created tables using the following command:

 show tables;

You should see the following output:

+--------------------+
| Tables_in_radiusdb |
+--------------------+
| nas                |
| radacct            |
| radcheck           |
| radgroupcheck      |
| radgroupreply      |
| radpostauth        |
| radreply           |
| radusergroup       |
+--------------------+

Next, exit from the shell with the following command:

EXIT;

Next, you will need to define your database connection details in freeradius SQL module. You can do it by editing /etc/freeradius/3.0/mods-enabled/sql file:

nano /etc/freeradius/3.0/mods-enabled/sql

Make the following changes as per your database:

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"

Then, change the ownership of /etc/freeradius/3.0/mods-enabled/sql with the following command:

chgrp -h freerad /etc/freeradius/3.0/mods-available/sql
 chown -R freerad:freerad /etc/freeradius/3.0/mods-enabled/sql

Finally, restart freeradius service to apply all the configuration changes:

systemctl restart freeradius

You can also verify the freeradius status with the following command:

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.

Run:

journalctl -xe" 

可以看到详细错误信息:MySql Error:Access Deny for user'freerad' .

管他的,重启大法启动一下。再查状态就对了。

systemctl status freeradius
freeradius.service - FreeRADIUS multi-protocol policy server

Install daloRADIUS

Next, you will need to install daloRADIUS to manage FreeRADIUS from the web browser.

First, download the latest version of daloRADIUS from the Git repository with the following command:

wget https://github.com/lirantal/daloradius/archive/master.zip

Once downloaded, unzip the downloaded file with the following command:

unzip master.zip

Next, move the extracted directory to the Apache web root directory with the following command:

mv daloradius-master /var/www/html/daloradius

Next, import daloRADIUS mysql tables to radiusdb with the following command:

 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

Next, give proper permission to the daloradius directory with the following command:

chown -R www-data:www-data /var/www/html/daloradius/
chmod 664 /var/www/html/daloradius/library/daloradius.conf.php

Next, open daloradius.conf.php file and define the database connection details:

nano /var/www/html/daloradius/library/daloradius.conf.php

Make the following changes that match your database:

$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'] = 'password';
$configValues['CONFIG_DB_NAME'] = 'radiusdb';

Save and close the file. Then, restart freeradius and apache service with the following command:

systemctl restart freeradius
 systemctl restart apache2

You can also check the status of Apache web service with the following command:

systemctl status apache2

You should see the following command:

? apache2.service - The Apache HTTP Server

Once you have done, you can proceed to the next step.

VISIT WEB

Access daloRADIUS Web Interface FreeRADIUS and daloRADIUS are now installed and configured. It's time to access daloRADIUS web interface. To access the web inetrface, open your web browser and type the URL http://your-server-ip/daloradius/login.php. You will be redirected to the daloRADIUS login page:

此时如果是虚拟机,如何在主机访问虚拟内的apache呢?请看:

coderwall.com/p/yx23qw/ac…

Now, provide default username and password as

administrator / radius

and click on the Login button. You should see the daloRADIUS default dashboard in the following page:

然而,遇到了HTTP 500 ,查看 /var/log/apache2/error.log

获得具体报错: failed open 'db.php' class DB

4

You are missing the PHP Pear DB library. Install the library via

sudo apt install php-pear
sudo pear install DB

再次登录,终于...............

成功。