I have created a captive portal with iptables

I use what many people seem to use : Users can request DNS, packet marked as 99. 99 means no internet else the user does have access.

When a user visits a page when visiting for example stack overflow. The user gets the disclaimer. He/she clicks on okay. What happened is that the server executes the following rules :

`sudo /sbin/iptables -t mangle -I captivePortal 1 -m mac --mac-source {$mac} -j RETURN`;
    `sudo /sbin/iptables -t mangle -I captivePortal 1 -s {$_SERVER['REMOTE_ADDR']} -j RETURN`;

What i have tried:

Used sinatra stand alone with thin. Render template with erb. When the user reloads after authenticating they get the disclaimer when visiting the initial domain. When the visit another they dont get the disclaimer page.

Set up apache2 with php, rewritten all in php. added meta tags to prevent caching in the browser but same result. original domain redirects to disclaimer always but other sites are okay.

What i want to achieve

Users need to click accept on disclaimer before they can use WIFI.

Reloading apache2 or restarting Sinatra does fix this problem, but that is not a proper solution on a low end alix board.


Found out that after inserting the mac address into iptables i needed to use conntrack.

/usr/sbin/conntrack -L \
|grep $1 \
|grep ESTAB \
|grep 'dport=80' \
|awk \
    "{ system(\"conntrack -D --orig-src $1 --orig-dst \" \
        substr(\$6,5) \" -p tcp --orig-port-src \" substr(\$7,7) \" \
        --orig-port-dst 80\"); }"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.