Facebook Developers Network

Join MamakSpot Fb Developer Network


New Project unleashed !!!
Build You Own SMS System at home
http://cakesms.blogspot.com

Introduction to MamakSpot



Watch the demo video here

What is MamakSpot ?
A wifi controller. You can control your wifi users using a web based management system.

Features ? You can control the users by
1.by maximum usage hours
2.by expire date
3.by upload/download speed in kbps

How many versions of MamakSpot ?
1. MamakSpot Prepaid Edition
2. MamakSpot Manage Edition

MamakSpot Prepaid Edition ?
MamakSpot prepaid is targeted to people who wants to run prepaid business using Wifi. Admin can create X numbers of prepaid and registered or public users can buy the prepaid for their internet usage.

Mamakspot Manage Edition ?
This is fork from version 1 of MamakSpot. User must be registered first. Admin the, can select which user have the rights to surf the net. Admin simply enable particular user with some credentials like
1. upload/bandwith speed
2. Expiry date
Admin can check every connected user internet history like :
1. When he/she online
2. Number of hours online by day,month,year
3. Total bandwidth downloaded/uploaded
4. Sites visited
Who are the developer for MamakSpot ?
Currently, I'm the only one doing the RnD. From understanding how Radius server works to Web Management Interface. I can be contacted at 014.6412.911 ( Malaysia ) or by email at azril.nazli@gmail.com


