IPTables for my custom setup

Hi everyone,

Thanks for Dietpi in the first place.

I am using xu4 + cloudshell + dietpi + wlan adapter + 3g/4g cdc_ether modem for setting up a wireless hotspot. I set up the hotspot using the dietpi-software, hotspot option.

The point of my setup is to create a captive portal and using the cdc_ether is to control the device remotely.

the adapters that show up in ifconfig are

wlan0
eth0
lo


How do I set up a captive portal that pops up “Sign in to wifi” options when the user connects to my wifi.

I am new to iptables and i am not able to understand how to set it up to my requirements completely.
Direct me to any script or material on the internet that can help. The script will have to do the following

  • When a user connects, take them to the captive portal welcome page. Should work for android, apple and windows devices.
    Redirect all traffic from browser to my local webserver.
    Not allow users to access the internet through eth0, eth0 is used by me to ssh to the machine.

I tried using this and it looked like it worked a couple of times but the behaviour is not consitent.

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80
 iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80

Thanks in advance,
nsiddhu