Skin - Ruby 紅寶美顏 » 商品

2014年7月14日 星期一

Installing Ubuntu 12.04 Freeradius 2.1.10 and daloRadius (Freeradius web GUI managerment)

Install Ubuntu Desktop or Server, select Open SSH, DNS Server and LAMP server

During Ubuntu installation, it will ask you for your "MySQL root" password, supply a password for it, IT IS NOT the same as your ubuntu password, it is for MySQL alone so that you can access your MySQL administration function.

When everything is done, reboot and login to your newly installed ubuntu system using your regular account.

OK, I'm kinda sick and tired of typing sudo every time I need to issue commands which requires a root access, let's settle this problem once and for all,

Ubuntu system has a root account without a password, what we needed to do is to allow us to use the root account so that we don't need to use the sudo crap. 

to activate the root account..

~$ sudo passwd
   
  Enter new UNIX password:
  Retype new UNIX password:

just type your new root password, once you are done, logout and login again, this time use the root username and use the password we just created earlier. Now, that you have root access, you don't need to type sudo every time you need to do something which requires a root access, however, be careful while you are in root account, you might break your system with a wrong command.

Also, bear in mind, that when you use the root account, your home directory is /root so whatever you downloaded from the net will be saved in that folder, if you use your regular account, your home directory is /home/useraccount/

Setup the server to have a static IP address, issue the commaind in your terminal

~$ nano /etc/network/interfaces

locate the interface you use, in this example the interface is eth0

auto eth0
iface eth0 inet dhcp

change to....

auto eth0
iface eth0 inet static
address 192.168.1.x  (put your ip address here)
netmask 255.255.255.0
gateway 192.168.1.x (put your gateway here)
dns-nameservers 192.168.1x (put your dns server here)

Save the file by hitting control-O and control-X to exit.

restart the network service for the new ip address to take effect

~$ /etc/init.d/networking restart

to confirm your new ip address issue the command below and locate your new ip address.

~$ ifconfig

If you see the ip address, you are good to go.

Before continuing, you MUST update and Upgrade your ubuntu system to ensure you have the latest software installed, in your terminal, issue the command below.

~$ apt-get update && sudo apt--get upgrade

once you are done with the initial upgrade, reboot the server, and re-issue the update and upgrade command again, that is to ensure that there is no upgrade left.

We also need to install additional libraries and tools for future use.

~$ apt-get install build-essential binutils libssl-dev openssl libmysqlclient-dev

Install the freeradius, Ubuntu 12.04 has the version 2.1.10 and the latest from freeradius.org is 2.2.0 - the version 2.1.10 is more than sufficient for our use, so we will use it instead.

~$ apt-get install freeradius freeradius-mysql freeradius-postgresql freeradius-dialupadmin freeradius-utils

after installing the freeradius, it will be run automatically, let it be for now, we will configure the radius later on.

We need to install the PhpMyadmin.

~$ apt-get install phpmyadmin

It will ask you which web server to reconfigure automatically, choose Apache2 by pressing the space bar, and click on OK to complete.
Another screen will appear..

Configure database for phpmyadmin with dbconfig-common?
Choose YES.

then supply a password of your MySQL root account and for your phpmyadmin, if you installed your phpmyAdmin correctly, you can access it using your browser like http://yourserver_ip_address/phpmyadmin login with the username and password you supplied during the phpmyadmin installation.

Next, we need to install the daloradius Radius Management, daloradius is a web based application to interact with your MySQL database; the freeradius software is default to use the plain "text file" to store user account details such as username, password and other token to limit its access,  what we want to achieve is to make FreeRadius to use MySQL to store user details, and the accounting of the each users, i.e. DL bytes/ expiry date etc...etc.

the pre-requisite of daloradius is to install some libraries for php

Additional packages you need to install.

~$ apt-get install php-pear php5-gd php-db

We also need to install the php pear, but first we need to download it.

~$ wget  pear.php.net/go-pear.phar

After you downloaded the go-pear.phar, install it by,

~$ php go-pear.phar

