Installation and Management of Freeradius System

Keywords: PHP SQL MySQL yum

Install freeredius in CentOS 6.5:

yum -y install httpd httpd-devel mysql mysql-server mysql-devel
yum -y install php php-devel php-mysql php-common php-gd php-mbstring php-mcrypt php-xml
/etc/init.d/httpd start
/etc/init.d/mysqld start
chkconfig httpd on
chkconfig mysqld on
mysqladmin -u root password 'newpassowrd'

Install freeradius using yum so that the version installed is slightly lower.

yum install -y freeradius freeradius-mysql freeradius-utils

This is freeradius started with the system.

chkconfig  radiusd on
service radiusd start

You can check the boot log for errors by opening a new terminal window and executing cat/var/log/radius/radius.log.

The following configures freeradius.

cp /etc/raddb/clients.conf /etc/raddb/clients.conf.bak 
grep -v \# /etc/raddb/clients.conf.bak | grep -v \^$ >/etc/raddb/clients.conf
vi /etc/raddb/clients.conf 

Content Configuration:

client localhost {
        ipaddr = 127.0.0.1
        secret          = testing123
        require_message_authenticator = no
}

It is important to note that the 127.0.0.1 configuration above is primarily for testing purposes and that future true clients will be supplemented with the following information

#In the future, your true raidus billing client, such as routeros, will need to configure ip information here, for example 
client x.x.x.x{  #Here x.x.x.x is your routeros server internal port ip 
   ipaddr=x.x.x.x #routeros intranet ip 
   secret=xxxxxxxxxx    #Your own password 
   shortname=ros 
} 
#!/bin/bash

# enable snd-soc-wmt-fm34
sed -i '/snd-soc-wmt-fm34/s/^#//' fs_patch/load_drivers.sh

source release_Common.sh

# disable snd-soc-wmt-fm34 back
sed -i '/snd-soc-wmt-fm34/s/^/#&/' fs_patch/load_drivers.sh
cp /etc/raddb/sql/mysql/admin.sql /etc/raddb/sql/mysql/admin.sql.bak
grep -v ^# /etc/raddb/sql/mysql/admin.sql.bak | grep -v \^$  > /etc/raddb/sql/mysql/admin.sql
vi /etc/raddb/sql/mysql/admin.sql

Change the content to look like this below;

CREATE USER 'radius'@'localhost'; 
SET PASSWORD FOR 'radius'@'localhost' = PASSWORD('radpass'); 
GRANT SELECT ON radius.* TO 'radius'@'localhost'; 
GRANT ALL ON radius.* TO 'radius'@'localhost';  

Execute the command, enter mysql's root administrator account password when mysql-u root-p returns, and then

source /etc/raddb/sql/mysql/admin.sql;
create database radius;
use radius;
source /etc/raddb/sql/mysql/schema.sql;
source /etc/raddb/sql/mysql/nas.sql;
source /etc/raddb/sql/mysql/ippool.sql;
flush privileges;
quit;

Then execute in the linux terminal

vi /etc/raddb/radiusd.conf

Page down hard to module and remove

$INCLUDE sql.conf
$INCLUDE sql/mysql/counter.conf

Save File After Previous # Exit vi Editor

Then?

vi /etc/raddb/sql.conf

Remove the comment information for the readclients variable.

readclients = yes

Then?

vi /etc/raddb/sites-enabled/default

Find the configurations authorize, accounting, session and enable all the SQL inside. Just remove the #before sql.In addition, add the following monthly Trafficcounter to authorize (I added this monthly statistic here and made a mistake).

Now that the fuck is finally configured, here's a real test of inserting a piece of data into the mysql database:

mysql -u root -p $ROOT_PASSWORD -e "INSERT INTO radius.radcheck (UserName, Attribute, Value) VALUES ('user1', 'Password','password1');"

service radiusd restart

radtest user1 password1 localhost 1812 testing123

Success looks like this:

[root@localhost raddb]# radtest user1 password1 localhost 1812 testing123 
Sending Access-Request of id 155 to 127.0.0.1 port 1812 
        User-Name = "user1" 
        User-Password = "password1" 
        NAS-IP-Address = 127.0.0.1 
        NAS-Port = 1812 
        Message-Authenticator = 0x00000000000000000000000000000000 
   rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=155, length=20 

Installation and daloradius

Download the latest version of daloraidus from sf.net, and then

tar zxvf daloradius-0.9-9.tar.gz