Mamakspot V1 is free ( http://code.google.com/p/mamakspot/ )

Monday, April 28, 2008

IP 2 Location using Google Map


PHP Code to retrieve the Longitude and Latitude for given IP Address


IP 2 Loc hosted at http://ad.protonmania.com

After saw the Ajax Powered IP to Location finder by Seomoz , I've decided to dig the net on how to do that using CakePHP .

Basically , I'll get the IP given by the user via $_POST or $_GET, filter it and try to get the longitude and latitude value from 3rd party site, in this case I'm using http://netgeo.caida.org/

Example http://netgeo.caida.org/perl/netgeo.cgi?target=202.188.1.5
Then filter the result, do some PHP coding and only get the Latitude and Longitude.

Pass that value to Google Map engine, and voila.

Reference URL
CakePHP = http://cakephp.org
Google Map Account = http://code.google.com/apis/maps/signup.html
CakePHP - Google Map Tutorial = http://bakery.cakephp.org/articles/view/adding-a-google-map-to-your-app

Example : http://ad.protonmania.com/ip2loc

Friday, April 25, 2008

Siaran tergendala : ad.protonmania.com



Clone Mudah.com.my, tapi tak siap lagi. 2 hari coding guna Cakephp 1.19. Dah mahir Cakephp 12 nanti, saya akan sambung development untuk mamakspot.

Sebelum itu, mari cuba testdrive applikasi baru saya ini

http://ad.protonmania.com

Sunday, April 20, 2008

Registration Module


User Controller


User Model


User View

I done it using CakePHP 1.2
Very basic user registration.
The flow
1. User register by entering username & password
2. System will check for duplicate username
3. After logged in user will be needed to complete some information
4. User choose type of subscription
5. User add mobile phone number
6. User complete his profile
7. List of subscriptions status

Saturday, April 19, 2008

CakePHP 1.2 Dev Update


1. Dowonloaded CakePHP 1.2 beta from CakePHP.org

2. Edit apache httpd.conf to enable .htaccess parsing

3. CakePHP installed on /var/www/html/cake

4. Database configured,chmod 777 APP/tmp and APP/cache folder

5. Design database in process


CakePHP Model

-------------------------------------

radusers = hasMany tables

radprofiles = belongsTo radusers

radcheck = belongsTo radusers


6.Added user_id field to radcheck table
7.Writing Model/View/Controller for user registration

Thursday, April 17, 2008

User Requirement Spec

I need code rewriting and these is in my heads

Admin Panel
- add user
- edit user
- delete user
- activate user
- deactivate user
- view usage status
- disconnect user
- set maximum download/upload speed
- set maximum bandwidth usage
- view current online users
- view overall statistics
- auto generate user on the fly based on hour ( username + password )

User
- registration module
- user management module
- view prepaid balance
- buy new prepaid

Registration Mode / User Groups
- prepaid mode
- postpaid mode
- by number of days/months mode
- by bandwidth mode

MamakSpot : Pembangunan Software

Saya telah selesai membuat tutorial untuk membina MamakSpot dari 1 hingga 5. Peringkat seterusnya bergantung kepada usaha anda sendiri untuk mempelajari

1. Radius Server
2. Coding PHP/MYSQL

Sehingga ke tahap tutorial 5, anda sudah boleh add/edit/delete user menggunakan MySQL. Jadi secara tidak langsung anda boleh membuat software sendiri seperti MamakSpot untuk automatekan process tersebut.

Jadi saya akan berhenti membuat tutorial di sini dan akan menumpukan perhatian kepada pembangunan software MamakSpot.


Ubah kepada CakePHP 1.2
Buat masa ini kod PHP MamakSpot ditulis secara ekspres tanya mementingkan soal keselamatan dan future upgrade. Jadi saya akan re-code balik semua code menggunakan PHP FrameWork dari jenis CakePHP . Anda boleh lawati laman web mereka di http://www.cakephp.org

Link CakePHP
1.http://www.cakephp.org - The official site
2.http://cakephpforum.net - CakePHp Forum International
3.http://www.php.net.my - CakpePHP Forum Malaysia

Gammu Server Server
Integrasi dengan SMS Server
1.User register dgn MamakSpot ( username + password + mobile number )
2.User pay via payment engine ( Maybank2u,Paypal)
3.Sistem automatically activate the user status == active
4.MamakSpot will send SMS notifier you're activated using Gammu
5.User can start using Mamakspot

Saya juga terfikir mengenai mekanisma tolak kredit guna SMS, cuma masih tidak faham dengan perjalanannya.

1. User buy prepaid RM5 ( 5 hours online ) using SMS
2. user type prepaid rm5 and send to designated number
3. SMS system will deduct RM5 for user and put into my account
4. SMS system notify Mamakspot account deducted from user credit sms
5. Mamakspot auto activate the user and send activation notice

Hmmm......payment engine.

Actually dengan sistem Mamakspot, saya boleh letak Master Mamakspot server di datacenter ( sewa colocation ) dan hanya deploy AP Linksys yang telah dimodified di banyak tempat contohnya 1Ap di selayang,1AP di putrajaya....dan seterusnya

Bayangkan ada saya mempunyai 200 AP dan kesemuanya akan refer ke Master Mamakspot server untuk authentication,accounting,activation,user management etc.

Jadi untuk itu saya memerlukan mekanisme payment engine yang mudah untuk rakyat Malaysia, iaitu tolak kredit dari SMS.

Tutorial 5 : Network Cabling


MamakSpot CAT 5 Wiring Video

Video mengenai Linux box dan AP Linksys

Wednesday, April 16, 2008

Tutorial 5: Install Coova Chilli

Coova Chilli adalah server untuk mengawal user.coova akan mendapatkan data dari server radius dan akan check samaada pengguna yang ingin login mempunyai akaun, status aktif atau tidak. Jika user failed dari segi memberi password atau tidak wujud dalam sistem atau status == reject, Coova tidak membenarkan user tersebut dari masuk ke dalam sistem.

Sekiranya user berjaya masuk dalam sistem, Radius server bersama Coova akan mengawasi user tersebut dan akan membuat accounting dari segi jumlah masa online,jumlah kilobyte data download upload, ip range yang diberi.

Coova juga berfungsi memberikah IP secara DHCP kepada connected clients.

Harap anda membaca documentation dahulu di site Coova Chilli : http://coova.org/wiki/index.php/CoovaChilli

Saya menggunakan Coova Chilli versi 1.0.11

Doanload source code : http://ap.coova.org/chilli/coova-chilli-1.0.11.tar.gz

Untar : tar zxvf coova-chilli-1.0.11.tar.gz
Configure : ./configure
Make : make
Install : make install

Setelah install, kita kena configure Coova untuk menggunakan setting radius server FreeRadius. Dalam tutorial 4, kita berjaya authenticate user "mankukhayun" dengan password "abc123"

jadi perlu ingat setting radius di bawah
radius ip : 127.0.0.1
nas secret : testing123
port acct : 1812
test user account : mankukhayun
test user password : abc123
IP eth1 : 10.0.0.1

1. Edit fail configuration Coova di vi /usr/local/etc/chilli/config

vi /usr/local/etc/chilli/config

Ubah data di dalam fail config

# -*- /bin/sh -*-
#
# Coova-Chilli Default Configurations.
# To customize, copy this file to /usr/local/etc/chilli/config
# and edit to your liking. This is included in shell scripts
# that configure chilli and related programs before file 'config'.


###
# Local Network Configurations
#

HS_WANIF=eth0 # WAN Interface toward the Internet
HS_LANIF=eth1 # Subscriber Interface for client devices
HS_NETWORK=10.0.0.1 # HotSpot Network (must include HS_UAMLISTEN)
HS_NETMASK=255.255.255.0 # HotSpot Network Netmask
HS_UAMLISTEN=10.0.0.1 # HotSpot IP Address (on subscriber network)
HS_UAMPORT=3990 # HotSpot Port (on subscriber network)

# HS_DYNIP=
# HS_DYNIP_MASK=255.255.255.0
# HS_STATIP=
# HS_STATIP_MASK=255.255.255.0
# HS_DNS_DOMAIN=
# HS_DNS1=
# HS_DNS2=

###
# HotSpot settings for simple Captive Portal
#
HS_NASID=hotspot
#HS_UAMSECRET=testing123
HS_RADIUS=127.0.0.1
# HS_RADIUS2=rad01.coova.org
HS_RADSECRET=testing123
# HS_UAMALLOW=coova.org

# Put entire domains in the walled-garden with DNS inspection
# HS_UAMDOMAINS=".paypal.com,.paypalobjects.com"

# Optional initial redirect and RADIUS settings
# HS_SSID= # To send to the captive portal
# HS_NASMAC= # To explicitly set Called-Station-Id
# HS_NASIP= # To explicitly set NAS-IP-Address

# The server to be used in combination with HS_UAMFORMAT to
# create the final chilli 'uamserver' url configuration.
HS_UAMSERVER=10.0.0.1

Save fail tersebut dan kita akan runningkan daemon chilli tersebut. laksanakan command di bawah

/usr/local/etc/init.d/chilli start


Pastikan apache web server anda sedang berjalan dan berfungsi. Kebiasaannya Apache Web Server didatangkan sekali dengan Centos. Jika anda tidak mempunyai Apache web server , sila install dahulu

Secara default, folder webroot apache terletak di path ini : /var/www/html
Folder untuk menyimpan fail cgi pula terletak di sini : /var/www/cgi-bin

Coova Chilli menggunakan fail hotspotlogin.cgi untuk authenticate user. Fail tersebut di datangkan sekali dengan source tarball yang anda telah download


[root@hotspot uam]# find / | grep 'hotspotlogin.cgi'
/root/coova/coova-chilli-1.0.11/doc/hotspotlogin.cgi


Salin fail tersebut ke dalam folder cgi-bin di /var/www/cgi-bin
Ubah permission fail tersebut

chmod +x hotspotlogin.cgi


Mari kita cuba invoke hotspotlogin.cgi menggunakan web browser. Halakan web browser anda ke http://192.168.1.2/cgi-bin/hotspotlogin.cgi

Sepatutnya anda akan menerima page seperti di dalam gambar rajah di bawah



Seterusnya kita perlu buat satu page UAM. UAM atau dikenali sebagai Universal Access Method ialah page yang serve login form dan juga status.

Anda perlu download fail ini http://protonmania.com/freeradius/uam.tar.gz
Untar fail tersebut dan copy ke folder berikut

/var/www/html/uam/

Pastikan fail-fail tersebut ada di dalam folder uam

[root@hotspot html]# ls -l /var/www/html/uam
total 20
-rw-r--r-- 1 root root 8034 Feb 23 15:47 chilliController.js
-rw-r--r-- 1 root root 1068 Dec 20 19:59 chilli.js
-rw-r--r-- 1 root root 3491 Aug 11 2007 coova.jpg
-rw-r--r-- 1 root root 1231 Mar 1 05:34 index.html
[root@hotspot html]#


Bagaimana kita hendak menguji Coova dan Radius sedang berjalan lancar ?

1.Setting TCP/IP di dalam Laptop ( atau pc ujian ) disetkan kepada DHCP ( lihat gambar rajah di bawah )


Kemudian sambungkan ke ethernet port2 Linksys di mana port 1 linksys telah disambungkan ke port ETH1 ( ip server linux ialah 10.0.0.1 )

2. Tunggu sebentar dan sepatutnya anda akan diberikan IP range 10.0.0.x secara automatik.

3. Jika anda berjaya mendapat IP, cuba surf ke internet

4. Sepatutnya anda akan ditahan dan menerima page login seperti di dalam gambar ini.

5. Masukkan username "mankukhayun" dan password "abc123" dan sepatutnya akan akan diauthenticate dan akan menerima page seperti di dalam gambar ini.

6. Anda boleh surf ke mana sahaja. Dan cuba logout menerusi status page tadi. Dan cuba untuk surf ke site lain. Sepatutnya anda akan ditahan oleh Coova Captive Portal.

7. Jika anda telah berjaya sampai ke tahap ini, secara teorinya anda berjaya mencipta HotSpot login ciptaan sendiri.

Saya menghabiskan dekat 2 bulan untuk membolehkan sistem ini dapat dibina. Jika anda gagal, sila cuba dan usaha lagi.

Tutorial seterusnya ialah saya akan mengajar bagaimana untuk menggunakan command-command Free Radius.

Tutorial 4 : Free Radius & MySQL

Secara default, Free Radius akan gunakan flat file untuk simpan data. Tutorial ini akan membolehkan anda mengubah FreeRadius untuk menggunakan MySQL sebagai storage server.

Pastikan anda mempunyai MySQL Server sedang running
( secara default mysql username = "root" password = "" )

[root@localhost raddb]# /sbin/service mysqld status
mysqld (pid 6933) is running...
[root@localhost raddb]#

[root@localhost raddb]# mysql -uroot
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3916 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>


Sebelum teruskan tutorial ini, sila baca tutorial di bawah :

http://www.frontios.com/freeradius.html

Dah baca ? Make sure ulang baca tutorial dalam link di atas 2-3 kali. Baiklah mari kita mulakan

Kita kena install database schema dalam database MySQL. Pengetahuan penggunaan MySQL/SQL amat penting untuk memudahkan pemahaman tutorial ini.

1. Masuk ke folder /usr/local/etc/raddb/sql/mysql

[root@localhost mysql]# cd /usr/local/etc/raddb/sql/mysql
[root@localhost mysql]# pwd
/usr/local/etc/raddb/sql/mysql
[root@localhost mysql]#


List folder tersebut dan make sure ada file bernama schema.sql. Mula-mula create database bernama radius di dalam MySQL console


[root@localhost mysql]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3920 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database radius;
Query OK, 1 row affected (0.00 sec)

mysql> exit
Bye
[root@localhost mysql]#


Database "radius" telah dibuat dan kita akan sumbatkan data dalam schema.sql ke dalam database "radius"

Laksanakan arahan berikut:


[root@localhost mysql]# mysql -uroot radius < schema.sql


Pastikan database telah diinstall dengan jayanya. Masuk semula ke MySQL console dan laksanakan arahan berikut


mysql> use radius;
Database changed
mysql> show tables;
+------------------+
| Tables_in_radius |
+------------------+
| radacct |
| radcheck |
| radgroupcheck |
| radgroupreply |
| radpostauth |
| radreply |
| radusergroup |
+------------------+
7 rows in set (0.01 sec)

mysql>

Sekarang kita akan mengubah radius configuration. Pergi ke folder /usr/local/etc/raddb/ dan edit fail radiusd.conf

Pastikan radiusd.conf include sql.conf

# Include another file that has the SQL-related configuration.
# This is another file only because it tends to be big.
#
$INCLUDE sql.conf


Kemudian edit fail sql.conf dan masukkan data seperti di bawah

#
# Set the database to one of:
#
# mysql, mssql, oracle, postgresql
#
database = "mysql"

#
# Which FreeRADIUS driver to use.
#
driver = "rlm_sql_${database}"

# Connection info:
server = "localhost"
login = "root"
password = ""


Ok sekarang cuba run balik radiusd

/usr/local/sbin/radiusd -X

rlm_sql (sql): Could not link driver rlm_sql_mysql: rlm_sql_mysql.so: cannot ope n shared object file: No such file or directory
rlm_sql (sql): Make sure it (and all its dependent libraries!) are in the search path of your system's ld.
/usr/local/etc/raddb/sql.conf[22]: Instantiation failed for module "sql"
/usr/local/etc/raddb/sites-enabled/default[126]: Failed to find module "sql".


Error ? Jangan risau, error ini sentiasa dihadapi bila install Freeradius. Solutionnya kena install mysql-devel rpm. Boleh install menggunakan YUM atau download sendiri dari rpmfind.

install mysql-devel

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mysql-devel x86_64 5.0.22-2.2.el5_1.1 rhel-x86_64-server-5 2. 4 M
mysql-devel i386 5.0.22-2.2.el5_1.1 rhel-x86_64-server-5 2. 4 M

Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 4.8 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): mysql-devel-5.0.22 100% |=========================| 2.4 MB 00:41
(2/2): mysql-devel-5.0.22 100% |=========================| 2.4 MB 01:18
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: mysql-devel ######################### [1/2]
Installing: mysql-devel ######################### [2/2]

