วันอาทิตย์ที่ 9 มกราคม พ.ศ. 2554

ตอนที่ 1

การติดตั้งและปรับแต่ง Linux server ให้เป็น Wireless LAN Access Point Controller ด้วยโปรแกรม chillispot ตอนที่ 1
  • การติดตั้ง Linux server
  • การติดตั้งโปรแกรม Apache web server
  • การติดตั้งโปรแกรม Freeradius
  • ทดสอบ authentication โดยใช้ username/password ของ Unix
  • การติดตั้งโปรแกรม Chillispot แบบ Web login

1.1 การติดตั้ง Linux server


คำแนะนำการติดตั้ง

  • ในขั้นตอนที่ติดตั้งจากแผ่นซีดี ให้เลือก Package selection เป็น Software Development
  • ในขั้นตอนที่ติดตั้งจากแผ่นซีดีครบแล้ว เมื่อรีบูตกลับมาให้ปิด SeLinux โดยเปลี่ยนจาก enforcing เป็น disabled

คำแนะนำการใช้งาน

  • การคอนฟิกระบบจะง่ายขึ้น ให้ใช้วิธีการ copy และ paste คำสั่งหรือข้อความจากเอกสารที่กำลังอ่านอยู่นี้
    หากภายหลังการติดตั้งได้รับหน้าจอเป็น text mode ให้เปลี่ยนเป็นกราฟฟิคโหมด ด้วยคำสั่ง startx
  • เปิดวินโดวชื่อ terminal เพื่อใช้ในการปรับแต่งและรันคำสั่ง ดังนี้ คลิก Application, Accessories, Terminal
  • โปรแกรม editor ที่ใช้ในการแก้ไขค่าคือ gedit เป็น full screen editor ใช้เมาส์คลิกวางตำแหน่ง cursor ได้
    จบด้วยคลิกปุ่ม Save และคลิก X เพื่อปิดโปรแกรม

1.1.1 การปรับแต่งระบบลินุกซ์