Just press ENTER to accept the default installation folder, once you are done installing it, we  need to fix apache's error "Could not reliably determine the server's fully qualified domain name"

To fix it, edit /etc/apache2/httpd.conf

~$ nano /etc/apache2/httpd.conf

then add this line

ServerName localhost

for now, we will just use localhost, we will change it later if we need to, save the file by ctrl-O then ctrl-X to exit, then restart your apache server.

~$ apachectl restart
~$ apachectl configtest

Next, you need to download the daloradius Software, you can get it from...

http://citylan.dl.sourceforge.net/project/daloradius/daloradius/daloradius0.9-9/daloradius-0.9-9.tar.gz

to download it into your server directly. issue the command

~$ wget http://citylan.dl.sourceforge.net/project/daloradius/daloradius/daloradius0.9-9/daloradius-0.9-9.tar.gz

now, we need to extract the daloradius.

~$ tar zxfv daloradius-0.9-9.tar.gz

The daloRadius package will be uncompressed, we need to move it to /var/www folder

~$ mv daloradius-0.9-9 /var/www/

 next, we need to change our current directory to /var/www/daloradius-0.9-9

~$ cd /var/www/daloradius-0.9-9

Next, we must create a MySQL database for our Freeradius, the database will be used by daloradius too.

~$ mysql -u root -p

then, enter your MySQL root password, you should see below

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


At the prompt, type create database radiusdb; 

mysq>create database radiusdb;
mysql> quit

While still inside the /var/www/daloradius-0.9-9/ folder issue the command below..

~$ mysql -u root -p radiusdb < contrib/db/fr2-mysql-daloradius-and-freeradius.sql

to see if you successfully created the database, login to your MySQL and issue the command show databases;


~$ mysql -u root -p
Enter password:



if you see the radiusdb database, issue the command at the MySQL prompt

mysql> use radiusdb
mysql> show tables;

you should see the tables of your radiusdb, type quit to exit MySQL.


now, that we have database for the freeradius and daloRadius, it is time to configure freeradius to use the MySQL database and configure apache server. but first, let's re-cap of what we have accomplished.

1. Install Ubuntu Server 12.04
2. Install LAMP, Openssh, DNS Server
3. Changed server IP address from DHCP to Static address.
4. Update the source cache and upgrade the ubuntu server system
5. Install build-essential, binutils, libssl-dev and openssl 
6. Install FreeRadius 2.1.10 from the Ubuntu repository
7. Install PhpMyAdmin
8. Install additional libraries php-pear, php5-gd and php-db
9. Install go-pear.phar from pear.php.net website.
10. Fix apache's FQDN settings.
11. Download daloRadius 0.9-9 from sourceforge.org
12. Extract daloRadius and move it to /var/www/
13. Create the FreeRadius database.
14. Insert the Freeradius and daloradius tables into Freeradius database.



SETTING UP FREERADIUS TO USE MYSQL


As I mentioned earlier, the default authentication method of Freeradius is to use a text file where user accounts are stored, the text file can be found in /etc/freeradius/users

We installed the Freeradius but we haven't tested it yet, to test freeradius, edit the /etc/freeradius/users file 

~$ nano /etc/freeradius/users

locate the line containing

#"Test"     Cleartext-Password := "hello"
#               Reply-Message = "Hello, %{User-Name}"


