Mudanças entre as edições de "Como criar o portal cativo de controle de acesso"

De Wiki Coolab
Ir para navegação Ir para pesquisar
m (Foram revertidas as edições de Brunovianna (disc) para a última versão por Adriano)
Linha 1: Linha 1:
  
 +
'''Informações preliminares'''
 +
* Essas instruções são para o roteador que está conectado à internet, fornecendo para o resto da rede. Não foi testado com mais de um gateway
 +
* Esse sistema de validação e portal cativo não funciona quando não há acesso internet, ou quando o acesso cai. Para isso, tem uma gambiarra descrita no fim da página
  
'''Important information'''
+
== Para versão DaybootRely da LibreMesh (1706) ==
* These instructions are meant for the gateway routers, connected to the Internet and providing it to the rest of the mesh. It was not tested in networks with more than one exit.
 
* The captive portal system doesn't work when there is no access to the Internet
 
  
== Libremesh's DaybootRely version (1706) ==
+
1. Faça o login na linha de comando via SSH e atualize os repositórios do roteador que receberá o portal captivo:
 
 
1. Login to the router through ssh and update the software repositories:
 
  
 
<code>opkg update</code>
 
<code>opkg update</code>
  
2. Now let’s install nodogsplash [http://nodogsplash.readthedocs.io/en/latest/ nodogsplash]. This is a package for version 17 of LiMe.
+
2. Vamos agora instalar o [http://nodogsplash.readthedocs.io/en/latest/ nodogsplash].
 +
Esté um pacote com as mudanças necessárias para instalar o captivo na versão 17.
  
 
<code>opkg install http://nuvem.tk/files/nodogsplash_0.9.2-1_mips_24kc.ipk</code>
 
<code>opkg install http://nuvem.tk/files/nodogsplash_0.9.2-1_mips_24kc.ipk</code>
  
3. Now we must edit the configuration file
+
3. Agora vamos editar o arquivo de configuração
  
 
<code>vi /etc/config/nodogsplash</code>
 
<code>vi /etc/config/nodogsplash</code>
  
Change the following lines so that this is the final result:
+
Neste arquivo, altere o arquivo nas seguintes linhas, de modo que se registre os seguintes parâmetros:
  
Change "option enable" from 0 to 1
+
Altere o valor do "option enable" de 0 para 1
  
 
<code>option enable 1</code>
 
<code>option enable 1</code>
  
Uncomment (erase the hash symbol from the start) the following line:
+
Descomentar (apagar o jogo da velha do início da linha) a linha a seguir:
  
 
<code>option config '/etc/nodogsplash/nodogsplash.conf'</code>
 
<code>option config '/etc/nodogsplash/nodogsplash.conf'</code>
  
Erase all lines after this one.
+
4. Agora salve o arquivo e saia do editor de texto.
  
4. Now save the file and exit the editor.
+
5. Crie o arquivo /etc/nodogsplash/nodogsplash.conf pelo listado abaixo (fazendo as devidas modificações nos IP e página de redirecionamento). O IP a ser usado é o do menu network -> interfaces, interface LAN (IPV4) (sem o /16). O range são os dois primeiros números, seguidos de .0.0/16. (ex se o ip é 10.7.255.50, o range é 10.7.0.0/16.
 
 
5. Create the file /etc/nodogsplash/nodogsplash.conf using the text below (modifying the IP and redirect page according to your network). You can find the ip to be used in the graphical interface (http://thisnode.info)under the menu menu network -> interfaces, LAN interface (IPV4) (without /16). The range are the first two numbers, follwed by .0.0/16. (for example, if the ip is 10.7.255.50, the range will be 10.7.0.0/16).
 
  
 
<pre>
 
<pre>
Linha 113: Linha 111:
 
</pre>
 
</pre>
  
DON’T FORGET TO CHANGE THE Ips IN THE FILE ABOVE!
+
NÃO ESQUEÇA DE TROCAR OS IPs no arquivo acima!
  
6. Go to the menu system -> startup and check if nodogsplash is ENABLED
+
6. Vá no menu system -> startup e confira se o nodogsplash está como ENABLED
  
7. Restart the router. When it is back on, the blocking of http pages should be working already.
+
7. Reinicie o roteador. Quando ele voltar, o bloqueio das portas HTTP já devem estar funcionando.  
  
8. Now let’s modify the FIREWALL so that https and other protocols/ports will also be blocked,
+
8. Agora, vamos modificar o FIREWALL
  
 
<code>vi /etc/config/firewall</code>
 
<code>vi /etc/config/firewall</code>
  
Comment out the following lines, including the hash symbol the beginning. It should look like this after editing.
+
Comente as seguintes linhas, incluindo jogo da velha antes de cada uma o jogo de velha (#)
  
 
<pre>
 
<pre>
#config forwarding
+
config forwarding
     #option src 'lan'
+
     option src 'lan'
     #option dest 'wan'
+
     option dest 'wan'
 
</pre>  
 
</pre>  
  
Save the file and restart the firewall
+
Depois salve o arquivo e reinicie novamente o roteador. Agora o bloqueio de HTTPS já deve estar funcionado.
 
 
<pre>
 
/etc/init.d/firewall reload && /etc/init.d/firewall restart
 
</pre>
 
 
 
Restart the router. Now the https pages should also be blocked.
 
  
== Voucher system configuration ==
+
== Configurando o voucher ==
 
 
1. Let’s connect through ssh, update repos and install the vale package.
 
  
 +
1. Conectadoas via SSH no roteador, vamos atualizar os repositórios e instalar o pacote do voucher
 
<pre>
 
<pre>
 
opkg update && opkg install http://nuvem.tk/files/vale_0.1-1_mips_24kc.ipk
 
opkg update && opkg install http://nuvem.tk/files/vale_0.1-1_mips_24kc.ipk
 
</pre>
 
</pre>
  
2. Now rename the splash html file. You can also customize this file to reflect your community info.
+
2. Vamos renomear o arquivo HTML do splash
 
 
 
<pre>
 
<pre>
 
mv /etc/nodogsplash/htdocs/splash-vale.html /etc/nodogsplash/htdocs/splash.html
 
mv /etc/nodogsplash/htdocs/splash-vale.html /etc/nodogsplash/htdocs/splash.html
 
</pre>
 
</pre>
  
3. Restart nodogpslash
+
3. Reinicie o nodogpslash
 
<pre>
 
<pre>
 
/etc/init.d/nodogpslash restart
 
/etc/init.d/nodogpslash restart
 
</pre>
 
</pre>
  
4. Translate or adapt the messages in the file  /www/cgi-bin/vale
+
4. Traduza ou customize as mensagens de erro que estão no arquivo /www/cgi-bin/vale
 
   
 
   
5. Add your VOUCHER codes in the files /etc/nodogsplash/vale/db.csv (you can use a [http://generator.voucherify.io/# random code generator]).  
+
5. Adicione seus códigos de VOUCHER no arquivo /etc/nodogsplash/vale/db.csv (se preferir, use um [http://generator.voucherify.io/# gerador aletório]).  
  
You can see an example of the formatting here: [https://github.com/coolabnet/lime-packages/blob/develop/packages/vale/files/etc/nodogsplash/vale/db.csv db.csv]
+
Veja um exemplo do arquivo [https://github.com/coolabnet/lime-packages/blob/develop/packages/vale/files/etc/nodogsplash/vale/db.csv db.csv]
  
Each line must end with two commas, with no spaces, and begin with one comma. The columns will be used to annotate the date/time and MAC address of every voucher. To generate automatically the commas, use an empty column in the beginning and two in the end in your spreadsheet editor. Example:
+
A primeira coluna não é utilizada. Cada linha tem que terminar com as duas vírgulas, sem espaços. As outras colunas serão usadas para anotar a hora e o MAC de cada conexão/voucher. Para gerar automaticamente as duas vírgulas ao fim de cada linha preencha a primeira linha. Exemplo:
  
 
<pre>
 
<pre>
reference,code,field1,field2
+
code,field1,field2
,6XvMcaLb,,
+
6XvMcaLb,,
,cF6m7eXu,,
+
cF6m7eXu,,
,nNqsSMCS,,
+
nNqsSMCS,,
,GSYJPotH,,
+
GSYJPotH,,
,PecFaM8c,,
+
PecFaM8c,,
,Tx2GgNNX,,
+
Tx2GgNNX,,
,zEeTmcwu,,
+
zEeTmcwu,,
,hBg5858g,,
+
hBg5858g,,
,rmsgUqR2,,
+
rmsgUqR2,,
 
</pre>
 
</pre>
  
6. Now copy it to your router:
+
6. Agora, copie o arquivo para o seu roteador
  
 
<pre> scp db.csv root@thisnode.info:/etc/nodogsplash/vale/</pre>
 
<pre> scp db.csv root@thisnode.info:/etc/nodogsplash/vale/</pre>
  
+
== Customizando o portal captivo ==
 +
 
 +
1.
  
'''References'''
+
'''Referências'''
  
 
* [http://nuvem.tk/wiki/index.php/Fuma%C3%A7a_Data_Springs/Anexo_t%C3%A9cnico#Instala.C3.A7.C3.A3o_do_portal_de_controle_de_acesso Tutorial da Nuvem]
 
* [http://nuvem.tk/wiki/index.php/Fuma%C3%A7a_Data_Springs/Anexo_t%C3%A9cnico#Instala.C3.A7.C3.A3o_do_portal_de_controle_de_acesso Tutorial da Nuvem]
 
* [http://nodogsplash.readthedocs.io/en/latest/ Nodogsplash - Documentação]
 
* [http://nodogsplash.readthedocs.io/en/latest/ Nodogsplash - Documentação]

Edição das 22h38min de 27 de março de 2018

Informações preliminares

  • Essas instruções são para o roteador que está conectado à internet, fornecendo para o resto da rede. Não foi testado com mais de um gateway
  • Esse sistema de validação e portal cativo não funciona quando não há acesso internet, ou quando o acesso cai. Para isso, tem uma gambiarra descrita no fim da página

Para versão DaybootRely da LibreMesh (1706)

  1. Faça o login na linha de comando via SSH e atualize os repositórios do roteador que receberá o portal captivo:

opkg update

  1. Vamos agora instalar o nodogsplash. Esté um pacote com as mudanças necessárias para instalar o captivo na versão 17.

opkg install http://nuvem.tk/files/nodogsplash_0.9.2-1_mips_24kc.ipk

  1. Agora vamos editar o arquivo de configuração

vi /etc/config/nodogsplash

Neste arquivo, altere o arquivo nas seguintes linhas, de modo que se registre os seguintes parâmetros:

Altere o valor do "option enable" de 0 para 1

option enable 1

Descomentar (apagar o jogo da velha do início da linha) a linha a seguir:

option config '/etc/nodogsplash/nodogsplash.conf'

  1. Agora salve o arquivo e saia do editor de texto.
  2. Crie o arquivo /etc/nodogsplash/nodogsplash.conf pelo listado abaixo (fazendo as devidas modificações nos IP e página de redirecionamento). O IP a ser usado é o do menu network -> interfaces, interface LAN (IPV4) (sem o /16). O range são os dois primeiros números, seguidos de .0.0/16. (ex se o ip é 10.7.255.50, o range é 10.7.0.0/16.
GatewayInterface br-lan
GatewayInterfaceExtra bmx+
GatewayInterfaceExtra2 anygw

FirewallRuleSet authenticated-users {
     FirewallRule allow to 0.0.0.0/0
}

FirewallRuleSet users-to-router {                                                                           
 # Nodogsplash automatically allows tcp to GatewayPort,                                                     
 # at GatewayAddress, to serve the splash page.                                                             
 # However you may want to open up other ports, e.g.                                                        
 # 53 for DNS and 67 for DHCP if the router itself is                                                       
 # providing these services.                                                                                
    FirewallRule allow udp port 53                                                                          
    FirewallRule allow tcp port 53                                                                          
    FirewallRule allow udp port 67                                                                          
 # You may want to allow ssh, http, and https to the router                                                 
 # for administration from the GatewayInterface.  If not,                                                   
 # comment these out.                                                                                       
    FirewallRule allow tcp port 22                                                                          
    FirewallRule allow tcp port 80                                                                          
    FirewallRule allow tcp port 443                                                                         
}                                                                                                           
# end FirewallRuleSet users-to-router                                                                       

FirewallRuleSet preauthenticated-users {
 # For preauthenticated users to resolve IP addresses in their initial
 # request not using the router itself as a DNS server,
 # you probably want to allow port 53 udp and tcp for DNS.
    FirewallRule allow tcp port 53  
    FirewallRule allow udp port 53
 # For splash page content not hosted on the router, you
 # will want to allow port 80 tcp to the remote host here.
 # Doing so circumvents the usual capture and redirect of
 # any port 80 request to this remote host.
 # Note that the remote host's numerical IP address must be known
 # and used here.  


     #change the IP for the address of the gateway router
     FirewallRule allow tcp port 80 to 10.7.122.55


}
# end FirewallRuleSet preauthenticated-users
      
                                                

EmptyRuleSetPolicy preauthenticated-users passthrough
EmptyRuleSetPolicy users-to-router passthrough


#change the IP for the address of the gateway router
GatewayName 10.7.122.55:80

#GatewayPort 80


MaxClients 500

ClientIdleTimeout 720

ClientForceTimeout 14400


#change the range for the ip range of your mesh network
GatewayIPRange 10.7.0.0/16

# BinVoucher "vale.sh"

# ForceVoucher yes

# EnablePreAuth yes

NÃO ESQUEÇA DE TROCAR OS IPs no arquivo acima!

  1. Vá no menu system -> startup e confira se o nodogsplash está como ENABLED
  2. Reinicie o roteador. Quando ele voltar, o bloqueio das portas HTTP já devem estar funcionando.
  3. Agora, vamos modificar o FIREWALL

vi /etc/config/firewall

Comente as seguintes linhas, incluindo jogo da velha antes de cada uma o jogo de velha (#)

config forwarding
    option src 'lan'
    option dest 'wan'

Depois salve o arquivo e reinicie novamente o roteador. Agora o bloqueio de HTTPS já deve estar funcionado.

Configurando o voucher

  1. Conectadoas via SSH no roteador, vamos atualizar os repositórios e instalar o pacote do voucher
opkg update && opkg install http://nuvem.tk/files/vale_0.1-1_mips_24kc.ipk
  1. Vamos renomear o arquivo HTML do splash
mv /etc/nodogsplash/htdocs/splash-vale.html /etc/nodogsplash/htdocs/splash.html
  1. Reinicie o nodogpslash
/etc/init.d/nodogpslash restart
  1. Traduza ou customize as mensagens de erro que estão no arquivo /www/cgi-bin/vale
  2. Adicione seus códigos de VOUCHER no arquivo /etc/nodogsplash/vale/db.csv (se preferir, use um gerador aletório).

Veja um exemplo do arquivo db.csv

A primeira coluna não é utilizada. Cada linha tem que terminar com as duas vírgulas, sem espaços. As outras colunas serão usadas para anotar a hora e o MAC de cada conexão/voucher. Para gerar automaticamente as duas vírgulas ao fim de cada linha preencha a primeira linha. Exemplo:

code,field1,field2
6XvMcaLb,,
cF6m7eXu,,
nNqsSMCS,,
GSYJPotH,,
PecFaM8c,,
Tx2GgNNX,,
zEeTmcwu,,
hBg5858g,,
rmsgUqR2,,
  1. Agora, copie o arquivo para o seu roteador
 scp db.csv root@thisnode.info:/etc/nodogsplash/vale/

Customizando o portal captivo

  1. Referências