I already have the captive portal working. Now the problem I have is the "authorization/login", I want the client to access the internet after passing the portal page/conditions. How do you make the connected client authorized and able to access the connection? I am using NodeJs as web server. hostapd and dnsmasq
Ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe64:8d48 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:64:8d:48 txqueuelen 1000 (Ethernet)
RX packets 795 bytes 149308 (145.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 841 bytes 153133 (149.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 20 bytes 1200 (1.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20 bytes 1200 (1.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255
ether ee:1f:08:9a:91:d0 txqueuelen 1000 (Ethernet)
RX packets 684 bytes 140824 (137.5 KiB)
RX errors 0 dropped 3 overruns 0 frame 0
TX packets 1120 bytes 188344 (183.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Hostapd
interface=wlan0
driver=nl80211
ssid=test
channel=5
hw_mode=g
macaddr_acl=0
ignore_broadcast_ssid=0
dnsmasq
interface=wlan0
dhcp-range=10.0.0.10,10.0.0.25,255.255.255.0,12h
dhcp-option=3,10.0.0.1
dhcp-option=6,10.0.0.1
server=8.8.8.8
log-queries
log-dhcp
listen-address=10.0.0.1
address=/#/10.0.0.1
bogus-priv
domain-needed
Nodejs server
const express = require("express")
const app = express();
const morgan = require("morgan");
const path = require("path");
app.use(morgan("dev"))
const indexPath = path.join(__dirname+"/index.html");
app.get('/generate_204', (req, res)=> {
console.log('generate 204 hit');
res.statusCode = 302;
res.setHeader("Location", "/");
res.end();
});
app.get("/", (req,res)=>{
res.sendFile(indexPath);
res.status(200);
});
app.listen("80",()=>{
console.log("Server listen on ",80)
});
Iptables
# Generated by iptables-save v1.8.8 (nf_tables) on Sun Sep 11 18:09:51
2022
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -i wlan0 -j ACCEPT
COMMIT
# Completed on Sun Sep 11 18:09:51 2022
# Generated by iptables-save v1.8.8 (nf_tables) on Sun Sep 11 18:09:51 2022
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Sun Sep 11 18:09:51 2022
sorry for the english I'm using google translate