and remove the comment tag (#) and save the file control-O and exit control-X

Stop the freeradius service daemon.

~$ /etc/init.d/freeradius stop

Run the freeradius server in debug mode.

~$ freeradius -XXX

you should see lots of texts scrolling, If everything goes well, the last line should say...

Thu Apr 11 10:28:20 2013 : Debug: Listening on accounting address * port 1813
Thu Apr 11 10:28:20 2013 : Debug: Listening on authentication address 127.0.0.1 port 18120 as server inner-tunnel
Thu Apr 11 10:28:20 2013 : Debug: Listening on proxy address * port 1814
Thu Apr 11 10:28:20 2013 : Info: Ready to process requests.


Press control-C to stop freeradius in debug mode and re-start it again in daemon mode.

~$ /etc/init.d/freeradius start

 to test freeradius authentication using a text file.

~$ radtest "Test" "hello" 127.0.0.1 0 testing123

Make sure you typed everything correctly, If all goes well, you should see the reply. It is important that you get the Reply-Message = "Hello, John Doe"


Sending Access-Request of id 78 to 127.0.0.1 port 1812
        User-Name = "Test"
        User-Password = "hello"
        NAS-IP-Address = 127.0.1.1
        NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=78, length=37
        Reply-Message = "Hello, John Doe"



If you see the above reply, congratulation, your freeradius is working fine, now we need to set it up to use SQL database for authentication instead of a flat text file.


Stop freeradius

~$ /etc/init.d/freeradius stop

Configure FreeRadius to use MySQL for Authentication

Edit the file /etc/freeradius/radiusd.conf

~$ nano /etc/freeradius/radiusd.conf

locate the following line and uncomment it 

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

Save the file (Control-W) and exit (Control-X)

edit another file

~$ nano /etc/freeradius/sites-available/default

locate the following line under the authorize section and uncomment it (line 159)

#            sql

locate the line under the session section and uncomment it too (line 435)

#            sql

Save the file and start Freeradius in debug mode.

~$ freeradius-XXX

If all goes well, you should see the log output..

Thu Apr 11 10:28:20 2013 : Debug: Listening on accounting address * port 1813
Thu Apr 11 10:28:20 2013 : Debug: Listening on authentication address 127.0.0.1 port 18120 as server inner-tunnel
Thu Apr 11 10:28:20 2013 : Debug: Listening on proxy address * port 1814
Thu Apr 11 10:28:20 2013 : Info: Ready to process requests.

  
Press Control-C to stop freeradius in debug mode.

CREATING FREERADIUS MYSQL User Account

Login to MySQL.

~$ mysql -u root -p

mysql> CREATE USER 'raddbuser'@'localhost';
mysql> SET PASSWORD FOR 'raddbuser'@'localhost' = PASSWORD('radpass');
mysql> GRANT ALL ON radiusdb.* to 'raddbuser'@'localhost';
mysql>quit

SETUP FREERADIUS MYSQL ACCOUNT

Edit the file /etc/freeradius/sql.conf

Locate the the following line.

login = "radius"
password = "radpass"
radius_db = "radius" 

and change it to...

login = "raddbuser"
password = "radpass"
radius_db = "radiusdb"

Uncomment the line.

readclients = yes

Save the file and exit.

CONFIGURING daloRadius MYSQL ACCOUNT
  
Edit the file /var/www/daloradius-0.9-9/library/daloradius.conf.php
~$ nano /var/www/daloradius-0.9-9/library/daloradius.conf.php 

locate the lines

$configValues['CONFIG_DB_ENGINE'] = 'mysql';
$configValues['CONFIG_DB_HOST'] = 'localhost';
$configValues['CONFIG_DB_PORT'] = '3306';
$configValues['CONFIG_DB_USER'] = 'root';
$configValues['CONFIG_DB_PASS'] = '';
$configValues['CONFIG_DB_NAME'] = 'radius';

and change the value settings to.

$configValues['CONFIG_DB_ENGINE'] = 'mysql';
$configValues['CONFIG_DB_HOST'] = 'localhost';
$configValues['CONFIG_DB_PORT'] = '3306';
$configValues['CONFIG_DB_USER'] = 'raddbuser';
$configValues['CONFIG_DB_PASS'] = 'radpass';
$configValues['CONFIG_DB_NAME'] = 'radiusdb';

Save the file and exit..
~$ cd /var/www/
~$ mv daloradius-0.9-9 daloradius

To test the daloradius, open a browser and type http://youripserver/daloradius you should see now your daloradius web page, the default username is administrator and password is radius

Congratulation! you now have a fully working daloRadius Billing Management

https://help.ubuntu.com/community/WifiDocs/CoovaChilli?highlight=%28ManufacturerModel%29
http://itrecess.blogspot.tw/2012/07/install-and-configure-freeradius-and_3623.html

沒有留言:

張貼留言