wlan welcomepage

Discussion in 'Programming/Scripts' started by commentator, Jun 23, 2009.

  1. commentator

    commentator Member

    Hi,

    In a ctmagazine from 2007 I found a nice cgi/iptables script to redirect every first visit to a welcome page.

    When I'm new, my mac is not on the list, and I browse for example to http://www.howtoforge.com I'm redirected to the welcomepage.
    After visiting the welcome page the mac is added to the allowed list and you can visit the pages on the web.

    This works except
    after visiting the welcomepage I can browse every page I want (like ispconfig.org) except the domain I tried to visit when the mac wasn't on the list.
    I have to close the browser and restart to browse to http://www.howtoforge.com in this example

    How to fix this?
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Can you post the script here?
     
  3. commentator

    commentator Member

    Code:
    iptables -t nat -A PREROUTING -p tcp -i $INTERFACE --dport 80 -j REDIRECT --too-ports 80
    
    cgi script
    Code:
    #!usr/bin/perl -w
    use warnings;
    use strict;
    use CGI qw/:standard/;
    my $URL = "http://192.168.0.1/index.html";
    my $INTERFACE=eth0;
    my $remote_ip = $ENV{'REMOTE_ADDR'};
    open(LS, "sudo arp - na |");
    while(<LS>){
       chop
       if($_ = ~/$remote_ip/) {
          my @lijst = split(/ /);
          system("sudo iptables -t nat -I PREROUTING -p tcp -i $INTERFACE -m mac --mac-source $lijst[3] - j ACCEPT");
          print "Status: 302 Moved\nLocation: $URL\n\n";
       }
    }
    close(LS);
    
     
  4. falko

    falko Super Moderator ISPConfig Developer

    I wonder if that has anything to do with your browser's cache. Have you tried to clear the browser cache?
     
  5. commentator

    commentator Member

    Hi,

    thanks for your reply.
    Cleared the cache. Problem still there.
    Also adding some vars like ?bla=1 to the url doesn't matter.
    Is there a way to fix this problem?
     
  6. id10t

    id10t Member

    Browsers tend to cache DNS info as well as images/files/etc. Try creating a new user or new profile for the after check...
     
  7. commentator

    commentator Member

    same problem on fresh pc install.
     
  8. commentator

    commentator Member

    other suggestions?
     
  9. davin.master

    davin.master New Member

    nice script and provide some other use full scripts like this.
     

Share This Page