Installed: mysql-devel.x86_64 0:5.0.22-2.2.el5_1.1 mysql-devel.i386 0:5.0.22-2.2 .el5_1.1
Complete!
[root@localhost raddb]# yum install mysql-devel

Mysql-devel library dah install. Jadi kita kena ./configure balik source code freeradius. Kembali ke folder di mana anda untar free radius dan lakukan semua process ./configure, make dan make install dan run kembali radiusd -X

Anda sepatutnya dapat result seperti di dalam gambar di bawah


Jika berjaya dapat result seperti di atas, ini bermaksud Free Radius berjaya load library MySQL. Seterusnya kita kena configure FreeRadius supaya abaikan user yang disimpan menggunakan text files dan hanya gunakan MySQL

Edit file berikut:

[root@localhost sites-enabled]# vi /usr/local/etc/raddb/sites-enabled/default

Fail ini mengandungi realm configuration seperti
authorize{
# config
#config
}
accounting{
# config
# config
}

Kita kena matikan option Files dan enable kan Sql di dalam kedua-dua realm tersebut. Anda hanya perlu ubah 2 realm,authorize{} dan accounting{}

authorize{
# matikan files
# files
# guna mysql untuk auth
sql
}

accounting{
# gunakan sql untuk acccounting
sql
}

