Saturday, July 21, 2012

Install and Configure Freeradius and Coovachilli Hotspot wifi on your Ubuntu Server

Ubuntu + Freeradius2 + CoovaChilli1.2.6 + Daloradius.
 
eth1 = 192.168.1.225 to the Internet.
eth0 = 192.168.0.1 LAN.

Note: Good Practice before modifying any file just take backup of original file. So your original file will be safe and anytime you can restore.

Step1. Setup your network in /etc/network/interfaces file according to your network Ethernet.

Edit file by entering this command on terminal: nano /etc/network/interfaces.
iface eth1 inet static
address 192.168.1.225
netmask 255.255.255.0
gateway 192.168.1.1
auto eth0

Step2. For allowed to forward packet edit file by entring this command on terminal: nano /etc/sysctl.conf

            Remove # from the begining of this line to enable it==>  #net.ip4.ip_forward = 1
            Run this command on your teminal echo 9 sudo tee /proc/sys/net/ipv4/ip_forward

Step3. Install tasksel package by entring this command on your terminal: sudo apt-get install tasksel

Step4. After installation tasksel, just run tasksel and Install LAMP Server DNS Server and Openssh-Server(just select these three package by pressing space key and enter).

Step5. Now we have apache running, DNS server and Openssh. Now we are going to freeradius.

Type this command on your terminal (make sure your pc should be connected to internet)
apt-get install freeradius freeradius-mysql

If there is any issue to install freeradius then do this
·         check log file
·         remove freeradius by this command apt-get purge freeradius
·         restart your pc and run this command apt-get update
·         Now again follow the step5.

Step6. After Successfully installation of freeradius create a database and execute sql scripts for to create sql tablesa script to create tables in radius database.

Run these command on your terminal:
 mysqladmin -pmysqlpasswd create radius #mysqlpasswd mean your mysql root password
 mysql -u root -p radius </etc/freeradius/sql/mysql/schema.sql
 mysql -u root -p radius </etc/freeradius/sql/mysql/nas.sql
 mysql-u root-p
 mysql> GRANT ALL PRIVILEGES ON radius. * TO 'radius'@'localhost' IDENTIFIED BY 'your-password   for mysql user radius'
 mysql> FLUSH PRIVILEGES;
 mysql> quit

Step7. Now enable the database mysql database for freeradius by making following changes:    
nano /etc/freeradius/sql.conf.

            server = "localhost".
            login = "radius".
            password = "your mysql password for radius user".
            Readclient = yes #enable this by removing the # from begining of this line

Now save and close this file and open radiusd.conf file by run this command
nano /etc/freeradius/radiusd.conf

Make following changes in this follwing.
modules {
......................
$ INCLUDE sql.conf. # remove  #from the beginning of this line
$ INCLUDE sql/mysql/counter.conf  #from the beginning of this line
.....................
}
Step8. Modify client.conf to compile Daloradius Coova-chilli and freeradius to work with them.
nano /etc/freeradius/clients.conf
client 127.0.0.1 {
secret = your MySql password for user radius
}
Step9. Modify also this file for to enable the database
nano /etc/freeradius/sites-available/default

 Findout authorize module and make changes
authorize {
            File       #comment line by putting # in begging of this line
            # sql     #remove # for to enable the database
            # add bellow three in the end of this file
            noresetcounter
            dailycounter
            monthlycounter
}


Findout authorize module and make changes
accounting {
            detail
            radutmp
            #sql      # remove # from the beginning of this file
}

Findout session module and make changes
session {
            #sql      # remove # from the beginning of this file
}

Step10. Now test the freeradius.
Add test user into the database and restart the freeradius
            mysql -u root -p
            enter password for your mysql user root
            change database by entering executing this command use radius;
 Now execute this query:
                        ·         INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('guest', 'Password', 'guest');

Exit from the mysql and restart the freeradius  /etc/init.d/freeradius restart

Run this command from your terminal
 radtest guest guest 127.0.0.1 0 your-mysql-user password
 You should get reply something like this
 Access-Accept packet from host 127.0.0.1:1812, id = 144, length = 20.
If there is any issue, check log file.

1 comment:

  1. hi

    do you have source of currently version that is full and completed? because currently I am trying to compile from the source code and it is missing sql folder under raddb. Thanks if you can help on this.

    ReplyDelete