24

I am using my android device as a mobile web server. I want to direct every user that connects through my portable Android hotspot to a specific wellcome page.

Does anybody know how to implement this technique in my device (I believe this is called the captive portal technique)?

Panayotis
  • 1,743
  • 1
  • 17
  • 30

4 Answers4

14

I answer my own question until someone shares some useful information on how to implement the captive portal in a non-rooted device.

At the moment I am not aware of such working solution.

Captive portal works by intercepting most network packets (using a firewall), regardless of address or port, until the user opens a browser and tries to access the web. At that time the browser is redirected to a web page which may require authentication et.c.

So for a captive portal solution to exist, many parts like a software firewall/router/webserver need to integrate and cooperate. Given the current restrictions/permissions in a non-rooted phone, I now believe that such application won't likely exist.

@mmm2006: However, if you do have a rooted device there are apps like Paywall that can do the trick for you.

You can also try to implement your own captive portal solution. It's not trivial but since Android is based on the Linux kernel, you could try something like these:

Panayotis
  • 1,743
  • 1
  • 17
  • 30
  • @Panayotis Did you find any method yet? also Paywall works for their developers and is not customizable, I do prefer open-source programs! – Amirreza Nasiri Feb 25 '15 at 02:41
  • Anyone achieved this ? If yes, then what files needs to be changed in Android Rooted Device ? – pravingaikwad07 Dec 28 '17 at 06:48
  • HI! I WANT to do the same thing, and I dont care if I need to root the device, ALSO I think that NOW with the new RFC [Captive-Portal Identification in DHCP and Router Advertisements](https://datatracker.ietf.org/doc/html/rfc8910) IT WILL be posibl – Diego Meza Jul 15 '22 at 18:49
  • I'm posting another Question to reopen the topic https://android.stackexchange.com/questions/247548/how-to-run-captive-portal-server-on-android-device-using-hotspot-softap-and-dhcp – Diego Meza Jul 15 '22 at 18:50
  • Also HERE https://stackoverflow.com/questions/72998503/run-captive-portal-server-on-android – Diego Meza Jul 15 '22 at 18:53
2

Captive Portal are now introduced in Android 11 - API Level 30 . Do have a look at the new feature . Captive Portal - API Level 30 - New Feature

Yatin
  • 2,969
  • 9
  • 34
  • 68
1

I'm not sure about doing this on android devices (I got here searching how to disable the android check for captivate), but I setup dnsmasq on a raspberry pi, operating as a WiFi access point using hostapd, so that all traffic would come to the device (and then use nginx to either offer either a default page or a domain-specific virtualhost setup).

This seems to trigger my Android 7.0 into believing there is a captivate portal (which weirdly directs me to captivate.apple.com, which shows me my default URL).

Perhaps this will help you to assess the underlying linux system components you need to implement something similar. Sorry it doesn't fully answer your question.

MrMesees
  • 1,488
  • 19
  • 27
-3

android handle captive portal from marshmallow onwards for more detail visit https://developer.android.com/reference/android/net/CaptivePortal.html

add "android.net.conn.CAPTIVE_PORTAL" intent filter in your app launcher activity

  • 1
    He wants to run a captive portal on his phone. "android.net.CaptivePortal" does not do that. – Ajay Oct 31 '16 at 17:54