Boleh lihat contoh file default di http://protonmania.com/freeradius/default.txt

Restart semula radiusd -X

Sekarang kita cuba authenticate user yang disimpan di dalam database MySQL.Masukkan username bernama "mankukhayun" dan password "abc123" ke dalam table radcheck di dalam database radius

mysql> insert into radcheck (username,attribute,value,op) VALUES ('mankukhayun','Password','abc123','==');
Query OK, 1 row affected (0.00 sec)

mysql> select * from radcheck;
+----+-------------+-----------+----+--------+
| id | username | attribute | op | value |
+----+-------------+-----------+----+--------+
| 1 | mankukhayun | Password | == | abc123 |
+----+-------------+-----------+----+--------+
1 row in set (0.00 sec)


Laksanakan arahan berikut

[root@localhost ~]# radtest mankukhayun abc123 127.0.0.1 1812 testing123


Jika berjaya, anda akan dapat hasil seperti di gambarajah berikut


Jika anda berjaya menamatkan tutorial hingga ke tahap ini, tahniah, kerana saya menghabiskan masa dekat 2 minggu menyelesaikan masalah Freeradius dan MySQL.

Tutorial 3 : Free Radius 2.0.3

Okay, sudah sampai ke tahap nak install Free Radius. Sila download source code di URL di bawah :