(ดัดแปลงจาก การปรับแต่งระบบลินุกซ์หลังการติดตั้ง (28-9-2550) วิภัทร ศรุติพรหม http://rd.cc.psu.ac.th/content/view/14/46/ )

1. ตรวจสอบการ์ดแลนพร้อมใช้งานด้วยคำสั่ง
ifconfig -a

ผลลัพธ์

[root@dhcp160 ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:60:97:A5:38:6F
inet addr:192.168.2.220 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: 2001:3c8:9009:300:260:97ff:fea5:386f/64 Scope:Global
inet6 addr: fe80::260:97ff:fea5:386f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:126 errors:0 dropped:0 overruns:0 frame:0
TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9430 (9.2 KiB) TX bytes:8450 (8.2 KiB)
Interrupt:9 Base address:0x2080

eth1 Link encap:Ethernet HWaddr 00:01:03:18:BA:59
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:431699 errors:0 dropped:0 overruns:520 frame:0
TX packets:858 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32878596 (31.3 MiB) TX bytes:88551 (86.4 KiB)
Interrupt:5

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:34660 errors:0 dropped:0 overruns:0 frame:0
TX packets:34660 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9917351 (9.4 MiB) TX bytes:9917351 (9.4 MiB)



2. หากต้องการเปลี่ยนรหัสผ่านของ root ทำด้วยคำสั่ง
passwd

ผลลัพธ์

[root@dhcp160 ~]# passwd
Changing password for user root.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.


3. ยกเลิกการตั้งค่า update อัตโนมัติ ด้วยคำสั่งดังนี้คือ

service yum-updatesd stop
chkconfig yum-updatesd off

ผลลัพธ์

[root@dhcp160 ~]# service yum-updatesd stop
Stopping yum-updatesd: [ OK ]
[root@dhcp160 ~]# chkconfig yum-updatesd off
[root@dhcp160 ~]#


4. ตั้งเวลาให้ตรงกับสากลด้วยคำสั่ง /usr/sbin/ntpdate -u <ชื่อเซิร์ฟเวอร์>
โดยที่
pool.ntp.org เป็น ntp server ที่เป็นสากลโดยตรง
time.psu.ac.th เป็น ntp server ภายใน ม.อ.
ใช้คำสั่ง
/usr/sbin/ntpdate -u pool.ntp.org

ผลลัพธ์

[root@dhcp160 ~]# /usr/sbin/ntpdate -u pool.ntp.org
27 Nov 17:20:45 ntpdate[22639]: step time server 61.19.242.42 offset -130.874347 sec


ต้องการให้ทุกครั้งที่บูทเครื่องมีการตั้งเวลาใหม่ ให้แก้ไขแฟ้ม /etc/rc.local ใช้คำสั่ง
gedit /etc/rc.local

เพิ่มบรรทัดข้อความว่า
/usr/sbin/ntpdate -u pool.ntp.org

บันทึกและปิดหน้าต่าง gedit

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/sbin/ntpdate -u pool.ntp.org


ตั้งเวลาให้ตรงกับสากลทุกวัน ให้สร้างแฟ้มข้อมูลชื่อ /etc/cron.daily/ntp.cron ใช้คำสั่ง
gedit /etc/cron.daily/ntp.cron

มีข้อมูลดังนี้
#!/bin/sh
/usr/sbin/ntpdate -u pool.ntp.org

และเปลี่ยนโหมดของแฟ้มเป็น execute ด้วยคำสั่ง
chmod +x /etc/cron.daily/ntp.cron

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/cron.daily/ntp.cron

#!/bin/sh
/usr/sbin/ntpdate -u pool.ntp.org

[root@dhcp160 ~]# chmod +x /etc/cron.daily/ntp.cron
[root@dhcp160 ~]#


5. เกี่ยวกับ SeLinux อาจทำให้การใช้งานบางอย่างยากขึ้น ให้เปลี่ยนจาก enforcing เป็น disabled โดยแก้ไขแฟ้ม /etc/selinux/config ใช้คำสั่ง
gedit /etc/selinux/config

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced. (default)
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted


1.1.2 การ update packages linux fedora core 6 ให้ทันสมัย


(ดัดแปลงจาก การ update packages ด้วยโปรแกรม Yum สำหรับมหาวิทยาลัยสงขลานครินทร์ (01-03-2550)
วิภัทร ศรุตพรหม http://rd.cc.psu.ac.th/content/view/52/46/)

กรณีที่เครื่องอยู่ในมหาวิทยาลัยสงขลานครินทร์

แก้ไขให้ชี้ update server มาอยู่ที่ repository server ที่ตั้งอยู่ภายในมหาวิทยาลัย ด้วยวิธีการคือ
ลบข้อมูลเดิมใน cache ทิ้งก่อนด้วยคำสั่ง
rm -rf /var/cache/yum/*

สำรองต้นฉบับ yum.repos.d เก็บไว้ก่อน เผื่อใช้ในอนาคต
cp -r /etc/yum.repos.d/ /etc/yum.repos.d.save

ลบแฟ้มใน directory /etc/yum.repos.d ทิ้งทั้งหมด
เพราะต้นฉบับ yum ที่ติดตั้งมีข้อมูลระบุให้ชี้ไปที่ server ต่างประเทศ ด้วยคำสั่ง
rm -f /etc/yum.repos.d/*

แล้วสร้างแฟ้ม 3 แฟ้มขึ้นมาใหม่ โดยระบุ repository server เป็น ftp.psu.ac.th
สร้างแฟ้ม /etc/yum.repos.d/psu-fedora.repo ให้มีข้อมูลดังนี้
[base]
name=Fedora Core $releasever - $basearch - Base
baseurl=ftp://ftp.psu.ac.th/pub/yum/fedora/core/6/base
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora

สร้างแฟ้ม /etc/yum.repos.d/psu-fedora-extras.repo ให้มีข้อมูลดังนี้
[extras]
name=Fedora Extras $releasever - $basearch
baseurl=ftp://ftp.psu.ac.th/pub/yum/fedora/core/6/extras
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
gpgcheck=1

สร้างแฟ้ม /etc/yum.repos.d/psu-fedora-updates.repo ให้มีข้อมูลดังนี้
[updates]
name=Fedora Updates $releasever - $basearch
baseurl=ftp://ftp.psu.ac.th/pub/yum/fedora/updates/6/i386
enabled=1
gpgcheck=0

ผลลัพธ์

[root@dhcp160 ~]# rm -rf /var/cache/yum/*
[root@dhcp160 ~]# cp -r /etc/yum.repos.d/ /etc/yum.repos.d.save
[root@dhcp160 ~]# rm -f /etc/yum.repos.d/*

[root@dhcp160 ~]# gedit /etc/yum.repos.d/psu-fedora.repo

[base]
name=Fedora Core $releasever - $basearch - Base
baseurl=ftp://ftp.psu.ac.th/pub/yum/fedora/core/6/base
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora

[root@dhcp160 ~]# gedit /etc/yum.repos.d/psu-fedora-extras.repo

[extras]
name=Fedora Extras $releasever - $basearch
baseurl=ftp://ftp.psu.ac.th/pub/yum/fedora/core/6/extras
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
gpgcheck=1

[root@dhcp160 ~]# gedit /etc/yum.repos.d/psu-fedora-updates.repo

[updates]
name=Fedora Updates $releasever - $basearch
baseurl=ftp://ftp.psu.ac.th/pub/yum/fedora/updates/6/i386
enabled=1
gpgcheck=0


กรณีที่เครื่องตั้งอยู่นอกมหาวิทยาลัยสงขลานครินทร์

ให้เริ่มทำเฉพาะ 2 คำสั่งข้างล่างนี้เลย

สั่งปรับปรุงรายชื่อ package ให้ทันสมัยตามแหล่งข้อมูลต้นทาง
yum check-update

สั่งปรับปรุง/ติดตั้ง package ให้ทันสมัย
yum update

ผลลัพธ์

[root@dhcp160 ~]# yum check-update
Loading "installonlyn" plugin
Setting up repositories
extras 100% |=========================| 1.1 kB 00:00
updates 100% |=========================| 1.2 kB 00:00
base 100% |=========================| 951 B 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 1.7 MB 00:00
...

[root@dhcp160 ~]# yum update
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
Reading repository metadata in from local files

Transaction Summary
==============================================
Install 11 Package(s)
Update 329 Package(s)
Remove 0 Package(s)

Total download size: 524 M
Is this ok [y/N]:y
... more lines...
[root@dhcp160 ~]#

1.2 การติดตั้งโปรแกรม Apache web server


ชื่อแฟ้มที่เกี่ยวข้องเมื่อติดตั้งเสร็จแล้ว
/var/log/httpd/access.log
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/

1. ติดตั้งโปรแกรม httpd พร้อมคู่มือ ด้วยคำสั่ง
yum install httpd
yum install httpd-manual
yum install mod_ssl

ผลลัพธ์

[root@dhcp160 ~]# yum install httpd
=============================================
Package Arch Version Repository Size
=============================================
Updating:
httpd i386 2.2.6-1.fc6 updates 1.0 M

Transaction Summary
=============================================
...
Complete!
[root@dhcp160 ~]# yum install httpd-manual
=============================================

Package Arch Version Repository Size
=============================================
Installing:
httpd-manual i386 2.2.6-1.fc6 updates 812 k

Transaction Summary
==============================================
...
Complete!
[root@dhcp160 ~]# yum install mod_ssl
==============================================
Package Arch Version Repository Size
==============================================
Installing:
mod_ssl i386 1:2.2.6-1.fc6 updates 84 k
Installing for dependencies:
distcache i386 1.4.5-14.1 base 120 k

Transaction Summary
==============================================

...
Complete!
[root@dhcp160 ~]#


2. แก้ไขให้ทำงานทุกครั้งที่บูทเครื่อง
chkconfig httpd on

ผลลัพธ์

[root@dhcp160 ~]# chkconfig httpd on
[root@dhcp160 ~]#


3. สั่งให้ทำงานด้วยคำสั่งว่า
service httpd start

ผลลัพธ์

[root@dhcp160 ~]# service httpd start
Starting httpd: [ OK ]
[root@dhcp160 ~]#

1.3 การติดตั้งโปรแกรม Freeradius


ชื่อแฟ้มที่เกี่ยวข้องเมื่อติดตั้งเสร็จแล้ว
/var/log/radius/radius.log
/etc/raddb/radiusd.conf
/etc/raddb/clients.conf

1. ติดตั้งโปรแกรม freeradius ด้วยคำสั่ง
yum install freeradius

แก้ไขให้ทำงานทุกครั้งที่บูทเครื่อง
chkconfig radiusd on

สั่งให้ทำงานด้วยคำสั่งว่า
service radiusd start

ผลล้ัพธ์

[root@dhcp160 ~]# yum install freeradius
=============================================

Package Arch Version Repository Size
=============================================
Installing:
freeradius i386 1.1.7-3.1.fc6 updates 1.2 M
Installing for dependencies:
lm_sensors i386 2.10.1-1.fc6 updates 506 k
net-snmp i386 1:5.3.1-15.fc6 updates 695 k
net-snmp-utils i386 1:5.3.1-15.fc6 updates 179 k
perl-DBI i386 1.52-1.fc6 base 605 k

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

Total download size: 3.1 M
Is this ok [y/N]: y
Downloading Packages:
...
Complete!
[root@dhcp160 ~]# chkconfig radiusd on
[root@dhcp160 ~]# service radiusd start
radiusd is stopped
Starting RADIUS server: [ OK ]
[root@dhcp160 ~]#

1.4 ทดสอบ authentication โดยใช้ username/password ของ Unix


1. (หากยังไม่มี) ให้เตรียม username ที่จะใช้ทดสอบชื่อ chilli มีรหัสผ่านเป็น abcd1234 ด้วยคำสั่งดังนี้
adduser chilli
passwd chilli

ผลลัพธ์

[root@dhcp160 ~]# adduser chilli
[root@dhcp160 ~]# passwd chilli
Changing password for user chilli.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dhcp160 ~]#


2. เมื่อให้ radiusd ทำงานแล้ว เริ่มขั้นตอนทดสอบระบบโดยป้อนตัวอย่างคำสั่งดังนี้
radtest chilli abcd1234 localhost 0 testing123

จะมีการแจ้งว่า Access-Reject
เป็นสาเหตุเนื่องจากไม่มีสิทธิในการอ่านแฟ้ม /etc/shadow ของระบบ

ผลลัพธ์

[root@dhcp160 ~]# radtest chilli abcd1234 localhost 0 testing123
Sending Access-Request of id 232 to 127.0.0.1 port 1812
User-Name = "chilli"
User-Password = "abcd1234"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
Re-sending Access-Request of id 232 to 127.0.0.1 port 1812
User-Name = "chilli"
User-Password = "abcd1234"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
rad_recv: Access-Reject packet from host 127.0.0.1:1812, id=232, length=20
[root@dhcp160 ~]#


หมายเหตุ คำว่า localhost คือ ชื่อโดเมนของไอพีแอดเดรส 127.0.0.1 ก็คือ ตัวเครื่องเซิร์ฟเวอร์เอง
ซึ่งต้องมีระบุไว้ในแฟ้ม /etc/hosts ใช้คำสั่งดูข้อมูลข้างในแฟ้มดังนี้
cat /etc/hosts

[root@dhcp160 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
[root@dhcp160 ~]#


3. แก้ไขให้อ่านแฟ้ม /etc/shadow ได้ โดยแก้ไขแฟ้ม /etc/raddb/radiusd.conf
3.1 ให้ทำการสำรองแฟ้มต้นฉบับเก็บไว้ก่อน ด้วยคำสั่ง
cp /etc/raddb/radiusd.conf /etc/raddb/radiusd.conf.save

ผลลัพธ์

[root@dhcp160 ~]# cp /etc/raddb/radiusd.conf /etc/raddb/radiusd.conf.save
[root@dhcp160 ~]#


3.2 แก้ไขแฟ้ม /etc/raddb/radiusd.conf เพื่อทำการ comment ยกเลิกบรรทัดข้อความจากเดิม
user = radiusd
group = radiusd
ให้เป็น
#user = radiusd
#group = radiusd

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/raddb/radiusd.conf

Line 114
#user = radiusd
#group = radiusd


3.3 เสร็จแล้วให้ restart ระบบ radiusd ใหม่ด้วยคำสั่ง
service radiusd restart

ผลลัพธ์

[root@dhcp160 ~]# service radiusd restart
radiusd (pid 23004) is running...
radiusd (pid 23004) is running...
Stopping RADIUS server: [ OK ]
radiusd is stopped
Starting RADIUS server: [ OK ]
[root@dhcp160 ~]#


3.4 ต่อไปลองป้อนตัวอย่างคำสั่งเดิมเพื่อทดสอบดังนี้
radtest chilli abcd1234 localhost 0 testing123

จะมีการแจ้งว่า Access-Accept ถูกต้องตามต้องการ
ผลลัพธ์

[root@dhcp160 ~]# radtest chilli abcd1234 localhost 0 testing123
Sending Access-Request of id 39 to 127.0.0.1 port 1812
User-Name = "chilli"
User-Password = "abcd1234"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1:1812, id=39, length=20
[root@dhcp160 ~]#


3.5 ในการนำไปใช้งานจริง ขอให้แก้ไข secret ใหม่ ตัวอย่างเช่น ตั้งใหม่เป็น mytestkey
ให้แก้ไขแฟ้ม /etc/raddb/clients.conf ของโปรแกรม freeradius ให้มีค่าดังตัวอย่างนี้
client 127.0.0.1 {
...
บรรทัดที่ 35 เดิม secret = testing123
แก้ไขเป็น secret = mytestkey
...
}
เสร็จแล้วให้ restart ระบบ radiusd ใหม่ด้วยคำสั่ง
service radiusd restart
ทดสอบ radius อีกครั้งด้วย secret อันใหม่ ดังนี้
radtest chilli abcd1234 localhost 0 mytestkey

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/raddb/clients.conf

Line 35
secret = mytestkey

[root@dhcp160 ~]# service radiusd restart
radiusd (pid 23068) is running...
radiusd (pid 23068) is running...
Stopping RADIUS server: [ OK ]
radiusd is stopped
Starting RADIUS server: [ OK ]

[root@dhcp160 ~]# radtest chilli abcd1234 localhost 0 mytestkey
Sending Access-Request of id 166 to 127.0.0.1 port 1812
User-Name = "chilli"
User-Password = "abcd1234"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1:1812, id=166, length=20
[root@dhcp160 ~]#

1.5 การติดตั้งโปรแกรม Chillispot แบบ Web login


ชื่อแฟ้มที่เกี่ยวข้องเมื่อติดตั้งเสร็จแล้ว

/etc/chilli.conf

/var/www/cgi-bin/hotspotlogin.cgi

/var/www/html/welcome.html

/etc/firewall.iptables

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

โปรดตรวจสอบ

เนื่องจาก chillispot จะเป็น dhcp server เอง
กรณีที่นำเครื่องเดิมมาติดตั้ง chillispot เพิ่ม จะต้องเช็คว่าในเครื่อง
ไม่มี
dhcp server รันอยู่ ถ้ามีอยู่ก็หยุดดังนี้
service dhcpd stop
chkconfig dhcpd off

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

1. เราต้องทำให้เครื่องนี้ทำหน้าที่เป็นเราเตอร์เพื่อ forward packet
ทุกครั้งที่รีบูตเครื่อง

ให้แก้ไขแฟ้ม /etc/sysctl.conf ให้มีค่าดังตัวอย่างนี้
บรรทัดที่ 7 เดิม net.ipv4.ip_forward = 0
แก้ไขเป็น net.ipv4.ip_forward = 1

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/sysctl.conf

# Controls IP packet forwarding
net.ipv4.ip_forward = 1


2. เพื่อให้มีผลทันทีในขณะนี้ ให้เครื่อง forward packet
รันคำสั่ง echo "1" > /proc/sys/net/ipv4/ip_forward

ผลลัพธ์

[root@dhcp160 ~]# echo "1" > /proc/sys/net/ipv4/ip_forward
[root@dhcp160 ~]#


3. เพื่อให้การ์ดแลน eth1 ไม่รับ dhcp ตอนรีบูตเครื่อง
ให้แก้ไขแฟ้ม /etc/sysconfig/network-scripts/ifcfg-eth1 ให้มีค่าดังตัวอย่างนี้
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/sysconfig/network-scripts/ifcfg-eth1

# 3Com Corporation 3c905C-TX/TX-M [Tornado]
DEVICE=eth1
BOOTPROTO=none
HWADDR=00:01:03:18:BA:59
ONBOOT=yes


4. ดาวน์โหลดโปรแกรม chillispot จากเครื่องเอฟทีพีของม.อ. ด้วยคำสั่ง wget ดังนี้
wget ftp://ftp.psu.ac.th/pub/chillispot/chillispot-1.1.0.i386.rpm

ผลลัพธ์

[root@dhcp160 ~]# wget ftp://ftp.psu.ac.th/pub/chillispot/chillispot-1.1.0.i386.rpm
--20:25:02-- ftp://ftp.psu.ac.th/pub/chillispot/chillispot-1.1.0.i386.rpm
=> `chillispot-1.1.0.i386.rpm'
Resolving ftp.psu.ac.th... 192.168.100.101
Connecting to ftp.psu.ac.th|192.168.100.101|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/chillispot ... done.
==> SIZE chillispot-1.1.0.i386.rpm ... 88761
==> PASV ... done. ==> RETR chillispot-1.1.0.i386.rpm ... done.
Length: 88761 (87K)

100%[=======================================>] 88,761 --.-K/s in 0.04s

20:25:03 (2.00 MB/s) - `chillispot-1.1.0.i386.rpm' saved [88761]
[root@dhcp160 ~]#


หรือดาวน์โหลดจากเว็บต้นฉบับที่ http://www.chillispot.info/download.html

http://www.chillispot.info/download.html
Suitable for Redhat 9, Fedora (FC1, FC2 and FC3 and FC4).
http://www.chillispot.info/download/chillispot-1.1.0.i386.rpm
Or other linux distro.
http://www.chillispot.info/download/chillispot-1.1.0.tar.gz


5. แล้วติดตั้ง package rpm ด้วยคำสั่งดังนี้
rpm -Uvh chillispot-1.1.0.i386.rpm

ผลลัพธ์

[root@dhcp160 ~]# rpm -Uvh chillispot-1.1.0.i386.rpm
Preparing... ########################################### [100%]
1:chillispot ########################################### [100%]
[root@dhcp160 ~]#


6. แก้ไขแฟ้ม /etc/chilli.conf ให้มีค่าดังตัวอย่างนี้
[หัวข้อ TUN parameters]
บรรทัดที่ 38 เดิม net 192.168.182.0/24
แก้ไขเป็น net 10.0.1.0/24

[หัวข้อ Radius parameters]
บรรทัดที่ 113 เดิม radiusserver1 rad01.chillispot.org
แก้ไขเป็น radiusserver1 127.0.0.1

บรรทัดที่ 120 เดิม radiusserver2 rad02.chillispot.org
แก้ไขเป็น radiusserver2 127.0.0.1

บรรทัดที่ 139 เดิม #radiussecret testing123
แก้ไขเป็น radiussecret mytestkey
(ตรงกับ radius secret ในแฟ้ม /etc/raddb/clients.conf ของ freeradius)

[หัวข้อ Universal access method (UAM) parameters]
บรรทัดที่ 237 เดิม #uamserver https://radius.chillispot.org/hotspotlogin
แก้ไขเป็น uamserver https://10.0.1.1/cgi-bin/hotspotlogin.cgi

บรรทัดที่ 244 เดิม #uamhomepage http://192.168.182.1/welcome.html
แก้ไขเป็น uamhomepage http://10.0.1.1/welcome.html

บรรทัดที่ 248 เดิม #uamsecret ht2eb8ej6s4et3rg1ulp
แก้ไขโดยให้เอาเครื่องหมาย# ออก เป็น uamsecret ht2eb8ej6s4et3rg1ulp
(หรือแก้ไขเป็นรหัสใหม่ แต่ต้องเหมือนกับในแฟ้ม hotspotlogin.cgi ในข้อถัดไป)

บรรทัดที่ 253 เดิม #uamlisten 192.168.182.1
แก้ไขเป็น uamlisten 10.0.1.1

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/chilli.conf

Line 38
net 10.0.1.0/24
radiusserver1 127.0.0.1
radiusserver2 127.0.0.1
radiussecret mytestkey
uamserver https://10.0.1.1/cgi-bin/hotspotlogin.cgi
uamhomepage http://10.0.1.1/welcome.html
uamsecret ht2eb8ej6s4et3rg1ulp
uamlisten 10.0.1.1


7. ให้คัดลอกแฟ้ม firewall.iptables ด้วยคำสั่ง
cp /usr/share/doc/chillispot-1.1.0/firewall.iptables /etc

ให้คัดลอกแฟ้ม hotspotlogin.cgi ด้วยคำสั่ง
cp /usr/share/doc/chillispot-1.1.0/hotspotlogin.cgi /var/www/cgi-bin/

ผลลัพธ์

[root@dhcp160 ~]# cp /usr/share/doc/chillispot-1.1.0/firewall.iptables /etc
[root@dhcp160 ~]# cp /usr/share/doc/chillispot-1.1.0/hotspotlogin.cgi /var/www/cgi-bin/
[root@dhcp160 ~]#


8. แก้ไขแฟ้ม /var/www/cgi-bin/hotspotlogin.cgi ให้มีค่าดังตัวอย่างนี้
บรรทัดที่ 27 เดิม #$uamsecret = "ht2eb8ej6s4et3rg1ulp";
แก้ไขโดยให้เอาเครื่องหมาย# ออก เป็น $uamsecret = "ht2eb8ej6s4et3rg1ulp";

บรรทัดที่ 31 เดิม #$userpassword=1;
แก้ไขโดยให้เอาเครื่องหมาย# ออก เป็น $userpassword=1;

ผลลัพธ์

[root@dhcp160 ~]# gedit /var/www/cgi-bin/hotspotlogin.cgi

Line 27
$uamsecret = "ht2eb8ej6s4et3rg1ulp";

# Uncomment the following line if you want to use ordinary user-password
# for radius authentication. Must be used together with $uamsecret.
$userpassword=1;


9. สร้างแฟ้ม /var/www/html/welcome.html ให้มีค่าดังตัวอย่างนี้


ผลลัพธ์

[root@dhcp160 ~]# gedit /var/www/html/welcome.html



Welcome to Our Hotspot, Wireless Network.



TESTING ONLY



Welcome to Our Hotspot, Wireless Network.


You are connected to an authentication and restricted network access point.

Click here to login



Enjoy.





10. ถ้าต้องการรูป chillispot.png ให้ดาวน์โหลดได้ที่นี่
wget http://mamboeasy.psu.ac.th/~wiboon.w/images/stories/chillispot/chillispot.png

แล้วคัดลอกแฟ้มนี้ไปไว้ใน /var/www/html ด้วยคำสั่งดังนี้
cp chillispot.png /var/www/html

ผลลัพธ์

[root@dhcp160 ~]# wget http://mamboeasy.psu.ac.th/~wiboon.w/images/stories/
chillispot/chillispot.png

[root@dhcp160 ~]# cp chillispot.png /var/www/html
[root@dhcp160 ~]#


11. ก่อนที่จะสตาร์ท chillispot ให้ไปทำการคอนฟิกแอคเซสพอยน์/ไวร์เลสเราเตอร์ ให้พร้อมใช้งาน โดยทำตามเอกสารของแต่ละรุ่น
ความต้องการคือ ให้ทำ factory defaults แล้วกำหนดให้มันจะต้องรับ dhcp ip จาก chillispot และตัวมันเองจะต้องไม่ทำหน้าที่แจก ip
รวมทั้งควรแก้ไข ESSID ตั้งชื่อใหม่ด้วย เพื่อให้รู้ว่าตัวไหนของเรา ดูตัวอย่างบางรุ่นในเว็บนี้ได้

หมายเหตุ Linksys WRT54GL ที่ผมนำมา upgrade firmware เป็น DD-WRT แล้ว
ผมพบว่า ต้อง Enable DHCP server ให้กับ port LAN 1-4 ของเราเตอร์ด้วย
มันยังคงแจกไอพีให้กับ เครื่องที่ต่อ port LAN 1-4 แต่มันไม่แจกไอพีให้ไวร์เลส

12. เปิดใช้งาน iptables เพื่อทำเป็น firewall ด้วยคำสั่ง
sh /etc/firewall.iptables

ผลลัพธ์

[root@dhcp160 ~]# sh /etc/firewall.iptables
[root@dhcp160 ~]#


13. สั่งให้ chillispot ทำงานด้วยคำสั่ง
service chilli start

ผลลัพธ์

[root@dhcp160 ~]# service chilli start
Starting chilli: [ OK ]


14. ตรวจสอบการทำงานของ chiilispot ว่าสร้างอินเทอร์เฟส tun0 พร้อมใช้งานและมีเลข IP เป็น 10.0.1.1
โดยที่อินเทอร์เฟส eth1 จะไม่มี IP ใด ๆ ส่วน eth0 ก็เป็นเลข IP ที่รับจากเน็ตที่เซิร์ฟเวอร์นี้ต่ออยู่เหมือนเดิม
ด้วยคำสั่ง ifconfig ดังตัวอย่าง

ผลลัพธ์

[root@dhcp160 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:60:97:A5:38:6F
inet addr:192.168.2.220 Bcast:192.168.2.255 Mask:255.255.255.0
...

eth1 Link encap:Ethernet HWaddr 00:01:03:18:BA:59
inet6 addr: fe80::201:3ff:fe18:ba59/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
...

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
...

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.0.1.1 P-t-P:10.0.1.1 Mask:255.255.255.0
UP POINTOPOINT RUNNING MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:116 (116.0 b) TX bytes:240 (240.0 b)
[root@dhcp160 ~]#


15. ให้จดเลข Mac address ของโน้ตบุ๊คที่จะนำมาทดสอบการเชื่อมต่อกับ chillispot
และรันคำสั่งตรวจสอบว่าโน้ตบุ๊คได้ IP Address จาก chillispot ดังนี้
tail -f /var/log/messages
จะได้ผลลัพธ์แสดงคล้าย ๆ ตังอย่างข้างล่างนี้

ผลลัพธ์

[root@dhcp160 ~]# tail -f /var/log/messages
Nov 27 20:05:18 dhcp160 Installed: httpd-manual.i386 2.2.6-1.fc6
Nov 27 20:06:54 dhcp160 Installed: distcache.i386 1.4.5-14.1
Nov 27 20:06:57 dhcp160 Installed: mod_ssl.i386 1:2.2.6-1.fc6
Nov 27 20:57:57 dhcp160 chillispot[23328]: ChilliSpot 1.1.0.
Copyright 2002-2005 Mondru AB. Licensed under GPL.
See http://www.chillispot.org for credits.
Nov 27 20:57:57 dhcp160 kernel: tun: Universal TUN/TAP device driver, 1.6
Nov 27 20:57:57 dhcp160 kernel: tun: (C) 1999-2004 Max Krasnyansky <

maxk@qualcomm.com

This email address is being protected from spam bots, you need Javascript enabled to view it

>
Nov 27 20:57:57 dhcp160 kernel: ADDRCONF(NETDEV_CHANGE): tun0: link becomes ready
Nov 27 20:57:57 dhcp160 kernel: eth1: setting full-duplex.
Nov 27 20:58:00 dhcp160 chillispot[23328]: chilli.c: 3509:
New DHCP request from MAC=00-1D-7E-27-C3-18
Nov 27 20:58:00 dhcp160 chillispot[23328]: chilli.c: 3479:
Client MAC=00-1D-7E-27-C3-18 assigned IP 10.0.1.2
Nov 27 21:16:55 dhcp160 chillispot[23328]: chilli.c: 3509:
New DHCP request from MAC=00-13-02-69-41-FA
Nov 27 21:16:55 dhcp160 chillispot[23328]: chilli.c: 3479:
Client MAC=00-13-02-69-41-FA assigned IP 10.0.1.3
Nov 27 21:20:32 dhcp160 chillispot[23328]: chilli.c: 3759:
Successful UAM login from username=chilli IP=10.0.1.3
Ctrl-C break


โดยที่ 10.0.1.2 จะเป็น IP ของแอคเซสพอยน์ และ 10.0.1.3 จะเป็น IP ของโน้ตบุ๊คตัวแรกที่เชื่อมต่อ

16. เริ่มขั้นตอนทดสอบระบบที่เครื่องโน้ตบุคดังนี้
เริ่มทำการคอนเนค W-IFI
คลิกที่นี่เพื่อดูรูป

ที่บราวเซอร์ให้ยกเลิกการเซ็ตพร็อกซี่เซิร์ฟเวอร์

ที่บราวเซอร์ที่มีการเซ็ตหน้าโฮมเพจไว้ จะถูก redirect ไปยัง welcome.html ทันทีเมื่อเรียกโปรแกรม คลิกที่นี่เพื่อดูรูป

คลิกที่ข้อความ Click here to login แล้วจะมีหน้าต่างเพื่อให้ใส่ username และ password
คลิกที่นี่เพื่อดูรูป

เมื่อ login เข้าได้สำเร็จจะมีหน้าต่าง logged in พร้อมเวลาเริ่มนับ และเอาไว้ใช้สำหรับ logout
คลิกที่นี่เพื่อดูรูป

17. แก้ไขแฟ้ม /etc/rc.local เพื่อให้ firewall.iptables และ chilli มีผลทำงานด้วยเมื่อรีบูตเครื่องใหม่
เพิ่มบรรทัด 2 บรรทัดนี้ต่อท้าย
sh /etc/firewall.iptables
service chilli start

ผลลัพธ์

[root@dhcp160 ~]# gedit /etc/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/sbin/ntpdate -u pool.ntp.org
sh /etc/firewall.iptables
service chilli start


18. รีบูตเครื่องเซิร์ฟเวอร์ 1 ครั้ง

19. ถึงขั้นตอนนี้เป็นอันเปิดใช้ระบบ chillispot แบบ web login ได้แล้ว



ไม่มีความคิดเห็น: