I'm working on a project where a Raspberry Pi creates its own access point running a Flask server, but will not have an internet connection. I set up the iptables so that when the user tries to connect to any website, they are instead redirected to a custom HTML portal from Flask.
This mostly works, but the issue I'm having is that mobile phones, when connected, will correctly recognize the access point as "Connected, no internet." It then appears that the mobile phone will fall back to using mobile data. So if the user tries to access www.google.com, it will actually connect to Google via the mobile data. If I disable mobile data on the phone, accessing www.google.com will redirect to the Flask webpage as intended.
Since this device will not be connected to the internet, I would guess that I need some way to make the device think that it does have a valid internet connection so that it won't use mobile data. Does that sound right? And if so, how would I go about doing this? For reference, here is how I was setting up the iptables:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to destination 192.168.4.1:80
And here is my /etc/dnsmasq.conf file:
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
bogus-priv
server=/localnet/192.168.4.1
local=/localnet/
address=/#/192.168.4.1
domain=localnet
dhcp-option=3,192.168.4.1
dhcp-option=6,192.168.4.1