Thursday, January 17, 2013

OpenWRT + BATMAN + CoovaChilli


Objective

Build a captive portal on a wireless mesh network

Wireless clients can roam around the mesh network



Requirements

OpenWRT compatible router
OpenWRT
B.A.T.M.A.N.
CoovaChilli
FreeRadius



Topology
pastedGraphic.pdf


OpenWRT

Installation

  • Download appropriate OpenWRT image from http://downloads.openwrt.org/snapshots/trunk/ 
  • Connect your computer to the router
  • Turn on the router
  • Follow the router’s manual on upgrading its firmware but instead of using the manufacturer’s upgraded firmware, use the downloaded OpenWRT image


Configuration

For the configuration, we just need to set a password for the root user account

  • Using Telnet, login to the router. A router with a newly installed OpenWRT has a default IP address of 192.168.1.1. Your telnet command should be
telnet 192.168.1.1

  • Once logged in type passwd then Enter and provide a password for the root user account
  • Logout by typing exit then press Enter


Testing

First we test if OpenWRT can access the Internet

  • Connect the WAN port of the router to the Internet
  • Login to the router using ssh (use root and the password you just set during configuration respectively)
  • Now do a ping test to see if the router is indeed connected to the Internet


Now We’ll test the wireless interface of the router

  • Still logged in to the router, edit /etc/config/wireless
  • Delete the line that says “option disabled 1”
  • Optionally set the SSID (This is the line that says option ssid ‘OpenWRT’. Change OpenWRT to your chosen SSID)
  • Save and close the file
  • Type wifi and press Enter to reload wifi configuration
  • Connect to the router through its wireless interface. You should be able to access the Internet



B.A.T.M.A.N.

Installation

  • Login to the router
  • Connect the router to the Internet
  • Execute the following
opkg update
opkg install kmod-batman-adv


Configuration

  • Create a file /tmp/batman_config.sh and set the content with the following

#!/bin/sh

### Node-specific settings
export HOSTNAME="ROUTERNAME" 
export IP="192.168.1.1" 
export LAN_IFNAME="eth0 bat0"

### Network-specific settings should be consistent across all nodes with in the mesh network
export PUBLIC_ESSID="OMNISPOT" 
export NETMASK="255.255.255.0" 
export DNS="" 
export GATEWAY="" 
export MESH0_BSSID="CA:CA:CA:CA:CA:00" 
export MESH0_ESSID="mesh0" 
export MESH0_CHANNEL="3" 

wifi detect >>/etc/config/wireless

( for i in `seq 0 9` ; do echo "delete wireless.@wifi-iface[]" ; done ) | uci batch -q

uci import -m batman-adv </dev/null

echo " 
set system.@system[0].hostname=$HOSTNAME

set batman-adv.bat0=mesh
set batman-adv.bat0.interfaces='mesh0'
set batman-adv.bat0.gw_mode='off'

set network.lan.ipaddr=$IP
set network.lan.netmask=$NETMASK
set network.lan.dns='$DNS'
set network.lan.gateway=$GATEWAY
set network.lan.ifname='$LAN_IFNAME'

set network.bat0=interface
set network.bat0.ifname=bat0
set network.bat0.proto=none
set network.bat0.mtu=1500
set network.mesh0=interface
set network.mesh0.proto=none
set network.mesh0.mtu=1528

set wireless.radio0=wifi-device
set wireless.radio0.channel=$MESH0_CHANNEL
set wireless.radio0.disabled=0
set wireless.radio0.phy=phy0
set wireless.radio0.macaddr=

add wireless wifi-iface
set wireless.@wifi-iface[-1].device=radio0
set wireless.@wifi-iface[-1].encryption=none
set wireless.@wifi-iface[-1].network=lan
set wireless.@wifi-iface[-1].mode=ap
set wireless.@wifi-iface[-1].ssid='$PUBLIC_ESSID'

