วันพุธที่ 23 พฤษภาคม พ.ศ. 2550

ติดตั้ง Chillispot server สำหรับ WIFI แบบ web login

ติดตั้ง Chillispot server สำหรับ WIFI แบบ web login
เนื่องจาก chillispot จะเป็น dhcp server เอง ดังนี้นจะต้องเช็คว่าในเครื่องไม่มี dhcp server รันอยู่ ถ้ามีอยู่ก็หยุดดังนี้service dhcpd stop
แก้ไขแฟ้ม /etc/sysctl.conf ให้มีค่าดังตัวอย่างนี้บรรทัดที่ 7 เดิม net.ipv4.ip_forward = 0แก้ไขเป็น net.ipv4.ip_forward = 1
รันคำสั่ง echo "1" > /proc/sys/net/ipv4/ip_forwardเพื่อให้มีผลทันที ให้ forward packet ทำตัวเป็นเราเตอร์ได้
แก้ไขแฟ้ม /etc/sysconfig/network-scripts/ifcfg-eth1 ให้มีค่าดังตัวอย่างนี้DEVICE=eth1BOOTPROTO=noneONBOOT=yesTYPE=EthernetDHCP_HOSTNAME=kthakon.radius.com
แก้ไขแฟ้ม /etc/raddb/clients.conf ของโปรแกรม freeradius ให้มีค่าดังตัวอย่างนี้client 10.114.0.0/24 {...บรรทัดที่ 35 เดิม secret = testing123แก้ไขเป็น secret = testing...}
รีสตาร์ท radiusd ใหม่ ด้วยคำสั่งservice radiusd restar
ดาวน์โหลดโปรแกรม chillispot และติดตั้งผ่าน browser ด้วยการคลิกที่ลิงค์นี้ftp://ftp.psu.ac.th/pub/chillispot/chillispot-1.1.0.i386.rpmหรือดาวน์โหลดด้วยคำสั่ง wget ดังนี้wget ftp://ftp.psu.ac.th/pub/chillispot/chillispot-1.1.0.i386.rpmแล้วติดตั้ง package rpm ด้วยคำสั่งดังนี้rpm -Uvh chillispot-1.1.0.i386.rpm
แฟ้มที่เกี่ยวข้อง
/etc/chilli.conf
/var/www/cgi-bin/hotspotlogin.cgi
/var/www/html/welcome.html
/etc/firewall.iptables
แก้ไขแฟ้ม /etc/chilli.conf ให้มีค่าดังตัวอย่างนี้[หัวข้อ TUN parameters]บรรทัดที่ 38 เดิม net 192.168.182.0/24แก้ไขเป็น net 10.114.0.0/24[หัวข้อ Radius parameters]บรรทัดที่ 113 เดิม radiusserver1 rad01.chillispot.orgแก้ไขเป็น radiusserver1 10.114.0.2บรรทัดที่ 120 เดิม radiusserver2 rad02.chillispot.orgแก้ไขเป็น radiusserver2 10.114.0.2บรรทัดที่ 139 เดิม #radiussecret testing123แก้ไขเป็น radiussecret testing(ตรงกับ radius secret ในแฟ้ม /etc/raddb/clients.conf ของ freeradius)[หัวข้อ Universal access method (UAM) parameters]บรรทัดที่ 237 เดิม #uamserver https://radius.chillispot.org/hotspotloginแก้ไขเป็น uamserver https://10.114.0.1/cgi-bin/hotspotlogin.cgiบรรทัดที่ 244 เดิม #uamhomepage http://192.168.182.1/welcome.htmlแก้ไขเป็น uamhomepage http://10.114.0.1/welcome.htmlบรรทัดที่ 248 เดิม #uamsecret ht2eb8ej6s4et3rg1ulpแก้ไขโดยให้เอาเครื่องหมาย# ออก เป็น uamsecret secretshilli(หรือแก้ไขเป็นรหัสใหม่ แต่ต้องเหมือนกับในแฟ้ม hotspotlogin.cgi ในข้อถัดไป)บรรทัดที่ 253 เดิม #uamlisten 192.168.182.1แก้ไขเป็น uamlisten 10.114.0.1
ให้คัดลอกแฟ้ม 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/
แก้ไขแฟ้ม /var/www/cgi-bin/hotspotlogin.cgi ให้มีค่าดังตัวอย่างนี้บรรทัดที่ 27 เดิม #$uamsecret = "ht2eb8ej6s4et3rg1ulp";แก้ไขโดยให้เอาเครื่องหมาย# ออก เป็น $uamsecret = "secretchilli";บรรทัดที่ 31 เดิม #$userpassword=1;แก้ไขโดยให้เอาเครื่องหมาย# ออก เป็น $userpassword=1;
สร้างแฟ้ม /var/www/html/welcome.html ให้มีค่าดังตัวอย่างนีsave เป็น code html นะครับอย่าลืม !
TESTING ONLY
Welcome to Our Hotspot, Wireless Network.
You are connected to an authentication and restricted network access point.
Click here to login
Enjoy.ถ้าต้องการรูป chillispot.png ให้ดาวน์โหลดได้จาก ที่นี่ แล้วคัดลอกแฟ้มนี้ไปไว้ใน /var/www/html ด้วยคำสั่งดังนี้wget http://mamboeasy.psu.ac.th/~wiboon.w/images/stories/chillispot/chillispot.pngcp chillispot.png /var/www/html
ก่อนที่จะสตาร์ท chillispot ให้ไปทำการคอนฟิกแอคเซสพอยน์/ไวร์เลสเราเตอร์ ให้พร้อมใช้งาน โดยทำตามเอกสารของแต่ละรุ่น ความต้องการคือ ให้ทำ factory defaults แล้วกำหนดให้มันจะต้องรับ dhcp ip จาก chillispot และตัวมันเองจะต้องไม่ทำหน้าที่แจก ip รวมทั้งแก้ไข ESSID ตั้งชื่อใหม่ด้วย ตามเอกสารของพี่ wiboon
สั่งให้ firewall.iptables ทำงานด้วยคำสั่งว่าsh /etc/firewall.iptables
สั่งให้ chillispot ทำงานด้วยคำสั่งว่าservice chilli startStarting chilli: [ OK ]
ดุ IP [root@kthakon src]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0D:61:E1:FB:28inet addr:10.114.0.2 Bcast:10.114.255.255 Mask:255.255.0.0inet6 addr: fe80::20d:61ff:fee1:fb28/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:12804 errors:0 dropped:0 overruns:0 frame:0TX packets:3548 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:4090246 (3.9 MiB) TX bytes:459774 (448.9 KiB)Interrupt:11 Base address:0xe000eth1 Link encap:Ethernet HWaddr 00:04:E2:D3:23:01inet6 addr: fe80::204:e2ff:fed3:2301/64 Scope:LinkUP BROADCAST MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:5 dropped:0 overruns:0 carrier:10collisions:0 txqueuelen:1000RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)Interrupt:10 Base address:0x4000lo Link encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:3223 errors:0 dropped:0 overruns:0 frame:0TX packets:3223 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:3202251 (3.0 MiB) TX bytes:3202251 (3.0 MiB)tun0 Link encap:UNSPEC HWaddr E9-FE-3B-13-18-00-F4-3F-00-00-00-00-00-00-00-00inet addr:10.114.0.1 P-t-P:10.114.0.1 Mask:255.255.255.0UP POINTOPOINT RUNNING MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:3 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:10RX bytes:0 (0.0 b) TX bytes:517 (517.0 b)[root@kthakon src]#
เ นื่องจาก chillispot ต้องใช้พอร์ท 1812 และ 1813 ในการหน้าที่เป็น proxy radius จึงต้องแก้ให้ radius server คอยรับ request ที่พอร์ทหมายเลข 1645 และ 1646 แทนให้แก้ไขแฟ้ม /etc/raddb/radiusd.confบรรทัดที่ 207 แก้ port = 0 เป็น port = 1645
เมื่อแก้ไขเสร็จแล้วให้รีสตาร์ทใหม่ด้วยคำสั่งservice radiusd restartลองทดสอบด้วยคำสั่งตัวอย่างradtest user1 wunca16 10.0.1.1:1645 0 mytestkeyจะมีการแจ้งว่า Access-Accept ถูกต้องตามต้องการ
แก้ไขแฟ้ม /etc/chilli.conf ให้มีค่าดังตัวอย่างนี้[หัวข้อ Radius parameters]บรรทัดที่ 127 เดิม #radiusauthport 1812แก้ไขเป็น radiusauthport 1645บรรทัดที่ 134 เดิม #radiusacctport 1813แก้ไขเป็น radiusacctport 1646บรรทัดที่ 139 ตรวจสอบว่าเป็น radiussecret mytestkey(ตรงกับ radius secret ในแฟ้ม /etc/raddb/clients.conf ของ freeradius)[หัวข้อ Radius proxy parameters]บรรทัดที่ 174 เดิม #proxylisten 10.0.0.1แก้ไขเป็น proxylisten 10.114.0.1บรรทัดที่ 180 เดิม #proxyport 1645แก้ไขเป็น proxyport 1812บรรทัดที่ 185 เดิม #proxyclient 10.114.0.0/24แก้ไขเป็น proxyclient 10.0.1.0/24บรรทัดที่ 191 เดิม #proxysecret testing123แก้ไขเป็น proxysecret testing
แก้ไขแฟ้ม /etc/firewall.iptablesไปที่บรรทัดที่ 33 จะมีบรรทัดเดิมคือ$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPTเพิ่มใต้บรรทัดที่ 33 ดังตัวอย่างนี้$IPTABLES -A INPUT -i tun0 -p udp -m udp --dport 1812 -j ACCEPTและสั่งรันไฟร์วอลล์ใหม่sh /etc/firewall.iptables
สั่งให้ chillispot อ่านแฟ้มคอนฟิกใหม่ด้วยคำสั่งว่าservice chilli reload
แก้ไข file /etc/firewall.iptables ดังนี้้
#!/bin/sh## Firewall script for ChilliSpot# A Wireless LAN Access Point Controller## Uses $EXTIF (eth0) as the external interface (Internet or intranet) and# $INTIF (eth1) as the internal interface (access points).### SUMMARY# * All connections originating from chilli are allowed.# * Only ssh is allowed in on external interface.# * Nothing is allowed in on internal interface.# * Forwarding is allowed to and from the external interface, but disallowed# to and from the internal interface.# * NAT is enabled on the external interface.IPTABLES="/sbin/iptables"EXTIF="ppp0"INTIF="eth1"#Flush all rules$IPTABLES -F$IPTABLES -F -t nat$IPTABLES -F -t mangle#Set default behaviour$IPTABLES -P INPUT DROP$IPTABLES -P FORWARD ACCEPT$IPTABLES -P OUTPUT ACCEPT#Allow related and established on all interfaces (input)$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT#Allow releated, established and ssh on $EXTIF. Reject everything else.$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT$IPTABLES -A INPUT -i $EXTIF -j REJECT#Allow related and established from $INTIF. Drop everything else.$IPTABLES -A INPUT -i $INTIF -j DROP#Allow http and https on other interfaces (input).#This is only needed if authentication server is on same server as chilli$IPTABLES -A INPUT -p tcp -m tcp --dport 80 --syn -j ACCEPT$IPTABLES -A INPUT -p tcp -m tcp --dport 443 --syn -j ACCEPT$IPTABLES -A INPUT -i tun0 -p udp -m udp --dport 1812 -j ACCEPT#Allow 3990 on other interfaces (input).$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT#Allow ICMP echo on other interfaces (input).$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT#Allow everything on loopback interface.$IPTABLES -A INPUT -i lo -j ACCEPT# Drop everything to and from $INTIF (forward)# This means that access points can only be managed from ChilliSpot$IPTABLES -A FORWARD -i $INTIF -j DROP$IPTABLES -A FORWARD -o $INTIF -j DROP#Enable NAT on output device$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE$IPTABLES -t nat -A PREROUTING -s 10.114.0.0/24 -p udp --dport 53 -j DNAT --to 10.114.0.1********* THE END *************************

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