feat: add hotspot admin panel and harden payment provisioning
build-image / build-push (push) Failing after 1m36s
build-image / build-push (push) Failing after 1m36s
This commit is contained in:
1 parent
fb3135d18f
commit
ebb2d1d792
25 files changed
+832
-686
No files matched your search
@@ -1,11 +1,5 @@
|
||||
# ============================================================
|
||||
# Página do Hotspot com botão "Pagar com PIX"
|
||||
# Envie para o MikroTik: Winbox -> Files -> pasta hotspot/
|
||||
# edite o IP abaixo antes de enviar
|
||||
# ============================================================
|
||||
# Alternativa: use a pagina padrao do hotspot e adicione o link:
|
||||
# http://SEU_IP_ZIMASOS:3000/?mac=$(mac)
|
||||
#
|
||||
# No Winbox: IP -> Hotspot -> Server -> aba HTTP ->
|
||||
# ou edite hotspot/login.html direto no Files
|
||||
# ============================================================
|
||||
# Página do hotspot INCTG
|
||||
Envie hotspot-login.html para hotspot/login.html no Winbox > Files.
|
||||
Preserve o alogin.html padrão do RouterOS, que respeita o parâmetro dst.
|
||||
O domínio padrão é https://hotspot.jf.eng.br; ajuste se necessário.
|
||||
Veja README.md para instalação, migração e validação da rede.
|
||||
+52
-70
@@ -1,80 +1,62 @@
|
||||
# ============================================================
|
||||
# pix-hotspot - Setup MikroTik hAP lite
|
||||
# WiFi de convidados isolado + Hotspot + perfis PIX
|
||||
# Importe via: /import file-name=setup-hotspot.rsc
|
||||
# (ou cole linha a linha no Terminal do Winbox)
|
||||
# ============================================================
|
||||
|
||||
# ===== EDITAR ABAIXO =====
|
||||
# INCTG - fresh installation, RouterOS 6.43+ with legacy wireless.
|
||||
# Export a backup and use Safe Mode. Do not import over an existing hotspot.
|
||||
:local guestSubnet "10.10.10.0/24"
|
||||
:local guestIP "10.10.10.1"
|
||||
:local backendIP "192.168.3.100"
|
||||
:local portalHost "hotspot.jf.eng.br"
|
||||
:local wanInterface "ether1"
|
||||
:local guestInterface "ether4"
|
||||
|
||||
# ===== 1. REDE DOS CONVIDADOS (isolada) =====
|
||||
/interface bridge add name=bridge-guest comment="REDE CONVIDADOS"
|
||||
/ip address add address=($guestIP . "/24") interface=bridge-guest
|
||||
# Abort before changes when resources conflict.
|
||||
:if ([:len [/interface bridge find name="bridge-guest"]] > 0) do={ :error "Existing guest bridge: manual migration required" }
|
||||
:if ([:len [/interface bridge port find interface=$guestInterface]] > 0) do={ :error "Guest port is in another bridge: review topology in Safe Mode" }
|
||||
:if ([:len [/ip hotspot find name="guest-hotspot"]] > 0) do={ :error "Existing guest hotspot: manual migration required" }
|
||||
:if ([:len [/ip pool find name="guest-pool"]] > 0) do={ :error "Existing guest pool" }
|
||||
:if ([:len [/ip hotspot profile find name="hs-guest"]] > 0) do={ :error "Existing hotspot profile" }
|
||||
:if ([:len [/interface wireless find name="wlan1"]] = 0) do={ :error "Legacy wlan1 is required" }
|
||||
:if ([:len [/interface find name=$wanInterface]] = 0) do={ :error "WAN not found" }
|
||||
:if ([:len [/interface find name=$guestInterface]] = 0) do={ :error "Guest interface not found" }
|
||||
|
||||
# ether4 = porta fisica dos convidados (opcional - cabo para switch guest)
|
||||
/interface bridge port add bridge=bridge-guest interface=$guestInterface comment="porta convidados"
|
||||
/interface bridge add name=bridge-guest comment="pix: guest network"
|
||||
/ip address add address=($guestIP . "/24") interface=bridge-guest comment="pix: guest gateway"
|
||||
/interface bridge port add bridge=bridge-guest interface=$guestInterface
|
||||
/interface wireless add master-interface=wlan1 name=wlan-guest ssid="Internet Gratis" mode=ap-bridge default-forwarding=no disabled=no
|
||||
/interface bridge port add bridge=bridge-guest interface=wlan-guest
|
||||
/ip pool add name=guest-pool ranges="10.10.10.10-10.10.10.50"
|
||||
/ip dhcp-server add name=guest-dhcp interface=bridge-guest address-pool=guest-pool lease-time=1h disabled=no
|
||||
/ip dhcp-server network add address=$guestSubnet gateway=$guestIP dns-server=1.1.1.1,8.8.8.8 comment="pix: DHCP"
|
||||
/ip hotspot profile add name=hs-guest hotspot-address=$guestIP html-directory=hotspot login-by=cookie,http-chap,http-pap dns-name=""
|
||||
/ip hotspot add name=guest-hotspot interface=bridge-guest address-pool=guest-pool profile=hs-guest disabled=no
|
||||
|
||||
# WiFi virtual para convidados (SSID separado)
|
||||
/interface wireless add master-interface=wlan1 name=wlan-guest ssid="Internet Gratis" mode=ap disabled=no comment="WiFi convidados"
|
||||
/interface bridge port add bridge=bridge-guest interface=wlan-guest comment="wifi convidados"
|
||||
# RouterOS rate-limit is upload/download from the client perspective.
|
||||
# Preserve existing profiles and vouchers.
|
||||
:if ([:len [/ip hotspot user profile find name="pix-1h"]] = 0) do={ /ip hotspot user profile add name=pix-1h rate-limit=1M/5M shared-users=1 }
|
||||
:if ([:len [/ip hotspot user profile find name="pix-24h"]] = 0) do={ /ip hotspot user profile add name=pix-24h rate-limit=2M/8M shared-users=1 }
|
||||
:if ([:len [/ip hotspot user profile find name="pix-7d"]] = 0) do={ /ip hotspot user profile add name=pix-7d rate-limit=3M/10M shared-users=1 }
|
||||
/ip firewall nat add chain=srcnat out-interface=$wanInterface src-address=$guestSubnet action=masquerade comment="pix: NAT"
|
||||
|
||||
# ===== 2. POOL + HOTSPOT =====
|
||||
/ip pool add name=guest-pool ranges=($guestIP . "10-")($guestIP . "50")
|
||||
/ip pool set [find name=guest-pool] ranges=("10.10.10.10-10.10.10.50")
|
||||
# Private-network guard runs before existing accepts/fasttrack.
|
||||
# Internet returns to the ordinary chain so HotSpot filtering still applies.
|
||||
/ip firewall filter add chain=pix-guest-forward dst-address=$backendIP protocol=tcp dst-port=3000 action=accept comment="pix: portal LAN"
|
||||
/ip firewall filter add chain=pix-guest-forward dst-address=192.168.0.0/16 action=drop
|
||||
/ip firewall filter add chain=pix-guest-forward dst-address=10.0.0.0/8 action=drop
|
||||
/ip firewall filter add chain=pix-guest-forward dst-address=172.16.0.0/12 action=drop
|
||||
/ip firewall filter add chain=pix-guest-forward dst-address=169.254.0.0/16 action=drop
|
||||
/ip firewall filter add chain=pix-guest-forward action=return
|
||||
/ip firewall filter add chain=forward in-interface=bridge-guest action=jump jump-target=pix-guest-forward place-before=0 comment="pix: guest isolation"
|
||||
/ip firewall filter add chain=pix-guest-input protocol=udp dst-port=53,67,64872 action=accept
|
||||
/ip firewall filter add chain=pix-guest-input protocol=tcp dst-port=53,64872-64875 action=accept
|
||||
/ip firewall filter add chain=pix-guest-input action=drop
|
||||
/ip firewall filter add chain=input in-interface=bridge-guest action=jump jump-target=pix-guest-input place-before=0 comment="pix: router guard"
|
||||
|
||||
/ip hotspot profile add name=hs-guest hotspot-interface=bridge-guest html-directory=hotspot login-by=cookie,http-chap,http-pap dns-name="" comment="perfil hotspot convidados"
|
||||
/ip hotspot add name=guest-hotspot interface=bridge-guest address-pool=guest-pool profile=hs-guest lease-time=1h disabled=no
|
||||
|
||||
# ===== 3. PERFIS DE PLANO (nomes devem bater com o backend) =====
|
||||
/ip hotspot user profile remove [find name~"pix-"]
|
||||
/ip hotspot user profile add name=pix-1h rate-limit=5M/1M shared-users=1 comment="plano 1h"
|
||||
/ip hotspot user profile add name=pix-24h rate-limit=8M/2M shared-users=1 comment="plano 24h"
|
||||
/ip hotspot user profile add name=pix-7d rate-limit=10M/3M shared-users=1 comment="plano 7d"
|
||||
|
||||
# ===== 4. DNS/Internet dos convidados =====
|
||||
/ip firewall nat add chain=srcnat out-interface=$wanInterface src-address=$guestSubnet action=masquerade comment="NAT convidados"
|
||||
|
||||
# ===== 5. FIREWALL - ISOLAMENTO =====
|
||||
# Convidado pode ir: internet + backend (portal de pagamento) + DNS do hotspot
|
||||
# Convidado NAO pode: rede interna192.168.3.0/24 (seus PCs, MikroTik, etc)
|
||||
|
||||
/ip firewall filter
|
||||
# permite convidado -> backend:3000 (pagamento PIX)
|
||||
add chain=forward src-address=$guestSubnet dst-address=$backendIP protocol=tcp dst-port=3000 action=accept place-before=0 comment="guest->backend PIX"
|
||||
# permite respostas estabelecidas
|
||||
add chain=forward connection-state=established,related action=accept place-before=0 comment="estabelecidos"
|
||||
# BLOQUEIA convidado -> qualquer rede interna (exceto o backend ja aceito acima)
|
||||
add chain=forward src-address=$guestSubnet dst-address=192.168.0.0/16 action=drop comment="guest nao acessa rede interna"
|
||||
add chain=forward src-address=$guestSubnet dst-address=10.0.0.0/8 action=drop comment="guest nao acessa10.x"
|
||||
add chain=forward src-address=$guestSubnet dst-address=172.16.0.0/12 action=drop comment="guest nao acessa172.x"
|
||||
# gerenciao MikroTik pelo lado guest = bloqueado
|
||||
add chain=input src-address=$guestSubnet dst-address=$guestIP action=drop comment="guest nao gerencia o MikroTik"
|
||||
add chain=input src-address=$guestSubnet action=drop comment="guest so usa hotspot"
|
||||
|
||||
# ===== 6. WALLED GARDEN (portal antes do login) =====
|
||||
# Portal publico (Cloudflare) - necessario para o convidado abrir o portal
|
||||
# antes de autenticar. As faixas cobrem os IPs anycast usados pelo dominio.
|
||||
/ip hotspot walled-garden ip
|
||||
add dst-address=104.16.0.0/13 dst-port=443 protocol=tcp action=accept comment="pix-portal-cloudflare"
|
||||
add dst-address=172.64.0.0/13 dst-port=443 protocol=tcp action=accept comment="pix-portal-cloudflare"
|
||||
|
||||
# Portal local (fallback, caso use o backend direto na LAN)
|
||||
/ip hotspot walled-garden ip
|
||||
add dst-address=192.168.3.100 dst-port=3000 protocol=tcp action=accept comment="pix: portal pagamento"
|
||||
|
||||
# ===== 6.1 PAGINA DE LOGIN CUSTOMIZADA =====
|
||||
# Substituir hotspot/login.html e hotspot/alogin.html pelo arquivo
|
||||
# mikrotik/hotspot-login.html (redireciona para o portal INCTG).
|
||||
# Via FTP:
|
||||
# curl -T hotspot-login.html ftp://USER:[email protected]/hotspot/login.html
|
||||
# curl -T hotspot-login.html ftp://USER:[email protected]/hotspot/alogin.html
|
||||
|
||||
# ===== 7. LIMPA HOTSPOT ANTIGO (se houver) =====
|
||||
/ip hotspot user remove [find where comment~"pix"]
|
||||
|
||||
:log info "pix-hotspot: setup de rede convidados concluido"
|
||||
# Restrict pre-login exception to the portal host, not all Cloudflare IPs.
|
||||
/ip hotspot walled-garden ip add dst-host=$portalHost dst-port=443 protocol=tcp action=accept comment="pix: public portal"
|
||||
/ip hotspot walled-garden ip add dst-address=$backendIP dst-port=3000 protocol=tcp action=accept comment="pix: local portal"
|
||||
# HotSpot is IPv4-only: prevent an IPv6 path around authentication.
|
||||
:do {
|
||||
/ipv6 firewall filter add chain=forward in-interface=bridge-guest action=drop place-before=0 comment="pix: block guest IPv6"
|
||||
/ipv6 firewall filter add chain=input in-interface=bridge-guest action=drop place-before=0 comment="pix: block guest IPv6 management"
|
||||
} on-error={ :log warning "pix: verify guest network has no IPv6 connectivity" }
|
||||
# Copy hotspot-login.html ONLY to hotspot/login.html; keep stock alogin.html
|
||||
# so the login dst parameter is honored. Restrict API service to backend LAN IP.
|
||||
:log info "pix-hotspot: setup complete; validate DHCP, DNS, login and isolation"
|
||||
Reference in new issue
Block a user