cp  -R daloradius-0.9-9 /var/www

cd /var/www

mv daloradius-0.9-9 daloradius

mysql -u root -p

use radius

source /var/www/daloradius/contrib/db/mysql-daloradius.sql



vi /var/www/daloradius/library/daloradius.conf.php

Change the password of the linked database to be radius with the user name and radpass with the password

$configValues['CONFIG_DB_USER'] = 'radius'; 
$configValues['CONFIG_DB_PASS'] = 'radpass'; 

Then?

vi /etc/httpd/conf/httpd.conf

Add the following at the end

    Alias /myradius "/var/www/daloradius/" 
    <Directory /var/www/daloradius/> 
      Options None 
      order deny,allow 
      allow from all 
    </Directory> 

service httpd restart after configuration is complete.

Then open a browser to access it http://localhost/myradius You can open the login interface, enter the username administrator, password radius submit login later interface does not respond, cat/etc/httpd/logs/error_log discovery prompt

    PHP Fatal error:  Class 'DB' not found in /var/www/daloradius/library/opendb.php on line 86, referer: http://localhost/myradius/login.php 

This is due to the lack of php-related extensions and the TMD has to continue to torn

according to http://blog.sina.com.cn/s/blog_541a3cf10101hjth.html This article says that adding third-party sources

Update yum source
Some required packages are not in the default standard library and are required before installation, requiring the RPM forge database to be added

#wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm 
#wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt 
#rpm --import RPM-GPG-KEY.dag.txt 
#rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm 

Html Code Collection Code

Install PHP and Extensions 
#yum install php php-mysql php-gd php-ldap php-xml php-mbstring 
Install PEAR related 
#yum install php-pear php-pear-DB 
#pear channel-update pear.php.net 
#pear upgrade-all 

Once the service httpd restart is installed, log in to daloradius again.
Next, change the firewall rules and open port 80

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 1812 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 1813 -j ACCEPT 
/sbin/iptables -I INPUT -p tcp --dport 1814 -j ACCEPT 
/etc/rc.d/init.d/iptables save #Save Configuration
/etc/rc.d/init.d/iptables restart #Restart Service

Use the test user in freeradius to verify that the installation was successful

When freeradius is installed through yum, all configuration files are stored in the / etc/raddb path.The profile for users is/etc/raddb/users.This configuration file will not work if freeradius is associated with the mysql database in the future.
1. Enable test users
Open the configuration file:

vi /etc/raddb/users

Then find the following paragraph, delete the #comment in front of it, and save the file.The user name for this text configuration is steve and the password is testing.

#steve  Cleartext-Password := "testing" 
#       Service-Type = Framed-User, 
#       Framed-Protocol = PPP, 
#       Framed-IP-Address = 172.16.3.33, 
#       Framed-IP-Netmask = 255.255.255.0, 
#       Framed-Routing = Broadcast-Listen, 
#       Framed-Filter-Id = "std.ppp", 
#       Framed-MTU = 1500, 
#       Framed-Compression = Van-Jacobsen-TCP-IP 

2. Start freeradius
For the first startup with radiusd-X, note that the first startup must be a root account, and note that the X is capitalized. If you see the hint below, the startup should be successful.

Listening on authentication address * port 1812 
Listening on accounting address * port 1813 
Listening on command file /var/run/radiusd/radiusd.sock 
Listening on authentication address 127.0.0.1 port 18120 as server inner-tunnel 
Listening on proxy address * port 1814 
Ready to process requests. 

3. Testing user connections
Then open another terminal to run

radtest steve testing localhost 1812 testing123

Test that freeradius is installed successfully when prompted by rad_recv: Access-Accept.Under normal circumstances, test tips should be as follows:

rad_recv: Access-Accept

4. End of test process

Remember to re-annotate the user profile after the test is OK, comment out all enabled user configurations, and close the radiusd debugging process.

Analysis of daloradius anomalies

Enter http://localhost/myradius in the browser, open the login interface, enter user name and password, submit login interface does not respond, check HTTP error log/etc/httpd/logs/error_log, find the following prompts:

PHP Fatal error:  Class 'DB' not found in /var/www/daloradius/library/opendb.php on line 86, referer: http://localhost/myradius/login.php 

This is due to the lack of php-related extensions, mainly pear-DB extensions, which have been addressed during the above installation.

Posted by gofeddy on Thu, 16 May 2019 23:42:41 -0700