add wireless wifi-iface
set wireless.@wifi-iface[-1].device=radio0 
set wireless.@wifi-iface[-1].encryption=none
set wireless.@wifi-iface[-1].network=mesh0
set wireless.@wifi-iface[-1].mode=adhoc 
set wireless.@wifi-iface[-1].bssid=$MESH0_BSSID
set wireless.@wifi-iface[-1].ssid='$MESH0_ESSID'
set wireless.@wifi-iface[-1].mcast_rate=11000 

set dhcp.lan.ignore=1

commit" \
| uci batch


  • Set the values of the node-specific settings for each router


Name
Description
HOSTNAME
Would-be hostname of the router
IP
Would-be IP address of the router
LAN_IFNAME
LAN interface name of the router and bat0 (B.A.T.M.A.N. interface)


  • Set the network specific-settings. These should be the same for all nodes in the mesh network


Name
Description
PUBLIC_ESSID
The SSID of the wireless network where clients will connect to
NETMASK
Network mask of the mesh network
DNS
The DNS setting 
GATEWAY
Internet gateway address
MESH0_BSSID
A common MAC address to enable the nodes of the mesh network to identify each other and communicate
MESH0_ESSID
The SSID for the mesh network
MESH0_CHANNEL
The channel to use for wireless communication


  • Save and close the file /tmp/batman_config.sh
  • Run the batman configuration script

sh /tmp/batman_config.sh

  • Restart the router

Do this for all the routers involve 


Testing

  • Turn on all the routers
  • Log in to one of the routers
  • You should be able to ping the other router



CoovaChilli

Installation

  • Login to the router
  • Connect the router to the Internet
  • Execute the following
opkg update
opkg install coova-chilli


Configuration

  • Execute the following on your computer

tar -xzvf coova-chilli-1.3.0.tar.gz
cd coova-chilli-1.3.0/miniportal
ls *.in | sed 's/\(.*\)\.in/\1/' | xargs -I {} mv {}.in {}

  • Substitute the markers @SBINDIR@ and @ETCCHILLI@ with “/usr/sbin” and “/etc/chilli” respectively
  • Copy the content of miniportal folder to the router

scp * root@192.168.1.1:/etc/chilli/www/

  • Logon to the router
  • Open /etc/chilli/defaults and edit the following settings


Key
Recommended Value
Remarks
HS_WANIF
eth1 or eth0.2
  • The WAN interface
  • Uncomment this and set the value to the name of the WAN of the router
  • Use ifconfig to give you a hint
HS_LANIF
bat0
  • The LAN interface
  • bat0 is the name of the mesh network interface


  • Choose either of the two for authentication

RADIUS Authentication

    • For radius authentication, provide the IP address of the RADIUS server as value for key HS_RADIUS in /etc/chilli/defaults


Local File Authentication

    • For local file authentication, uncomment the line HS_LOCALUSERS in /etc/chilli/defaults
    • Create the file /etc/chilli/localusers and add the username and password in the following format

username:password:

Replace the marker username and password for the actual username and password. Use one line for each entry

  • Restart the router


Testing

  • Use a tablet or a PC to connect to the mesh network
  • Open a browser and type in a URL



Conclusion

After you have installed and configured everything, you should have a captive portal working on a wireless mesh network. All DHCP request are handled by the gateway running CoovaChilli. And Internet access is controlled by CoovaChilli.

Sunday, December 2, 2012

Running NetBeans using a Mac Network User Account

I have known this for a long time now. And today, I just happen to need NetBeans again. I am using Mac OSX 10.6 logged in as a network user. You'd think it would be easy to run NetBeans in this environment. Well, think again. I, again, forgot how to start NetBeans.

So I am writing this to share to other, and serve also as a reminder to myself.

Steps to running NetBeans:

1. Open a Terminal
2. Type the following on the Terminal

open <Path to NetBeans.app> --args -J-Dosgi.locking=none

That's it!


Friday, November 23, 2012

CoovaChilli - MAC Address Authentication

Since it's hard to get a straight answer from CoovaChilli's site, I just decided to post my findings in here.

