项目作者: zoilomora

项目描述 :
Captive Portal in Linux
高级语言:
项目地址: git://github.com/zoilomora/captive-portal.git
创建时间: 2018-06-09T08:54:25Z
项目社区:https://github.com/zoilomora/captive-portal

开源协议:MIT License

下载


Captive Portal in Linux

Description

Result diagram

*Note: Most of the default settings will be used to obtain a functional portal Captive with the minimum configuration
we will assume most of the default.*

Requirements

Hardware

  • Internet connection
  • Wireless LAN Access Point
  • 2 network cards

Software

  • CentOS 7

Installation

All the commands listed below will be executed as root.

  1. Update CentOS 7:

    1. yum check-update
    2. yum update
  2. Disable firewall by default:

    1. systemctl stop firewalld
    2. systemctl disable firewalld
  3. Install packages and dependencies:

    1. # Tools
    2. yum install wget nano
    3. # Firewall
    4. yum install iptables-services
    5. # FreeRADIUS
    6. yum install freeradius freeradius-utils
    7. # Web Server
    8. yum install httpd openssl mod_ssl
    9. # Chillispot dependencies
    10. yum install glibc-devel.i686 glibc-i686 perl-Digest-MD5
  4. Install Chillispot:

    1. wget https://raw.githubusercontent.com/zoilomora/captive-portal/master/chillispot-1.1.0.i386.rpm
    2. rpm -Uvh chillispot-1.1.0.i386.rpm
  5. Edit the file /etc/chilli.conf and modify the following lines:

    1. # DNS
    2. dns1 8.8.8.8
    3. dns2 8.8.4.4
    4. # FreeRADIUS
    5. radiusserver1 127.0.0.1
    6. radiusserver2 127.0.0.1
    7. radiussecret secret-password-for-radius
    8. # DHCP
    9. dhcpif eth1
    10. # Universal access method (UAM)
    11. uamserver https://192.168.182.1/cgi-bin/hotspotlogin.cgi
    12. uamhomepage https://192.168.182.1/
    13. uamsecret secret-password-for-uam
  6. Link dictionary from Chillispot to FreeRADIUS

    1. echo "\$INCLUDE /usr/share/doc/chillispot-1.1.0/dictionary.chillispot" >> /etc/raddb/dictionary
  7. Copy the login script and grant permissions:

    1. cd /var/www/cgi-bin/
    2. cp /usr/share/doc/chillispot-1.1.0/hotspotlogin.cgi ./hotspotlogin.cgi
    3. chown apache.apache ./hotspotlogin.cgi
    4. chmod 700 ./hotspotlogin.cgi
  8. Edit the file /var/www/cgi-bin/hotspotlogin.cgi:

    1. # Uncomment the lines
    2. $uamsecret = "secret-password-for-uam";
    3. $userpassword = 1;
  9. Create the /var/www/html/index.html file with the content:

    1. <html>
    2. <body>
    3. <a href="http://192.168.182.1:3990/prelogin">Click here to login</a>
    4. </body>
    5. </html>
  10. Enable Chillispot firewall rules:

    1. # Executes iptables rules and is enabled in memory
    2. /usr/share/doc/chillispot-1.1.0/firewall.iptables
    3. # The rules persist
    4. service iptables save
  11. Enable IP Forward:

    1. # Add the line to the end of the file
    2. echo "net.ipv4.ip_forward = 1" >> /usr/lib/sysctl.d/50-default.conf
    3. # Applies the settings to the system
    4. /sbin/sysctl -p
  12. Adjust the FreeRADIUS shared secret by editing the file /etc/raddb/clients.conf:

    1. client localhost {
    2. # Replace the default password with that of step 5 (radiussecret)
    3. secret = secret-password-for-radius
    4. }
  13. Register user in FreeRADIUS by editing the file /etc/raddb/users:

    1. # Insert a line for each user at the end of the file
    2. john Cleartext-Password := "hello"
  14. Check access to FreeRADIUS from console:

    1. radtest "john" "hello" 127.0.0.1 0 testing123
    • Correct result of the command
      1. Sent Access-Request Id 215 from 0.0.0.0:51134 to 127.0.0.1:1812 length 75
      2. User-Name = "john"
      3. User-Password = "hello"
      4. NAS-IP-Address = 127.0.0.1
      5. NAS-Port = 0
      6. Message-Authenticator = 0x00
      7. Cleartext-Password = "hello"
      8. Received Access-Accept Id 215 from 127.0.0.1:1812 to 0.0.0.0:0 length 20
  15. Activate the services so that they start at startup:

    1. systemctl enable iptables
    2. systemctl enable httpd
    3. systemctl enable radiusd
    4. systemctl enable chilli
  16. Restart the server to apply and activate the services

    1. reboot

Notes

  • Start freeradius in debug mode to check in case of error:
    1. radiusd -X