การติดตงั้ chillispot บน Ubuntu 9.10 กาหนดค่า ADSL Router - IP Wan Router = Dynamic IP รับค่าจาก ISP - IP Lan Router = 192.168.1.1 Ubuntu 9.10 Desktop Server - IP Eth0 = 192.168.1.2 - IP Eth1 = DHCP Wifi AP - ให ้เสียบลายแลนทีม ่ าจาก Ubuntu ที่ port Lan - ปิ ด DHCP Server - กาหนดค่าเป็ น AP ไม่ต ้องใส่ Key ————————————————————————————————————————————— หลังจากทีต ่ ด ิ ตัง้ ตัว Ubuntu 9.10 เรียบร ้อยแล ้วแล ้วก็มาเริม ่ ขัน ้ ตอนการติดตัง้ กันเลย 1. ติดตัง้ OpenSSH server apt-get install ssh openssh-server 2. ติดตัง้ Chillispot apt-get install chillispot แล ้วก็เติมรายละเอียดดังนี้ (เติมตามไดอะแกรมบ ้างบน) IP address of radius server 1: 127.0.0.1 Radius shared secret: radiussecret Ethernet interface for DHCP to listen: eth1 URL of UAM Server: https://192.168.182.1/cgi-bin/hotspotlogin.cgi URL of UAM homepage: https://192.168.182.1/welcome.html Shared password between chillispot and webserver uamsecret 3. Enable captive portal ในไฟล chillispot vi /etc/default/chillispot กาหนดค่า ENABLE=1 4. แก ้ไขค่า config ของ chillispot vi /etc/chillispot.conf โดยแก ้ไขค่าเป็ นดังนี้ net 192.168.182.0/24 dns1 192.168.1.1 dns2 192.168.1.1 radiusserver1 127.0.0.1 radiusserver2 127.0.0.1 radiussecert radiussecret dhcpif eth1 uamserver https://192.168.182.1/cgi-bin/hotspotlogin.cgi uamhomepage https://192.168.182.1/welcome.html uamsecret uamsecret uamlisten 192.168.182.1 uamallowed www.google.co.th,192.168.182.0/24 5. ติดตัง้ firewall cp /usr/share/doc/chillispot/firewall.iptables /etc/init.d/chilli.iptables chmod a+x /etc/init.d/chilli.iptables ln -s /etc/init.d/chilli.iptables /etc/rcS.d/S41chilli.iptables 6. แก ้ไขคอนฟิ ก firewall IPTABLES=‖/sbin/iptables‖ EXTIF=‖eth1″ # interface ทีต ่ อ ่ กับ wifi access point INTIF=‖eth0″ # interface ทีต ่ อ ่ กับ router adsl $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 22 –syn -j ACCEPT # อนุญาตให ้ client ภายในวง 192.168.182.0/24 ssh ไปที่ server Ubuntu ได ้ (เปิ ดไว ้ก่อน สาหรับ config เดีย ๋ วค่อยปิ ดทีหลัง) $IPTABLES -A INPUT -p tcp -m tcp –dport 80 –syn -j ACCEPT $IPTABLES -A INPUT -p tcp -m tcp –dport 443 –syn -j ACCEPT #Allow 3990 on other interfaces (input). $IPTABLES -A INPUT -p tcp -m tcp –dport 3990 –syn -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 #Allow ping to myserver (บรรทัดนีเ้ พิม ่ เข ้าไป เพือ ่ ให ้สามารถ ping ที่ Server Ubuntu ได ้ ! เดีย ๋ วค่อยปิ ดทีหลัง) SERVER_IP=‖192.168.182.1″ /sbin/iptables -A INPUT -p icmp –icmp-type 8 -s 0/0 -d $SERVER_IP -m state –state NEW,ESTABLISHED,RELATED -j ACCEPT /sbin/iptables -A OUTPUT -p icmp –icmp-type 0 -s $SERVER_IP -d 0/0 -m state –state ESTABLISHED,RELATED -j ACCEPT 7. ติดตัง้ Apache2 และ PHP5 apt-get install apache2 apt-get install php5 8. ติดตัง้ Mysql Server อย่าลืมจา password ของ root ไว ้ด ้วย apt-get install mysql-server 9. ติดตัง้ PhpMyAdmin apt-get install phpmyadmin 10. ทาการสร ้างหน ้าสาหรับ Login mkdir –p /var/www/cgi-bin zcat –c /usr/share/doc/chillispot/hotspotlogin.cgi.gz | tee /var/www/cgibin/ hotspotlogin.cgi chmod 755 /var/www/cgi-bin/hotspotlogin.cgi 11. แก ้ไขค่าคอนฟิ กในหน ้า login ให ้ตรงกับ chillispot.conf vi /var/www/cgi-bin/hotspotlogin.cgi $uamsecret=‖uamsecret‖; $userpassword=1: 12. จากนัน ้ ทาการสร ้าง file welcome.html <html> <head><title> Welcome to Our Hotspot, Wireless Network </title> </head> <body> <center> <H1><font color=‖red‖>TESTING ONLY</font></H1> <img src=‖chillispot.png‖> <H3><font color=‖blue‖>Welcome to Our Hotspot, Wireless Network.</font></H3> <p>You are connected to an authentication and restricted network access point. <H3><a href=‖http://192.168.182.1:3990/prelogin‖>Click here to login</a></H3> <p> <p>Enjoy. </center> </body> </html> 13. copy logo chillispot มาด ้วย เอาจากศูนย์คอมนีแ ่ หละ wget http://mamboeasy.psu.ac.th/~wiboon.w/images/stories/chillispot/chillispot.png cp chillispot.png /var/www 14. ทาให ้ apache2 ใช ้ SSL mkdir /etc/apache2/ssl make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem a2enmod ssl ่ hotspot 15. สร ้าง virtual host ชือ vi /etc/apache2/sites-available/hotspot NameVirtualHost 192.168.182.1:443 <VirtualHost 192.168.182.1:443> ServerAdmin [email protected] DocumentRoot ―/var/www‖ ServerName ―192.168.182.1″ <Directory ―/var/www/‖> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory ―/var/www/cgi-bin/‖> AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/hotspot-error.log LogLevel warn CustomLog /var/log/apache2/hotspot-access.log combined ServerSignature On SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.pem </VirtualHost> 16. แล ้วทาการ enable SSL virtual host a2ensite hotspot 17. แก ้ไข apache2 port vi /etc/apache2/ports.conf #NameVirtualHost *:80 #Listen 80 #<IfModule mod_ssl.c> # SSL name based virtual hosts are not yet supported, therefore no # NameVirtualHost statement here # Listen 443 #</IfModule> Listen 192.168.182.1:80 Listen 192.168.182.1:443 18. กาหนดค่า ServerName และ hosts vi /etc/apache2/apache2.conf ServerName 192.168.182.1 ServerRoot ―/etc/apache2″ vi /etc/hosts 127.0.0.1 localhost 127.0.1.1 bigtree-ibm 192.168.182.1 bigtree-ibm # เพิม ่ เข ้าไป 19. จากนัน ้ ให ้ทาการ restart apache2 /etc/init.d/apache2 restart 20. ติดตัง้ Freeradius 2.x.x apt-get install freeradius freeradius-mysql 21. กาหนดค่าคอนฟิ กของ Freeradius 2.x.x โดยทาการแก ้ไข 4 ไฟล์ดงั นี้ vi /etc/freeradius/radiusd.conf ให ้เอา comment ทีห ่ น ้า 2 บรรทัดนีอ ้ อก modules { …. $INCLUDE sql.conf $INCLUDE sql/mysql/counter.conf …. :wq! ทาการ save คอนฟิ ก vi /etc/freeradius/sql.conf # Connection info: server = ―localhost‖ login = ―root‖ password = ―mysqlrootpassword― #ใส่ password root ของ mysql ทีเ่ ราติดตัง้ ไว ้ก่อนหน ้านี้ # Database table configuration for everything except Oracle radius_db = ―radius‖ :wq! ทาการ save คอนฟิ ก vi /etc/freeradius/clients.conf client localhost { … secret = radiussecret # แก ้ไขค่าให ้ตรงกับ chillispot … :wq! ทาการ save คอนฟิ ก vi /etc/freeradius/sites-available/default authorize { … #files #ปิ ดการรับ authen จาก files … sql #เปิ ดการรับ authen จาก mysql server แทน … daily # เพิม ่ 3 บรรทัดข ้างล่างต่อท ้าย noresetcounter dailycounter monthlycounter … accounting { … sql #ให ้ accounting จาก mysql server … session { … sql … :wq! ทาการ save คอนฟิ ก 22. ติดตัง้ daloradius ซึง่ เป็ นโปรแกรมจัดการ Hotspot ให ้โหลด file จาก http://sourceforge.net/projects/daloradius/ tar zvfx daloradius-0.9-8.tar.gz cp -R daloradius-0.9-8 /var/www mv daloradius-0.9-8 dalo ่ radius และ import โครงสร ้างจาก daloradius 23. สร ้าง database ชือ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 166 Server version: 5.1.37-1ubuntu5 (Ubuntu) Type ‗help;‘ or ‗\h‘ for help. Type ‗\c‘ to clear the current input statement. mysql> create database radius; Query OK, 1 row affected (0.00 sec) mysql> exit Bye import โครงสร ้าง database จาก file /var/www/dalo/contrib/db/fr2-mysql-daloradius-and-freeradius.sql mysql -u root -p radius < /var/www/dalo/contrib/db/fr2-mysql-daloradius-and-freeradius.sql Enter password: 24. เปิ ด web browser เพือ ่ ทาการเพิม ่ user http://192.168.182.1/dalo/login.php Username: administrator Password: radius กดปุ่ ม Apply เพือ ่ ทาการ create user 25. ทดสอบการ authen ของ radius ด ้วยการเปิ ด command ขึน ้ มา 2 หน ้า หน ้าแรกเพือ ่ การ debug freeradius -XXX หน ้าทีส ่ องเพือ ่ ทดสอบ radtest test test 127.0.0.1 0 radiussecret Sending Access-Request of id 43 to 127.0.0.1 port 1812 User-Name = ―test‖ User-Password = ―test‖ NAS-IP-Address = 127.0.1.1 NAS-Port = 0 rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=43, length=20 เป็ นอันเรียบร ้อย : )
© Copyright 2026 Paperzz