Skip to content

Instantly share code, notes, and snippets.

@robertov8
Last active November 26, 2024 11:59
Show Gist options
  • Select an option

  • Save robertov8/9a46c2f336282dcd8f72726ab75a24be to your computer and use it in GitHub Desktop.

Select an option

Save robertov8/9a46c2f336282dcd8f72726ab75a24be to your computer and use it in GitHub Desktop.
Install Hotspot + Mysql + Portal Captive + WifiDog + Authpuppy

Hotspot + Portal Captive

Dependencias

  • Header Kernel - GCC

sudo apt-get install linux-headers

  • Pacotes essenciais

sudo apt-get install build-essential

  • PHP

sudo apt-get install php5-curl php5-xsl php5-apcu

  • WifiDog

sudo apt-get install libtool automake autoconf lighttpd

  • Mysql

sudo apt-get install mysql-server -y

  • PhpmyAdmin

sudo apt-get install phpmyadmin

  • DNS

sudo apt-get install bind9 bind9-doc dnsutils

  • GIT

sudo apt-get install git

  • Desabilitando o Lighttpd

sudo update-rc.d lighttpd stop

Rede

sudo nano /etc/network/interfaces

# LOCALHOST
auto lo
iface lo inet loopback

# WAN
auto eth0
iface eth0 inet dhcp

# LAN
auto eth1
iface eth1 inet static
address 10.0.0.1
netmask 255.255.255.0
gateway 10.0.0.1

DHCP

Servidor DHCP - isc-dhcp-server

Movendo arquivo original

sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.orig

Adicionando a nova configuração

sudo nano /etc/dhcp/dhcpd.conf

authoritative;
log-facility local7;
subnet 10.0.0.0 netmask 255.255.255.0 {
	range 10.0.0.2 10.0.0.254;
	option routers 10.0.0.1;
	option broadcast-address 10.0.0.255;
	option domain-name "local";
	option domain-name-servers 10.0.0.1;	
	
	default-lease-time 600;
	max-lease-time 7200;
}

Reiniciando servidor DHCP

sudo service isc-dhcpd-server restart

Routas entre interfaces

Habilitar o encaminhamento ipv4

sudo nano /etc/sysctl.conf

net.ipv4.ip_forward=1

Habilitar imediatamente o encaminhamento ipv4

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Regras de encaminhamento via iptables

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

Salvar as configurações

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Restaura as configurações a cada reboot, antes do "exit 0"

sudo nano /etc/rc.local

iptables-restore < /etc/iptables.ipv4.nat

DNS

Movendo o arquivo original

sudo mv /etc/bind/named.conf.options /etc/bind/named.conf.options.bk

sudo nano /etc/bind/named.conf.options

options {
	directory "/var/cache/bind";

	forwarders {
		// Google Public DNS
		8.8.8.8;
		8.8.4.4;
		
		// OpenDNS servers
		208.67.222.222;
		208.67.220.220;
		
		// ADSL Router
		192.168.1.1;
	};
	
	// Security options
	listen-on port 53 { 127.0.0.1; 10.0.0.1; };
	allow-query { 127.0.0.1; 10.0.0.0/24; };
    allow-recursion { 127.0.0.1; 10.0.0.0/24; };
	allow-transfer { none; };

	dnssec-validation auto;

	auth-nxdomain no;    # conform to RFC1035
	listen-on-v6 { any; };
};

Mudar o resolv.con

sudo nano /etc/resolv.conf

nameserver 127.0.0.1

sudo service bind9 restart

WifiDog

Download do código fonte

git clone https://github.com/wifidog/wifidog-gateway.git

Gerando dependencias Configurando Compilando Instalando

./autogen.sh
./configure
make
sudo make install

Fix Bug - WifiDog não consegue encontrar o libhttpd.so.0

sudo cp /usr/local/lib/libhttpd.so.0 /usr/lib/x86_64-linux-gnu/.

Arquivo de configuração do wifidog

sudo cp wifidog-gateway/wifidog.conf /usr/local/etc/.

Html do wifidog

sudo cp wifidog-msg.html /usr/local/etc/wifidog-msg.html

Configurações Gerais

sudo nano /usr/local/etc/wifidog.conf

GatewayID MAC:DA:REDE:INTERNA

GatewayInterface eth1

AuthServer {
    Hostname 10.0.0.1
    SSLAvailable no
    Path /
}

AuthPuppy

Conferiar pacotes do Symfony Framework

wget http://sf-to.org/1.4/check.php && php check.php

Habilitando modulo rewrite

sudo a2enmod rewrite

Dowload Versão Instavel

wget https://launchpad.net/authpuppy/trunk/1.0.0-stable/+download/authpuppy-1.0.0-stable.tgz

Descomptação

tar xvzf authpuppy-<version>-<stability>_<packaging>.tgz

Movendo para pasta do padrão do apache

sudo mv authpuppy /var/www/

Movendo arquivo original

sudo mv /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf.bk

Gerando nova configuração authpuppy sudo nano /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
       ServerAdmin webmaster@localhost
       ServerName authpuppy.localhost
       ServerAlias authpuppy.test
  
       DocumentRoot /var/www/authpuppy/web
       DirectoryIndex index.php
       <Directory /var/www/authpuppy/web/>
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>
  
       Alias /sf /var/www/authpuppy/lib/vendor/symfony/data/web/sf
       <Directory "/var/www/authpuppy/lib/vendor/symfony/data/web/sf">
               AllowOverride All
               Allow from All
       </Directory>
  
       ErrorLog /var/log/apache2/authpuppy/error.log
  
       # Possible values include: debug, info, notice, warn, error, crit,
       # alert, emerg.
       LogLevel warn
  
       CustomLog /var/log/apache2/authpuppy/access.log combined
  
</VirtualHost>

Pasta contendo o log do authpuppy

sudo mkdir /var/log/apache2/authpuppy

Mudando permissão para o usário e grupo www-data

sudo chown -R www-data:www-data /var/www/authpuppy/

Criando banco, usuario e dando permissão.

mysql -uroot 
mysql> create database authpuppy;
mysql> create user 'authpuppy'@'localhost' identified by 'authpuppydev';
mysql> grant all privileges on authpuppy.* to 'authpuppy'@'localhost' with grant option;

Reiniciando o servidor apache

sudo service apache2 restart

AuthPuppy Portal

http://10.0.0.1

Database and user configuration Db type: mysql Db server: 10.0.0.1 Db name: authpuppy Db username: authpuppy Db password: authpuppydev

Plugins

  • apAuthLocalUserPlugin Authenticator from a local username / password database, and possibility for users to signup

  • apNodeExtraPlugin Add some functionnalities to nodes, geolocation, create or steal node - Google Maps

  • apNodeCustomPlugin Allows to set some options per node instead of global, like the authenticator and network policies

  • apConnectionPoliciesPlugin Manage connection policies (bandwith and duration) for the various authenticators of the system

  • apWebServicePlugin Allow to use Web Service *** Latest version 0.1.3 requires core version 0.1.2 ***

  • apStatisticsPlugin Generic report generator and default reports for the elements of the authpuppy core

  • apExternalCMSPlugin Allow to plug login and portal pages to an external content management system

@SohailAsghar236
Copy link

@robertov8 I need your help with captive portal and auth server. I am using Ruijie AP with WiFiDog Authentication. Are you active?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment