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

    Captive Portal com Proxy Transparente na versão 2.3 do Pfsense

    Scheduled Pinned Locked Moved Portuguese
    19 Posts 9 Posters 6.9k 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.
    • J Offline
      juninhoandrade
      last edited by

      Captiveportal não está redirecionando aqui .. poem  "clica em login " mas ele não redireciona.

      verifiquei aqui que tem um "  " adicional "_"

      Fixado ! :)

      1 Reply Last reply Reply Quote 0
      • A Offline
        albarci
        last edited by

        Bom dia,

        Também passei pelo memo problema e encontrei a solução.
            O primeiro passo é a correção do script conforme o "paulorm.bsd" fez.
            O script roda sem erro com usuário que tenha permissões então, basta apenas dar permissão ao usuário squid, pois ele quem executa o script. Para isso, basta apenas aplicar o comando conforme segue:

        chmod 666 /usr/local/etc/php/extensions.ini

        Com essa alteração, o erro de Class não mais ocorrerá e o squid passará a funcionar corretamente.

        O ideal é fazer um script para executar quando o S.O. for reiniciado, pois essas permissões serão perdidas.

        1 Reply Last reply Reply Quote 0
        • I Offline
          iNCONIX
          last edited by

          Estou tentando implementar

          Captive Portal com Proxy Transparente na versão 2.3 do Pfsense

          mas não sei qual CHECK_IP.PHP devo baixar para aplicar as alterações do PAULORM.BSD
          São tantos CHECK_IP.PHP diferentes e espalhados que já estou perdido. kkkkk

          Na versão 2.1 utilizei o indicado pelo MARCELLOC:

          fetch -o /usr/pbi/squid-amd64/libexec/squid/check_ip.php https://raw.github.com/pfsense/pfsense-packages/master/config/squid3/33/check_ip.php

          Só que na versão 2.3 não existe mais o diretorio /usr/pbi/squid-amd64/libexec/squid

          O local ideal para baixar, seria no /usr/local/libexec/squid  ? ? ?

          Quando alguém indicar um CHECK_IP.PHP  que rode na 2.3 , indique também o local onde esse cara deve ficar, por favor.

          Obrigado a todos.

          1 Reply Last reply Reply Quote 0
          • R Offline
            rlrobs
            last edited by

            Essa foi o melhor que achei.

            No 2.3 substituia o check_ip.php original: /usr/local/bin/check_ip.php

            
            #!/usr/local/bin/php-cgi -q
            /*
            	check_ip.php
            	part of pfSense (https://www.pfSense.org/)
            	Copyright (C) 2013-2016 Marcello Coutinho
            	Copyright (C) 2016 ESF, LLC
            	All rights reserved.
            
            	Redistribution and use in source and binary forms, with or without
            	modification, are permitted provided that the following conditions are met:
            
            	1\. Redistributions of source code must retain the above copyright notice,
            	   this list of conditions and the following disclaimer.
            
            	2\. Redistributions in binary form must reproduce the above copyright
            	   notice, this list of conditions and the following disclaimer in the
            	   documentation and/or other materials provided with the distribution.
            
            	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
            	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
            	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
            	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
            	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
            	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
            	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
            	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
            	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
            	POSSIBILITY OF SUCH DAMAGE.
            */
            require_once("config.inc");
            require_once("globals.inc");
            if (!extension_loaded('sqlite3')) {
            dl("sqlite3.so");
            }
            error_reporting(0);
            global $g;
            // stdin loop
            if (!defined(STDIN)) {
            	define("STDIN", fopen("php://stdin", "r"));
            }
            if (!defined(STDOUT)) {
            	define("STDOUT", fopen('php://stdout', 'w'));
            }
            while (!feof(STDIN)) {
            	$line = trim(fgets(STDIN));
            	$files = glob("{$g['vardb_path']}/captive*.db");
            	$answer="ERR";
            	foreach ($files as $file) {
            		$result = squid_cp_read_db($file);
            	foreach ($result as $row) {
            //Database contains 5 fields: 1461302438 - 2006 - 192.168.4.100 - fc:aa:14:7d:e6:de - admin - 80b7d55a1bacb9c6
            			if ($row[2] != "" && $row[2] == $line) {
            				$answer = "OK user={$row[4]}";
            				break 2;
            			}
            		}
            	}
            	fwrite(STDOUT, "{$answer}\n");
            }
            /* read captive portal DB into array */
            function squid_cp_read_db($file) {
            	$cpdb = array();
            	$DB = new SQLite3($file);
            	if ($DB) {
            		$response = $DB->query("SELECT * FROM captiveportal");
            		if ($response != FALSE) {
            			while ($row = $response->fetchArray()) {
            				$cpdb[] = $row;
            			}
            		}
            		$DB->close();
            	}
            	return $cpdb;
            }
            
            ?>
            
            
            1 Reply Last reply Reply Quote 0
            • I Offline
              iNCONIX
              last edited by

              Valeu pela dica RLROBS

              mas ainda não tá rolando …

              executo o /usr/local/bin/check_ip.php  e ele não mostra nada, até que dou enter e apresenta "ERR"

              No squid ainda não me mostra os usuários logados e apenas NEGA as solicitações:

              13.06.2016 23:24:40 192.168.231.12 TCP_DENIED/403 http://www.microsoft.com/pki/CRL/products/Microsoft%20Windows%20Hardware%20Compatibility%20PCA(1).crl - -
              13.06.2016 23:24:40 192.168.231.12 TCP_DENIED/403 http://crl.microsoft.com/pki/crl/products/MicrosoftRootAuthority.crl - -
              13.06.2016 23:24:40 192.168.231.12 TCP_DENIED/403 http://crl.microsoft.com/pki/crl/products/WinPCA.crl - -

              1 Reply Last reply Reply Quote 0
              • R Offline
                rlrobs
                last edited by

                Você tem q editar as configurações do squid e CP  e salvar. Além disso,  pra testar, vc executa o check_ip no shell e digita o. IP do cliente autenticado no CP. Ele retornar o usuário. Aqui tá rodando blz…

                1 Reply Last reply Reply Quote 0
                • I Offline
                  iNCONIX
                  last edited by

                  Beleza !  Funcionou

                  Valeu pelas dicas RLROBS

                  Agora bora testar SquidGuard !

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    juninhoandrade
                    last edited by

                    Vou verificar.

                    1 Reply Last reply Reply Quote 0
                    • E Offline
                      emanuelspeed
                      last edited by

                      iNCONIX, pode me dizer como você resolveu o problema de executr o /usr/local/bin/check_ip.php  e ele não mostrar nada, até que dou enter e apresenta "ERR"?
                      Estou com este mesmo problema.
                      Valeu!

                      1 Reply Last reply Reply Quote 0
                      • I Offline
                        iNCONIX
                        last edited by

                        apenas digite o IP da estação que efetuou o login no captive portal.

                        ex:

                        #/usr/local/bin/check_ip.php
                        192.168.1.10                                < –---  digite
                        OK=usuario                                    < -----  lhe será mostrado

                        ou ERR  se a estação não estiver logada no CP.

                        1 Reply Last reply Reply Quote 0
                        • E Offline
                          emanuelspeed
                          last edited by

                          Eu havia feito isso. Porém, continua aparecendo a mesma mensagem. Estou utilizando o script abaixo e a agora está funcionando tudo ok.

                          /usr/local/bin/check_ip.php:
                          #!/usr/local/bin/php-cgi -q
                          if(!defined(STDIN)){
                            define("STDIN", fopen("php://stdin", "r"));
                          }
                          if(!defined(STDOUT)){
                            define("STDOUT", fopen("php://stdout", "r"));
                          }
                          $check_ip = trim(fgets(STDIN));
                          $dbs = glob("/var/db/captiveportal*.db");
                          foreach($dbs as $db){
                            $status = check_ip($db, $check_ip);
                            break;
                          }
                          if(isset($status)){
                            fwrite(STDOUT, "OK user={$status}\n");
                          }
                          else{
                            fwrite(STDOUT, "ERR\n");
                          }

                          function check_ip($db, $check_ip){
                            exec("sqlite3 {$db} "SELECT ip FROM captiveportal WHERE ip='{$check_ip}'"", $ip);
                            if($check_ip == $ip[0]){
                                exec("sqlite3 {$db} "SELECT username FROM captiveportal WHERE ip='{$check_ip}'"", $user);
                                return $user[0];
                            }
                          }
                          ?>

                          1 Reply Last reply Reply Quote 0
                          • I Offline
                            iNCONIX
                            last edited by

                            À alguns posts atrás disse que estava ok e iria testar o SquidGuard.

                            Durante o teste do SquidGuard observei que o CaptivePortal derruba o login de uma estação Windows.

                            Faço o teste com o check_ip.php e informo o IP da estação e mostra ERR, mas no Captive Portal ainda me mostra logado
                            (inclusive no Dashboard)

                            Na estação Linux continua logada e navegando.

                            Mas após logar no Windows novamente o Linux é que cai.

                            Não consigo testar com mais que duas estações.

                            Alguém já testou isso com mais estações ? ? ?

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