apacheiptableshotspotcaptiveportal

How make automatic detection of captive portal


I'm doing a hotspot on a server with CentOS 6 and I'd like to know how to make the smarthphones automatically recognize a captive portal, to redirect to the login. In my firewall I have this rule:

iptables -t nat -A NET_DHCP -i eth1 -s 172.16.0.0/16 -p tcp --dport 80 -j DNAT --to 172.16.0.1:80

In Apache (httpd.conf):

<VirtualHost *:80>
        ErrorDocument 400 /var/www/dhcpauth/index.php
        ErrorDocument 404 /var/www/dhcpauth/index.php
        ServerPath /var/www/dhcpauth
        DocumentRoot /var/www/dhcpauth/
        <Directory /var/www/dhcpauth>
            AllowOverride All
            DirectoryIndex index.html index.html
            Options Indexes FollowSymLinks
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>

In other related answers I found the following code. It did not work the way I used it:

<!--
<?xml version="1.0" encoding="UTF-8"?>
<WISPAccessGatewayParam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.wballiance.net/wispr_2_0.xsd">
<Redirect>
<MessageType>100</MessageType>
<ResponseCode>0</ResponseCode>
<VersionHigh>2.0</VersionHigh>
<VersionLow>1.0</VersionLow>
<AccessProcedure>1.0</AccessProcedure>
<AccessLocation>Andrew Wippler is awesome</AccessLocation>
<LocationName>MyOpenAP</LocationName>
<LoginURL>http://hotspot.localnet/</LoginURL>
</Redirect>
</WISPAccessGatewayParam>
-->

The hotspot works normally if it is accessed by the internal domain or IP, but when the devices connect in the network I would like to see the message "This network needs authentication". Could someone please help me?


Solution

  • I was able to do the reconnaissance while doing a 302 redirect by apache, according to the link:

    https://serverfault.com/questions/679393/captive-portal-popups-the-definitive-guide

    It should be noted that in virtual host Apache's only option should be FollowSymLinks Options like:

    Options FollowSymLinks