http://freeradius.org/download.html

Download version 2.0.3 dan baca installation procedure. RTFM!. Saya galakkan compile dari source dari install guna RPM.

Download Free Radius

-bash-3.1$ wget ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-2.0.3. tar.gz
--08:33:54-- ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-2.0.3.ta r.gz
=> `freeradius-server-2.0.3.tar.gz'
Resolving ftp.freeradius.org... 66.135.41.84
Connecting to ftp.freeradius.org|66.135.41.84|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/freeradius ... done.
==> SIZE freeradius-server-2.0.3.tar.gz ... 3488944
==> PASV ... done. ==> RETR freeradius-server-2.0.3.tar.gz ... done.
Length: 3488944 (3.3M)

100%[====================================================================================================================>] 3,488,944 134K/s in 27s

08:34:25 (126 KB/s) - `freeradius-server-2.0.3.tar.gz' saved [3488944]


Untar Free Radius
-bash-3.1$ tar zxvf freeradius-server-2.0.3.tar.gz

Configure Free Radius

-bash-3.1$ pwd
/var/www/html/freeradius-server-2.0.3
-bash-3.1$ ./configure
.
.
.
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h


Make Free Radius ( kalau tiada error )

-bash-3.1$ make


Kemudian kita install Free Radius

-bash-3.1$ make install


Kalau berjaya akan dapat mesej berikut

----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
[root@localhost freeradius-server-2.0.3]#


Dan binary berikut adalah yang berasal dari freeradius

[root@localhost freeradius-server-2.0.3]# rad
radclient radlast radtest radzap
radeapclient radsqlrelay radwho
[root@localhost freeradius-server-2.0.3]# rad


Nak uninstall Free Radius ? Malangnya, dalam Free Radius tidak diberikan sekali command make uninstall . Tapi boleh guna teknik di bawah :

You can use checkinstall to uninstall FreeRADIUS.

http://www.asic-linux.com.mx/~izto/checkinstall/

What you do is use checkinstall to install FreeRADIUS a second time from freeradius-server-2.0.2.tar.gz. You use the commands:

./configure
make
checkinstall

checkinstall will create a deb or rpm package for you. You then install the deb or rpm package and then uninstall it.


Ok. Skrg dah berjaya install Free Radius. Cuba local di mana radiusd ( Radius Daemon ) disimpan dan kita akan run untuk pertama kali