Today, after so much searching and testing, I discovered how to bypass CoovaChilli's usual login page. In this post you will learn how to allow a device to gain access to the Internet via CoovaChilli based on the devices' MAC address.

Thursday, November 22, 2012

OpenWRT+CoovaChilli

Introduction

Today I am going to share my experience in Installing CoovaChilli on a router.

My first attempt with this endeavor ended up with me having a very expensive brick instead of a captive portal. So for those who want to avoid this costly experience I am laying out this simple installation process for you to follow and hopefully succeed. Once you get comfortable with it you can then venture into more riskier approach, like compiling your own OpenWRT.

I am using TP-Link's MR3220 as my router. Though I haven't tried it yet, I hope the same approach will work on other routers based on Altheros AR71xx.
Let's start!

Tuesday, October 23, 2012


Creating a Capture Portal using CoovaChilli, FreeRadius, and MySQL







Objectives
  • Create a capture portal
  • Use MySQL database to hold user accounts and accounting data
  • Limit access/session time per user
  • Limit access/session time per MAC address
  • Limiut simultaneous logins



Requirements

  • Ubuntu 12.04.1 LTS
  • CoovaChilli
  • PC with 2 Network Card
  • Internet Access



Install Ubuntu

  • Download a copy of Ubuntu 12.04 LTS from http://www.ubuntu.com/download/desktop
  • Burn the ISO image onto a CD
  • Insert the CD in the CD Drive
  • Start the computer
  • Wait for Ubuntu to boot from the CD
  • Click “Install Ubuntu”
  • Click “Continue”
  • Select the option to erase the content of the disk and install Ubuntu. Click “Continue”
  • Click “Install Now”
  • Set your timezone then click “Continue”
  • Select appropriate keyboard layout then click “Continue”
  • Type your name, computer name, login name, and password. Click “Continue”
  • Wait until Ubuntu finishes copying the files
  • Click “Restart”
  • Remove CD from Drive then click press Enter
  • Wait for the computer to restart


Additional Software Installation

  • Login using the username and password you provided earlier
  • Click on the Ubunto Icon and type “Terminal” in the search box
  • Click the Terminal
  • Update the source packages
sudo apt-get update

  • Install tasksel

sudo apt-get install tasksel
  • Run tasksel and select LAMP server then click OK

sudo tasksel

  • When asked for “New password for the MYSQL ‘root’ user” use mysqlsecret (this password is use for this documentation. Change this for production use)


Enable packet forwarding

  • Execute the following command

echo 1 > /proc/sys/net/ipv4/ip_forward


To ensure packet forwarding is enable every time you reboot, do the following 

  • Open /etc/sysctl.conf

  • Uncomment the line

net.ipv4.ip_forward=1

  • Save and close sysctl.conf



Install and Configure FreeRadius

  • Install FreeRadius

sudo apt-get install freeradius 




Test FreeRadius

  • Uncomment line 90
    "John Doe"      Cleartext-Password := "hello"
    and line 91
    Reply-Message = "Hello, %{User-Name}"
    in /etc/freeradius/users
  • Restart FreeRadius

/etc/init.d/freeradius restart

  • Use radtest to test FreeRadius

radtest "John Doe" hello 127.0.0.1 0 testing123

  • The output should be similar to this

Sending Access-Request of id 153 to 127.0.0.1 port 1812
        User-Name = "John Doe"
        User-Password = "hello"
        NAS-IP-Address = 127.0.1.1
        NAS-Port = 0





Install CoovaChilli

  • Create user for CoovaChilli
sudo useradd chilli -s /usr/sbin/nologin

  • Install required libraries
sudo apt-get install libssl-dev
sudo apt-get install haserl

  • Download CoovaChilli

cd
mkdir chilli
cd chilli


  • Compile and Install CoovaChilli

tar -xzvf coova-chilli-1.3.0.tar.gz
cd coova-chilli-1.3.0
./configure --prefix= --enable-largelimits --enable-miniportal --with-openssl
make
sudo make install



