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
 
(9 revisões intermediárias por 2 usuários não estão sendo mostradas)
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 de saída para internet.
 +
* 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) ==
+
0. Esse tutorial supõe que você sabe usar o comando vi para editar texto em arquivos que estão no roteador. Se você sabe usar o comando scp também pode editar no seu PC e subir os arquivos editados para o seu roteador.
  
1. Login to the router through ssh and update the software repositories:
+
1. Faça o login na linha de comando via SSH e atualize os repositórios do roteador que receberá o portal captivo:
  
 
<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.
+
5. apague tudo que vem depois dessa linha
  
4. Now save the file and exit the editor.
+
6. Agora salve o arquivo e saia do editor de texto.
  
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).
+
7. 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.
  
 
<pre>
 
<pre>
Linha 50: Linha 52:
 
  # 53 for DNS and 67 for DHCP if the router itself is                                                       
 
  # 53 for DNS and 67 for DHCP if the router itself is                                                       
 
  # providing these services.                                                                                 
 
  # providing these services.                                                                                 
     FirewallRule allow udp port 53                                                                          
+
     FirewallRule allow udp port 53530                                                                          
     FirewallRule allow tcp port 53                                                                          
+
     FirewallRule allow tcp port 53530                                                                          
 
     FirewallRule allow udp port 67                                                                           
 
     FirewallRule allow udp port 67                                                                           
 
  # You may want to allow ssh, http, and https to the router                                                 
 
  # You may want to allow ssh, http, and https to the router                                                 
Linha 58: Linha 60:
 
     FirewallRule allow tcp port 22                                                                           
 
     FirewallRule allow tcp port 22                                                                           
 
     FirewallRule allow tcp port 80                                                                           
 
     FirewallRule allow tcp port 80                                                                           
     FirewallRule allow tcp port 443                                                                        
+
     FirewallRule allow tcp port 443
 +
 
 
}                                                                                                           
 
}                                                                                                           
 
# end FirewallRuleSet users-to-router                                                                       
 
# end FirewallRuleSet users-to-router                                                                       
Linha 105: Linha 108:
 
GatewayIPRange 10.7.0.0/16
 
GatewayIPRange 10.7.0.0/16
  
# BinVoucher "vale.sh"
+
BinVoucher "vale.sh"
  
# ForceVoucher yes
+
ForceVoucher yes
  
# EnablePreAuth yes
+
EnablePreAuth yes
  
 
</pre>
 
</pre>
  
DON’T FORGET TO CHANGE THE Ips IN THE FILE ABOVE!
+
NÃO ESQUEÇA DE TROCAR OS IPs no arquivo acima!
 +
 
 +
8. Vá no menu system -> startup e confira se o nodogsplash está como ENABLED
 +
 
 +
9. Crie um arquivo chamado /etc/dnsmasq2 com o seguinte conteúdo. Novamente, troque o ip abaixo pelo o mesmo usado acima, do seu roteador
 +
 
 +
<pre>
 +
# auto-generated config file from /etc/config/dhcp
 +
domain=lan
 +
address=/#/10.7.122.55:2050/nodogsplash_auth/
 +
addn-hosts=/tmp/hosts
 +
user=dnsmasq
 +
group=dnsmasq
 +
port=53530
 +
</pre>
  
6. Go to the menu system -> startup and check if nodogsplash is ENABLED
+
10. Edite o arquivo /etc/rc.local adicionando as seguintes linhas antes da linha "exit 0" (sem apagá-la). Troque novamente o ip.
  
7. Restart the router. When it is back on, the blocking of http pages should be working already.
+
<pre>
 +
/usr/sbin/dnsmasq -C /etc/dnsmasq2
  
8. Now let’s modify the FIREWALL so that https and other protocols/ports will also be blocked,
+
((sleep 60; \
 +
iptables -t nat -I ndsOUT 3 -p udp -m udp --dport 53 -j DNAT --to-destination 10.7.122.55:53530 ; \
 +
iptables -t nat -I ndsOUT 4 -p tcp -m tcp --dport 53 -j DNAT --to-destination 10.7.122.55:53530 )&)
  
<code>vi /etc/config/firewall</code>
+
exit 0
  
Comment out the following lines, including the hash symbol the beginning. It should look like this after editing.
+
</pre>
  
<pre>
+
11.Reinicie o roteador fisicamente ou usando o comando reboot.
#config forwarding
 
    #option src 'lan'
 
    #option dest 'wan'
 
</pre>
 
  
Save the file and restart the firewall
+
12. Verifique se deu tudo certo até aqui procurando pelo processo do dnsmasq2
  
 
<pre>
 
<pre>
/etc/init.d/firewall reload && /etc/init.d/firewall restart
+
ps | grep dns
 
</pre>
 
</pre>
  
Restart the router. Now the https pages should also be blocked.
+
Você deve ver algo parecido com:
 +
<pre>
 +
1049 dnsmasq  1084 S    /usr/sbin/dnsmasq -C /etc/dnsmasq2
 +
2296 dnsmasq  1128 S    /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg02411c
 +
2297 root      1080 S    /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg02411c
 +
29211 root      1184 S    grep dns
 +
</pre>
  
== Voucher system configuration ==
+
== Configurando o voucher ==
 
 
1. Let’s connect through ssh, update repos and install the vale package.
 
  
 +
1. Conectando 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/nodogsplash 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 atual tal como às 09h48min de 29 de dezembro 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 de saída para internet.
  • 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. Esse tutorial supõe que você sabe usar o comando vi para editar texto em arquivos que estão no roteador. Se você sabe usar o comando scp também pode editar no seu PC e subir os arquivos editados para o seu roteador.
  2. 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. apague tudo que vem depois dessa linha
  2. Agora salve o arquivo e saia do editor de texto.
  3. 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 53530                                                                          
    FirewallRule allow tcp port 53530                                                                          
    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. Crie um arquivo chamado /etc/dnsmasq2 com o seguinte conteúdo. Novamente, troque o ip abaixo pelo o mesmo usado acima, do seu roteador
# auto-generated config file from /etc/config/dhcp
domain=lan
address=/#/10.7.122.55:2050/nodogsplash_auth/
addn-hosts=/tmp/hosts
user=dnsmasq
group=dnsmasq
port=53530
  1. Edite o arquivo /etc/rc.local adicionando as seguintes linhas antes da linha "exit 0" (sem apagá-la). Troque novamente o ip.
/usr/sbin/dnsmasq -C /etc/dnsmasq2

((sleep 60; \
iptables -t nat -I ndsOUT 3 -p udp -m udp --dport 53 -j DNAT --to-destination 10.7.122.55:53530 ; \
iptables -t nat -I ndsOUT 4 -p tcp -m tcp --dport 53 -j DNAT --to-destination 10.7.122.55:53530 )&)

exit 0

11.Reinicie o roteador fisicamente ou usando o comando reboot.

  1. Verifique se deu tudo certo até aqui procurando pelo processo do dnsmasq2
ps | grep dns

Você deve ver algo parecido com:

 1049 dnsmasq   1084 S    /usr/sbin/dnsmasq -C /etc/dnsmasq2
 2296 dnsmasq   1128 S    /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg02411c
 2297 root      1080 S    /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg02411c
29211 root      1184 S    grep dns

Configurando o voucher

  1. Conectando 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/nodogsplash 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