Hi all,
As promised, here is the information you need to setup Grase Hotspot on Multiple-locationst (please Tim, feel free to move this to the wiki if you wish).
I made several tests with the setup described below and everything seams to work fine, even the javascript login interface.
Please note:
This procedure is not for beginners, you can damage your router if you flash a wrong file to it. Also you can break Grase if you place the wrong code when editing the files, please make backup of the original files before editing.
Do it at your own risk!
1 - Description:
The goal is to deploy multiple location Hotspots with one server in the main site (headquarters) and several routers in remote locations:

To make this work we need:
- One server running Grase Hotspot at the Headquarters.
- Static public IP address at the Headquarters. This wont work with dynamic ip address.
- Routers running DD-WRT at remote locations.
2 - Redirecting Ports
First we need to allow remote routers to connect to our server, so we need to redirect the following ports to our Grase Server:
Radius: UDP: 1812, 1813 and 1814
UAM: TCP: 3990
HTTP: TCP: 80
COA: TCP: 3779 (this one is optional)
My Draytek Configuration:
1. | RADIUS1 | All | UDP | 1812 | 10.10.10.5 | v |
2. | RADIUS2 | All | UDP | 1813 | 10.10.10.5 | v |
3. | RADIUS3 | All | UDP | 1814 | 10.10.10.5 | v |
4. | UAM | All | TCP | 3990 | 10.10.10.5 | v |
5. | HTTP | All | TCP | 80 | 10.10.10.5 | v |
6. | COA | All | TCP | 3779 | 10.10.10.5 | v |
3 - Freeradius configuration
At this point we need to edit /etc/freeradius/clients.conf to allow our remote routers to connect:
If the remote router has a static public IP you should add them right after the following code:
#
# You can now specify one secret for a network of clients.
# When a client request comes in, the BEST match is chosen.
# i.e. The entry from the smallest possible network.
#
If they have dynamic IPs (the most common case) you should either use the nas table and advanced freeradius configuration to add them dynamically or you can allow all to connect (Please note, this is not the best way because its less secure).
If you are ok with less security you can add the following;
secret = hotspotradius
shortname = NAS
nastype = other
}
secret = hotspotradius
shortname = NAS
nastype = other
}
This will allow any IP to connect to radius server as long as the secret is correct.
the default secret is hotspotradius its highly recommended to change this to a more complex password.
clients.conf will look like this after line 190:
...
#
# You can now specify one secret for a network of clients.
# When a client request comes in, the BEST match is chosen.
# i.e. The entry from the smallest possible network.
#
secret = hotspotradius
shortname = NAS
nastype = other
}
secret = hotspotradius
shortname = NAS
nastype = other
}
# secret = hotspotradius-1
# shortname = private-network-1
#}
#
# secret = hotspotradius-2
# shortname = private-network-2
#}
...
We are done with freeradius, restart the server in order to load new configuration.
4 - Grase configuration and files editing
Go to grase admin interface -> Network settings and configure IP and netmask as follows:

Go to Cooova Chilli Settings ad configure:

We need to add different DHCP ranges for each remote router to avoid problems having same IP assigned to clients in the Grase server network and in the remote routers. In fact there are other ways to avoid it but that will include several modifications in the Grase structure. So , to keep it simple we use this method. Each site will have a different DHCP Start and End.
File editing:
we neeed to edit: /usr/share/grase/www/uam/hotspot.php beecause we need to capture the remote client IP address and pass it to the nojsstatus.php file to get the correct status information.
Edit hotspot.php and add: "session_start();" in the second line:
<?php
session_start();
require_once('includes/site.inc.php');
....
And the code:"$_SESSION['ipaddress'] = $_GET['ip'];" after line 30 to look like this:
...
$res = @$_GET['res'];
$userurl = @$_GET['userurl'];
$challenge = @$_GET['challenge'];
// add this line to store user IP address in session.
$_SESSION['ipaddress'] = $_GET['ip'];
...
Then we need to edit
/usr/share/grase/www/uam/nojsstatus.php
Also need to start the session so, add: "session_start();" in the second line:
<?php
session_start();
require_once('includes/site.inc.php');
...
Then we need to retrieve the IP address commenting out the code: "//$ipaddress = $_SERVER['REMOTE_ADDR'];"
and adding: "$ipaddress = $_SESSION['ipaddress'];" at line 12:
...
// Meta refresh to update
//$ipaddress = $_SERVER['REMOTE_ADDR'];
$ipaddress = $_SESSION['ipaddress'];
$username = DatabaseFunctions::getInstance()->getRadiusUserByCurrentSession($ipaddress);
...
Save both files and we are done with editing.
5 - DD-WRT
I'm not going to explain how to install DD-WRT, I will assume that you already have a router with DD-WRT firmware.
If you are already familiar with DD-WRT this is going to be piece of cake. If not, you should visit
http://www.dd-wrt.com and check if your router is supported and follow the procedures to flash it. You can brick your router doing this, please be careful.
I use D-link DIR-615 for testing and Netgear WNDR3700 V4 at the remote sites since this are very reliable routers.
Configuration:
Configure Wan interface in order to get internet access:

LAN IP Is not important, just configure something out of the chillispot range (
10.1.0.0/16). Disable DHCP and make sure that you enable NTP Client and use the correct Server and Time Zone:

Configure the Wireless interface:

Now the Coova Chilli configuration:
Go to Services -> Hotspot, enable Cillispot and configurre as follows:

You can add as many DD-WRT Routers as you want, just make sure to use different and non overlaping DHCP ranges on each.
The changes made in the files may be replaced when updating Grase package. Hope this will be included in next releases.
Thats it!!
Hope this could help someone.
Regards,
Norberto Esteves