Configure CoovaChilli

sudo su -
cd /etc/chilli
cp defaults config
echo iptables -I POSTROUTING -t nat -o \$HS_WANIF -j MASQUERADE >> ipup.sh
/etc/init.d/chilli start && /etc/init.d/chilli stop



Test CoovaChilli

Connect eth0 to the LAN or device that has access to the internet
Set the default gateway to the IP of the Internet gateway that is located in eth0’s LAN
Connect eth1 to an access point or switch
Make sure that DHCP service is disabled in the above-mentioned access point

Start CoovaChilli
Using a tablet, phone or a pc, connect to the access point
Open an Internet browser and go to any site
You should be redirected to the capture portal’s login page

When checking who is logged in, sometimes radwho will give this error
radwho: Error reading /var/log/freeradius/sradutmp: No such file or directory
To fix it, uncomment sradutmp in the accounting section of /etc/freeradius/sites-available/default then restart freeradius

Customize Login Page



Use MySQL for FreeRadius User Configuration

Install Required Packages

  • MySQL is already installed. All we need is to install FreeRadius’s MySQL package

sudo apt-get install freeradius-mysql


Configure MySQL Database for FreeRadius

  • Create a database for FreeRadius to use

mysqladmin -uroot -pmysqsecret create radius

  • Create a user that will have access to the radius database. We’ll use one provided in FreeRadius’s MySQL package

mysql -uroot -pmysqlsecret  < /etc/freeradius/sql/mysql/admin.sql

  • Create the tables

mysql -uroot -pmysqlsecret radius < /etc/freeradius/sql/mysql/schema.sql

  • Add a test user

mysql -uroot -pmysqlsecret radius -e "INSERT INTO radcheck (username, attribute, op, value) VALUES ('testuser', 'Cleartext-Password', ':=', 'password')"


Configure FreeRadius

  • Uncomment the line

    $INCLUDE sql.conf

    in /etc/freeradius/radiusd.conf

  • Uncomment the line

    sql

    in the authorize section of /etc/freeradius/sites-available/default (by default this is in line 159)



Test FreeRadius MySQL User Configuration

  • Restart FreeRadius

/etc/init.d/freeradius restart

  • Use radtest to login as testuser

radtest testuser password 127.0.0.1 0 testing123

  • The result should look something like

Sending Access-Request of id 199 to 127.0.0.1 port 1812
        User-Name = "testuser"
        User-Password = "password"
        NAS-IP-Address = 127.0.1.1
        NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=199, length=20



Limit Access Time Per User

Limiting the time a use can access the Internet is done by basically returning an AVP of Session-Timeout. But using this a user can just log back in again. To prevent this a counter is used.

Since we already have FreeRadius’s MySQL package, we’ll use the sqlcounter. Our counter will reset the count on a daily basis thus a user can again use his account on the next day 

  • Open /etc/freeradius/dictionary and append the lines

    ATTRIBUTE      Daily-Session-Time      3000    integer
    ATTRIBUTE      Max-Daily-Session       3001    integer
  • Uncomment the line

    sql

    in the accounting section of /etc/freeradius/sites-available/default (by default this is in line 388)

  • Open /etc/freeradius/sql/mysql/counter.con and change the sql directive of dailycounter from this:

    query = "SELECT SUM(acctsessiontime - \
    GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)), 0)) \
    FROM radacct WHERE username = '%{%k}' AND \
    UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%b'"

    to this:

    query = "SELECT IFNULL(SUM(acctsessiontime - \
    GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)), 0)),0) \
    FROM radacct WHERE username = '%{%k}' AND \
    UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%b'"

  • Open /etc/freeradius/sites-available/default and add the line

    dailycounter

    just below daily in the authorize section (this should be in line 175)

  • Uncomment the line

    $INCLUDE sql/mysql/counter.conf

    in /etc/freeradius/radiusd.conf (this is at line 695)

  • Add a 15minute limit to testuser account