[root@localhost freeradius-server-2.0.3]# whereis radiusd
radiusd: /usr/local/sbin/radiusd


Runkan radius daemon dengan option -X ( so kita nampak apa yang sedang berlaku )

[root@localhost freeradius-server-2.0.3]# /usr/local/sbin/radiusd -X
.
.
.
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on proxy address * port 1814
Ready to process requests.

Berdasarkan maklumat di atas freeradius akan menggunakan 3 port iaitu 1812,1813 dan 1814.

Kita akan buat ujian Radtest untuk menguji server tersebut.Perlu diingatkan, fail configuration radius semuanya terletak di folder berikut
/usr/local/etc/raddb/

CD ke folder tersebut dan edit fail users

[root@localhost raddb]# vi /usr/local/etc/raddb/users


Dan letak configurasi berikut di bahagian paling bawah

# mamakspot user radtest demonstration
mankuk Cleartext-Password := "hayun"


Save fail tersebut dan laksanakan arahan berikut: ( kill radiusd dan run kembali dahulu )

radtest mankuk hayun 127.0.0.1 1812 testing123

Sila lihat gambar di bawah untuk hasil command tersebut.


Cuba lihat mesej radiusd -X yang mengatakan

auth: type "PAP"
+- entering group PAP
rlm_pap: login attempt with password "hayun"
rlm_pap: Using clear text password "hayun"
rlm_pap: User authenticated successfully
++[pap] returns ok
Login OK: [mankuk/hayun] (from client localhost port 1812)

Bermaksud anda memasukkan username dan password yang betul dan dapat reply status Login OK. Cuba masukkan username dengan password yang salah

auth: type "PAP"
+- entering group PAP
rlm_pap: login attempt with password "xhayun"
rlm_pap: Using clear text password "hayun"
rlm_pap: Passwords don't match
++[pap] returns reject
auth: Failed to validate the user.
Login incorrect (rlm_pap: CLEAR TEXT password check failed): [mankuk/xhayun] (from client localhost port 1812)
Found Post-Auth-Type Reject
+- entering group REJECT
expand: %{User-Name} -> mankuk
attr_filter: Matched entry DEFAULT at line 11
++[attr_filter.access_reject] returns updated


Anda akan direject.Dan sistem tidak akan authenticate anda.

Untuk mengubah nas secret "testing123", ubah fail clients.conf dan cari entry untuk 127.0.0.1


Jika anda telah berjaya ke tahap ini, itu sudah memadai. Tutorial seterusnya ialah kita akan ubah configuration radius server untuk menggunakan database MySQL sebagai storage. Buat masa ini anda boleh surf Google untuk maklumat menggunakan Free Radius

Tuesday, April 15, 2008

Objektif Tutorial 1 dan 2

Objektif Tutorial 1 dan 2 ialah untuk menjadikan server Linux anda sebagai router. Router. Clients akan connect menerusi switch atau HUB yang disambungkan ke port ETH1 ( network Card 2 ). Kemudian, laksanakan arahan route.sh ( IPTABLES Firewall Script ) setiap kali boot, adalah untuk route connection ke internet menerusi ETH0 yang telah disambungkan terus ke modem Streamyx.

PC Client
10.0.0.2
|
|
|
HUB
|
|
|
ETH1 ( 10.0.0.1 )
|
|
ETH0 ( 192.168.1.2 )
|
|
MODEM STREAMYX ( 192.168.1.1 )
|
|
INTERNET

So secara amnya, anda dah boleh letak seberapa banyak clients menerusi HUB yang di connect ke ETH1, tetapi kena manually assign IP setiap client dan menggunakankan Linux sebagai router.

Tutorial seterusnya, saya akan memperkenalkan elemen paling penting dalam Mamak Spot, iaitu radius server. Jika berkesempatan, baca maklumat mengenai Free Radius di http://www.freeradius.org. Saya akan gunakan Free radius versi 2.0 untuk tutorial seterusnya. pastikan Linux anda mempunyai compiler.

Saya akan ajar bagaimana untuk compile dan install Free Radius
Kemudian kita akan install MySQL Database server
Selepas itu kita akan ubah configuration Free Radius supaya menggunakan MySQL sebagai storage.

Monday, April 14, 2008

Tutorial 2 : Setting sebagai router

Pastikan anda berjaya mengikut Tutorial 1 dengan jayanya. Seterusnya, saya akan ajar bagaimana untuk menjadikan Linux anda sebagai router. Ini bermakna, Laptop anda yang connect menerusi HUB ( Linksys AP ethernet port ) --> port ETH1, dapat melayari ke internet

