Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Captive Portal redirection fails since last update..

    Scheduled Pinned Locked Moved 2.1 Snapshot Feedback and Problems - RETIRED
    4 Posts 2 Posters 2.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mathiew
      last edited by

      Hello,

      Since the last update  "Built On: Sun May 13 02:42:10 EDT 2012" our captive portal doesn't work anymore.

      The redirection URL seems to be wrong.

      Instead of a thing like : "10.0.54.1:8000/index.php?zone=zonename&…"

      We have

      "firewallHostnameDomainName/index.php?zone=1&…" ( moreover there's a dot missing between the hostname and the domain name in the redirect url)

      So Pfsense seems not being able to find the correct zonename of the portal and the correct ip of the interface...

      Nobody is experiencing the same trouble ?

      EDIT : I upgraded pfsense to the last (14 may) version, and the problem is still here.

      Here, the redirect URL I get :

      pfsense hostname : mypfsense
      pfsense domain : internal.mycorp.com

      And I use the default config of the captive portal.

      http://mypfsenseinternal.mycorp.com/index.php?zone=1&redirurl=http%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fmypfsenseinternal.mycorp.comhttp%3A%2F%2Fwww.google.com%2F

      Thanks

      Math

      1 Reply Last reply Reply Quote 0
      • M
        Mathiew
        last edited by

        A colleague  found a temporary fix

        Original /etc/inc/captiveportal.inc

        function portal_ip_from_client_ip($cliip) {
        	global $config, $cpzone;
        
        	$interfaces = explode(",", $config['captiveportal'][$cpzone]['interface']);
        	foreach ($interfaces as $cpif) {
        		$ip = get_interface_ip($cpif);
        		$sn = get_interface_subnet($cpif);
        		if (ip_in_subnet($cliip, "{$ip}/{$sn}"))
        			return $ip;
        
        	}
        

        New one

        function portal_ip_from_client_ip($cliip) {
        	global $config, $cpzone;
                foreach ($config['captiveportal'] as $cpkey => $cp) {
                $cpzone = $cpkey; 
        
        		$interfaces = explode(",", $config['captiveportal'][$cpzone]['interface']);
        		foreach ($interfaces as $cpif) {
        			$ip = get_interface_ip($cpif);
        			$sn = get_interface_subnet($cpif);
        			if (ip_in_subnet($cliip, "{$ip}/{$sn}"))
        				return $ip;
        		}
                }
        

        Original /usr/local/captiveportal/index.php

        $cpzone = $_REQUEST['zone'];
        $cpcfg = $config['captiveportal'][$cpzone];
        
        $orig_host = $_ENV['HTTP_HOST'];
        $orig_request = $_REQUEST['redirurl'];
        $clientip = $_SERVER['REMOTE_ADDR'];
        
        if (!$clientip) {
        	/* not good - bail out */
        	log_error("Captive portal could not determine client's IP address.");
        	$error_message = "An error occurred.  Please check the system logs for more information.";
        	portal_reply_page($redirurl, "error", $errormsg);
        	exit;
        }
        

        New One

        $orig_host = $_ENV['HTTP_HOST'];
        $orig_request = $_REQUEST['redirurl'];
        $clientip = $_SERVER['REMOTE_ADDR'];
        
        global $cpzone;
        #$cpzone = $_REQUEST['zone'];
        $ifip = portal_ip_from_client_ip($clientip);
        $cpcfg = $config['captiveportal'][$cpzone];
        
        if (!$clientip) {
        	/* not good - bail out */
        	log_error("Captive portal could not determine client's IP address.");
        	$error_message = "An error occurred.  Please check the system logs for more information.";
        	portal_reply_page($redirurl, "error", $errormsg);
        	exit;
        }
        

        Can we have a feedback on this ? Thanks  :)

        1 Reply Last reply Reply Quote 0
        • V
          vlad
          last edited by

          same problem…
          after you patch CaptivePortal is work.
          but after authorization to the client the speed is set 2,05 Kbits/s.
          "Per-user bandwith restriction" - enable/disable/set bandwith - no effect.
          what am I doing wrong?

          1 Reply Last reply Reply Quote 0
          • M
            Mathiew
            last edited by

            Dev feedback here :

            https://redmine.pfsense.org/issues/2454

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.