mysql -uroot -pmysqlsecret radius -e "INSERT INTO radcheck (username, attribute, op, value) VALUES ('testuser', 'Max-Daily-Session', ':=', 1800)"

  • Restart FreeRadius



Test Configuration for Limiting Access Time Per User

  • Restart FreeRadius

/etc/init.d/freeradius restart

  • Use radtest to login as testuser

radtest testuser password 127.0.0.1 0 testing123

  • The result should look something like

Sending Access-Request of id 132 to 127.0.0.1 port 1812
        User-Name = "testuser"
        User-Password = "password"
        NAS-IP-Address = 127.0.1.1
        NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=132, length=26
        Session-Timeout = 1800

Notice the “Session-Timeout” at the end of FreeRadius reply. This indicates the amount of time (in seconds) a user can access the internet using the capture portal.

To actually test the configuration browse the Internet by logging through the capture portal. Track the time from login up to the given time limit. When the configured time has lapsed you should be directed to the login screen. You should not be able to use the account again until the counter is reset (in this case, until the next day)



Limiting Simultaneous Logins Per User

This time we will limit the number of simultaneous login a user can have. We will use the rlm_sql module since it is faster (according to the notes in the configuration file)

  • In the /etc/freeradius/sites-available/default
    • Make sure sql is included in the accouting section (line 389)
    • Comment radutmp in the session section (line 433)
    • Uncomment sql in the session section (line 437)

  • Uncomment the simul_count_query in /etc/freeradius/sql/mysql/dialup.conf (lines 279-282)

  • Limit testuser to one session

mysql -uroot -pmysqlsecret radius -e "INSERT INTO radcheck (username, attribute, op, value) VALUES ('testuser', 'Simultaneous-Use', ':=', '1')"

  • Restart FreeRadius



Limit Access Time Per Device (MAC) Address

In this section we will limit the access time of a device base on user and the device’s MAC address

  • Append the following to /etc/freeradius/dictionary

ATTRIBUTE       MY-Counter-Reset-Type 3002    string
ATTRIBUTE       MY-Time-Limit                 3003    string
ATTRIBUTE       MY-Session-Start-Time   3004    integer
ATTRIBUTE       MY-Used-Session-Time  3005    string
ATTRIBUTE       MY-Avail-Session-Time   3006    string

  • Create the file /etc/freeradius/modules/set_starttime with the following content

perl set_starttime {
        module = ${confdir}/set_starttime.pl
}

  • Create the file /etc/freeradius/modules/check_time with the following content

perl check_time {
        module = ${confdir}/check_time.pl
}

  • Create the file /etc/freeradius/set_starttime.pl with the following content

#!/usr/bin/perl 
use strict;
# use ...
# This is very important ! Without this script will not get the filled hashesh from main.
use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK);
use Data::Dumper;

# This is hash wich hold original request from radius
#my %RAD_REQUEST;
# In this hash you add values that will be returned to NAS.
#my %RAD_REPLY;
#This is for check items
#my %RAD_CHECK;

#
# This the remapping of return values
#
        use constant    RLM_MODULE_REJECT=>    0;#  /* immediately reject the request */
        use constant    RLM_MODULE_FAIL=>      1;#  /* module failed, don't reply */
        use constant    RLM_MODULE_OK=>        2;#  /* the module is OK, continue */
        use constant    RLM_MODULE_HANDLED=>   3;#  /* the module handled the request, so stop. */
        use constant    RLM_MODULE_INVALID=>   4;#  /* the module considers the request invalid. */
        use constant    RLM_MODULE_USERLOCK=>  5;#  /* reject the request (user is locked out) */
        use constant    RLM_MODULE_NOTFOUND=>  6;#  /* user not found */
        use constant    RLM_MODULE_NOOP=>      7;#  /* module succeeded without doing anything */
        use constant    RLM_MODULE_UPDATED=>   8;#  /* OK (pairs modified) */
        use constant    RLM_MODULE_NUMCODES=>  9;#  /* How many return codes there are */