Laptop anda = 10.0.0.2 ( gatewaye 10.0.0.1 iaitu ETH1 )
ETH1 = 10.0.0.1

perkara pertama, kita perlu enablekan ip forwarding di dalam Linux. edit fail /etc/systcl.conf dan ubah mengikut konfigurasi di bawah.

[root@hotspot ~]# vi /etc/sysctl.conf

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
# ubah jadi 1 ( default =0 )
net.ipv4.ip_forward = 1

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1


Kemudian, create satu script bernama route.sh dan masukkan data berikut :
route.sh

# firewall.sh
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -t mangle -F
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth1 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward


Kemudian laksanakan arahan berikut

sh route.sh


kemudian cuba ping google.com melalui Laptop anda. sepatutnya anda boleh ping ke Google.com

Tutorial 1 : Install & Configure Network Linux Centos


Kena pastikan anda mempunyai hardware berikut

1. Intel Pentium PC
2. Minima 128MB RAM
3. 2 Network Card
4. 4 keping CD kosong
5. Laptop Windows XP dengan burn cd capability
6. 2 CAT5e Straight cable ( network card )
7. Linksys WRT54GL AP

Download Linux Centos 4.6 ISO
URL : http://mirror.nsc.liu.se/CentOS/4.6/isos/i386/
Download 4 iso di atas dan burn ke dalam 4 keping CD
Saya gunakan ISO Recorder : http://isorecorder.alexfeinman.com/isorecorder.htm

Pengetahuan menggunakan Linux amat penting untuk menggunakan MamakSpot, jadi saya assume anda mempunyai pengalaman lampau install dan gunakan linux. Jika anda tidak mempunyai asas dalam Linux, sila rujuk How To dan tutorial dari Google.


Install Linux Centos dengan setting berikut
- no firewall
- server mode ( minimal configuration)
- gcc,make ,compiler kena ada

Saya assume anda berjaya install Centos 4.6 Final edition, dan di bawah adalah setting-setting yang saya guna.

Lepas install, matikan firewall, laksanakan command berikut

/sbin/service iptables stop


Matikan SELINUX, baca tutorial di http://www.revsys.com/writings/quicktips/turn-off-selinux.html


Setting untuk model Streamyx
IP-address : 192.168.1.1
Subnet : 255.255.255.0
DNS : 202.188.1.5
DNS 2 : 202.188.0.133
Mode : auto dial,auto auth
Maksudnya, kita akan set username dan password terus dalam Modem Streamyx, jadi user yang point ke gateway 192.168.1.1 akan terus dapat sambungan ke internet

Setting untuk network card 1
Nama : ETH0
IP-Address : 192.168.1.2
Subnet Mask : 255.255.255.0
Gateway Address : 192.168.1.1
Cable : Sambung terus ke ethernet port Router Modem Streamyx
# edit file : vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Setting untuk network card 1
DEVICE=eth0
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.1.2
GATEWAY=192.168.1.1
TYPE=Ethernet
Ok, kita telah edit configuration untuk Network Card 1. Mari kita suba sambungan ke internet. Laksanakan command berikut :


/sbin/service network restart

Kemudian kita akan cuba sambungan ke internet dengan ping ke google.com

ping google.com

Sepatutnya anda akan dapat result seperti berikut :

[root@localhost html]# ping google.com
PING google.com (64.233.167.99) 56(84) bytes of data.
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=238 time=322 ms
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=2 ttl=238 time=275 ms
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=3 ttl=238 time=273 ms
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=4 ttl=238 time=278 ms
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=5 ttl=238 time=273 ms

--- google.com ping statistics ---
6 packets transmitted, 5 received, 16% packet loss, time 4997ms
rtt min/avg/max/mdev = 273.613/284.723/322.454/18.936 ms
[root@localhost html]#

Jika anda berjaya hingga ke tahap ini, anda berjaya connect Linux Box anda ke internet menggunakan laluan ETH0. Seterusnya kita akan setup Network Card 2 dengan menggunakan setting berikut:

Setting untuk network card 2
Nama : ETH1
IP-Address : 10.0.0.1
Subnet Mask : 255.255.255.0
Gateway Address : 192.168.1.2
Cable : Sambung terus ke ethernet port Linksys WRt54 GL
# edit file : vi /etc/sysconfig/network-scripts/ifcfg-eth1
# Setting untuk network card 2
DEVICE=eth1
BOOTPROTO=static
BROADCAST=10.0.0.255
HWADDR=00:0C:76:6B:0B:E0
IPADDR=10.0.0.1
NETMASK=255.255.255.0
NETWORK=10.0.0.0
ONBOOT=yes
TYPE=Ethernet