# Function to handle authorize
sub authorize {
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

    #Find out when the reset time should be 
    if($RAD_CHECK{'MY-Counter-Reset-Type'} =~ /monthly/i){
        $RAD_CHECK{'MY-Session-Start-Time'} = mktime (0, 0, 0, 1, $mon, $year, 0, 0);   #We use this month 
    }
    if($RAD_CHECK{'MY-Counter-Reset-Type'} =~ /weekly/i){
        $RAD_CHECK{'MY-Session-Start-Time'} = mktime (0, 0, 0, $mday-$wday, $mon, $year, 0, 0);
    } 
    if($RAD_CHECK{'MY-Counter-Reset-Type'} =~ /daily/i){  
        $RAD_CHECK{'MY-Session-Start-Time'} = mktime (0, 0, 0, $mday, $mon, $year, 0, 0);
    }
    if(exists($RAD_CHECK{'MY-Session-Start-Time'})){
        return RLM_MODULE_UPDATED;
    } else {
        return RLM_MODULE_NOOP;
    }
}


  • Create the file /etc/freeradius/check_time.pl with the following content

#!/usr/bin/perl
use strict;
# use ...
# This is very important ! Without this script will not get the filled hashesh from main.
use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK);
use Data::Dumper;

# This is hash wich hold original request from radius
#my %RAD_REQUEST;
# In this hash you add values that will be returned to NAS.
#my %RAD_REPLY;
#This is for check items
#my %RAD_CHECK;

#
# This the remapping of return values
#
        use constant    RLM_MODULE_REJECT=>    0;#  /* immediately reject the request */
        use constant    RLM_MODULE_FAIL=>      1;#  /* module failed, don't reply */
        use constant    RLM_MODULE_OK=>        2;#  /* the module is OK, continue */
        use constant    RLM_MODULE_HANDLED=>   3;#  /* the module handled the request, so stop. */
        use constant    RLM_MODULE_INVALID=>   4;#  /* the module considers the request invalid. */
        use constant    RLM_MODULE_USERLOCK=>  5;#  /* reject the request (user is locked out) */
        use constant    RLM_MODULE_NOTFOUND=>  6;#  /* user not found */
        use constant    RLM_MODULE_NOOP=>      7;#  /* module succeeded without doing anything */
        use constant    RLM_MODULE_UPDATED=>   8;#  /* OK (pairs modified) */
        use constant    RLM_MODULE_NUMCODES=>  9;#  /* How many return codes there are */

# Function to handle authorize
sub authorize {
    if(!exists($RAD_CHECK{'MY-Time-Limit'}) || !exists($RAD_CHECK{'MY-Used-Session-Time'})){
        return RLM_MODULE_NOOP;
    }

    $RAD_CHECK{'MY-Avail-Session-Time'} = $RAD_CHECK{'MY-Time-Limit'} - $RAD_CHECK{'MY-Used-Session-Time'};    
    
    if($RAD_CHECK{'MY-Avail-Session-Time'} <= $RAD_CHECK{'MY-Time-Limit'}){        
        if($RAD_CHECK{'MY-Counter-Reset-Type'} ne 'never'){ 
            $RAD_REPLY{'Reply-Message'} = "Maximum usage exceeded";
        }
        return RLM_MODULE_REJECT;
    }

    $RAD_REPLY{'Session-Timeout'} = int($RAD_CHECK{'MY-Avail-Session-Time'});

    return RLM_MODULE_UPDATED;
}


Add the following in the authorize section of /etc/freeradius/sites-available/default, just below daily (line 174). Delete or comment dailycounter

        if((control:MY-Time-Limit)&&(control:MY-Counter-Reset-Type)){
                set_starttime
                if(updated){
                        update control {
                                MY-Used-Session-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime), 0) FROM radacct WHERE UNIX_TIMESTAMP(acctstarttime) > %{control:MY-Session-Start-Time} AND username = '%{request:User-Name}' AND IF(username = 'free', callingstationid='%{request:Calling-Station-Id}', TRUE)}"
                        }
                } 
                else {
                        update control {
                                MY-Used-Session-Time := "%{sql:SELECT IFNULL(SUM(acctsessiontime), 0) FROM radacct WHERE username = '%{request:User-Name}' AND IF(username = 'free', callingstationid='%{request:Calling-Station-Id}', TRUE)}"
                        }
                }
                check_time

Note that “else {“ must be in a new line

  • Give testuser a daily access limit of 15 minutes

mysql -uroot -pmysqlsecret radius -e "INSERT INTO radcheck (username, attribute, op, value) VALUES ('testuser', 'MY-Time-Limit', ':=', ‘1800’)"
mysql -uroot -pmysqlsecret radius -e "INSERT INTO radcheck (username, attribute, op, value) VALUES ('testuser', 'MY-Counter-Reset-Type', ':=', 'daily')"

  • Remove the simultaneous usage limit created in the previous section

mysql -uroot -pmysqlsecret radius -e "DELETE FROM radcheck WHERE username='testuser' and attribute='Simultaneous-Use'"

  • Stop FreeRadius

/etc/init.d/freeradius stop

  • Start FreeRadius in debug mode

freeradius -XX

If you get an error like

Can't load '/usr/lib/perl/5.14/auto/Data/Dumper/Dumper.so' for module Data::Dumper: /usr/lib/perl/5.14/auto/Data/Dumper/Dumper.so: undefined symbol: PL_charclass at /usr/share/perl/5.14/XSLoader.pm line 71.
 at /usr/lib/perl/5.14/Data/Dumper.pm line 36
Compilation failed in require at /etc/freeradius/set_starttime.pl line 6.
BEGIN failed--compilation aborted at /etc/freeradius/set_starttime.pl line 6.
Thu Oct 25 10:51:37 2012 : Error: rlm_perl: perl_parse failed: /etc/freeradius/set_starttime.pl not found or has syntax errors.
Thu Oct 25 10:51:37 2012 : Error: /etc/freeradius/modules/set_starttime[1]: Instantiation failed for module "set_starttime"
Thu Oct 25 10:51:37 2012 : Error: /etc/freeradius/sites-enabled/default[176]: Failed to load module "set_starttime".
Thu Oct 25 10:51:37 2012 : Error: /etc/freeradius/sites-enabled/default[176]: Failed to parse "set_starttime" entry.
Thu Oct 25 10:51:37 2012 : Error: /etc/freeradius/sites-enabled/default[62]: Errors parsing authorize section.

This means FreeRadius has problems dynamically loading perl modules. A workaround is to set LD_PRELOAD environment variable before starting FreeRadius. Use the following command

LD_PRELOAD=/usr/lib/libperl.so.5.14 /usr/sbin/freeradius -XXX

This Setup will allow simultaneous devices using testuser account to have 15 minute daily access to the Internet using the capture portal
















Debugging PHP using NetBeans and x Debug

Objective:

To be able to debug PHP files



Tested on:

- Windows 7 64 bit



Requirements:

- NetBeans 6.9.1 with PHP package
- Apache 2.2
- PHP 5.3
- xDebug 2.1.0 (php-xdebug-2.1.0-5.3-vc9.dll



Steps:

- Install PHP
- Install Apache
- Configure Apache
- Download xDebug
- Configure php.ini
- Install Netbeans
- Create a test project
- Test


- Install PHP

Get the thread safe windows zip package, php-5.3.3-Win32-VC9-x86.zip, from PHP download site http://windows.php.net/download/

unzip the package to c:\php (you can put this in other location but you have to make adjustments)


- Install Apache

Download Apache HTTP server, httpd-2.2.16-win32-x86-openssl-0.9.8o.msi, from http://httpd.apache.org/download.cgi

Start installing Apache by double clicking httpd-2.2.16-win32-x86-openssl-0.9.8o.msi.


- Configure Apache



- Download xDebug
- Configure php.ini
- Install Netbeans
- Create a test project
- Test




Reference:
http://www.xdebug.org/find-binary.php