Restart semula service network menggunakan command /sbin/service dan kemudian laksanakan command berikut

/sbin/ifconfig -a

Command di atas berfungsi untuk melihat network card yang telah diconfigure dalam sistem. Sepatutnya anda akan melihat data mengenai ETH0 dan dan ETH1.

-bash-3.00$ /sbin/ifconfig -a
eth0 Link encap:Ethernet HWaddr xxxxxxxxxxxx
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::206:5bff:feed:62c6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:401058151 errors:0 dropped:0 overruns:0 frame:0
TX packets:497301783 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2828013415 (2.6 GiB) TX bytes:2305496074 (2.1 GiB)
Base address:0xcce0 Memory:feb60000-feb80000

eth1 Link encap:Ethernet HWaddr xxxxxxxxxxxx
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::206:5bff:feed:62c6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:401058151 errors:0 dropped:0 overruns:0 frame:0
TX packets:497301783 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2828013415 (2.6 GiB) TX bytes:2305496074 (2.1 GiB)
Base address:0xcce0 Memory:feb60000-feb80000


* peringatan, data di atas cuma contoh sahaja, dan bukan gambaran yang anda lihat di konsol Linux anda *

Seterusnya, sambung cable CAT 5 ( straight cable ), dari ETh1 ke ethernet port ( bukan WAN port ) AP Linksys WRT 54GL. Kemudian, sambung pula Laptop anda CAT5 cable ke ethernet port no 2 di LinksysAP yang sama.

Configure Laptop anda menggunakan setting berikut:

Setting untuk Laptop
IP-Address : 10.0.0.2
Subnet-mask : 255.255.255.0
GatewayAddress: 10.0.0.1 ( poin ke ETH1 ip address )
DNS: 202.188.1.5

Kemudian, ping ke IP 10.0.0.1

Pastikan anda dapat ping reply dari 10.0.0.1, dan kemudian baru teruskan ke bab seterusnya.

Jika anda berjaya dapat ping reply, itu sudah mencukupi untuk ke tahap ini. Sepatutnya anda tidak boleh surf ke internet . Ini disebabkan Linux anda masih belum diconfigure untuk menjadi router.

bab seterusnya kita akan configure Linux anda sebagai router menggunakan IPTABLES.

Jika ada masalah mengenai tutorial di atas, hubungi saya di 014 6412911 ( Azril Nazli )

Wednesday, April 9, 2008

Bahan-bahan untuk tutorial MamakSpot


http://projek-tahun-akhir.blogspot.com

Ilmu tak baik simpan sorang-sorang, he heh.Ok, saya dah bersemangat nak buat tutorial, dan mungkin akan capture pakai video post terus ke Youtube. Tapi kena sediakan bahan-bahannya.

1 unit intel PC beserta 2 network card
2 unit linksys AP WRT54GL
Complete CD Linux Centos 4.6final ( download kat centos.org )..ada 4 keping
8 port hub / switch
Sambungan ke internet

Perjalanan Tutorial
--------------------------
  1. Saya akan mulakan dengan install Linux
  2. Kemudian saya akan setup Linux jadi router supaya client yang connect dari ETH1 boleh surf ke internet ( modem streamyx di sambung ke ETH0 )
  3. Jika berjaya surf ke internet, saya akan teruskan dengan install Apache Web Server
  4. Diteruskan dengan install PHP Scripting language
  5. Dan kemudian, kita akan install MySQL Database
  6. Seterusnya ( part paling penting ), install Free Radius
  7. Kita akan cuba authenticate menggunakan Free Radius
  8. Kita akan setup Free Radius untuk menggunakan MySQL database sebagai storage so, kita boleh add/edit/delete/read user radius guna MySQL
  9. Jika server radius dah berjaya setup, kita teruskan ke setup Coova Chilli ( sangat sangat penting ), Coova Chilli nih lah yg jadi polis check user radius dan supply Captive Portal.
  10. Kita akan setup Coova AP cakap dengan Radius
  11. Akhir sekali, install MamakSpot PHP Script, script nih yang akan control user Wifi

Lepas tuh anda boleh start HotSpot sendiri.

Saya akan buat hujung minggu, kalau takder aral melintang ( biasanya saya akan ke Sepang f1 Circuit layan track day, atau layan Go Kart kat Shah Alam, atau layan Wife saya main Guitar Hero 3...so harap-haraplaa saya takder aktiviti pada hujung munggu )

Azril Nazli
014 6412911