jonjones
Posts: 6
Joined: Mon Jan 14, 2013 5:10 pm

WiFi with captive portal

Tue Apr 02, 2013 11:34 am

Hi all,

I've set up and got working my Pi as an access point. Now I want to create a captive portal where users accept some terms and then are granted access.

I've run through this guide and it works great:\
http://aryo.info/labs/captive-portal-us ... ables.html

However, I want a 'true' captive portal which will trigger a popup on an iPhone/iPad automatically. The above tutorial forwards all on port 80 to the Pi's ip address but that hasn't fixed it.

I've also tried --dport 0:255 in the hope that this would filter all ports but still no joy.

Any help would be greatly appreciated.

Thanks
Jon

JPElectron
Posts: 1
Joined: Tue Apr 02, 2013 3:04 pm
Location: near Chicago, IL
Contact: Website

Re: WiFi with captive portal

Tue Apr 02, 2013 3:18 pm

"true captive portal which will trigger a popup on an iPhone/iPad automatically"

The way this works is if the iThing can get to this URL: http://www.apple.com/library/test/success.html
...and find the string "Success" there, then it assumes Internet access is available/working and won't popup the captive portal page.

You need to be able to prevent it from reaching that URL, via a port 80 block (so http://www.apple.com/... won't be found), or via a DNS block (so www.apple.com won't resolve)
I cannot confirm, but I speculate that the newest version of IOS also checks https://www.apple.com so that means you'd have to block port 443 too, or use the DNS block which would take care of both.

This is not a complete solution however, note that Windows devices (laptops and phone) use a slightly different method, explained here. In this case you do want to allow: dns.msftncsi.com to resolve via DNS but don't want to allow: http://www.msftncsi.com/ncsi.txt to be reachable. Then, phones will popup your captive portal page automatically, and laptops will prompt with a bubble from the system tray that reads "Additional log on information may be required. Click to open your browser."

Maco1717
Posts: 28
Joined: Mon Jun 17, 2013 3:12 pm

Re: WiFi with captive portal

Wed Jun 19, 2013 12:20 pm

Hi,
I'm trying to implement a RPI running a local web with a WiFi and as a Access Point.

I have the Local Web, Access Point done... even have the Pi capturing all http web page requestes forwarding it to the internall web page.

Now I want to be able to and Iphone, Android Phone or Windows phone to open automatically the internal web page as if it was a captive portal... but not to sure about how to do this? I've understood in general that apple.com port 80 and 443 must be redirected somewhere but how can i do this?

thanks.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: WiFi with captive portal

Wed Jun 19, 2013 12:22 pm

with iptables and/or /etc/hosts
put in /etc/hosts
<ip of Pi> apple.com
and apple.com will resolve to the IP of the raspberry Pi instead if you're using the Pi to hand out DHCP addresses as the clients will use the Pi as the DNS server.

Or find out what the IP of apple.com is, and use iptables to redirect that ip to the Pi.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

Maco1717
Posts: 28
Joined: Mon Jun 17, 2013 3:12 pm

Re: WiFi with captive portal

Wed Jun 19, 2013 4:09 pm

Ok, put the internal IP of the Pi to point to apple.com...

but sadly it's still not working been looking around and there loads if link all saying the same that they did it basically by stopping the library/test/success.html and letting apple ping back...

according to this network dump success.html returns NOT FOUND which is good but still no pop up on the Iphone.

Link to network dump in case someone can see something (wireshark)
Dump

Thanks and regards.

Maco1717
Posts: 28
Joined: Mon Jun 17, 2013 3:12 pm

Re: WiFi with captive portal

Thu Jun 27, 2013 2:08 pm

In the end desisted on trying to create a popup for mac.

but im having some problems to find what i want to do.

i want to forward any http traffic to and "captive portal"/"flash plash" but not for login just an interactive page... so that wifi hotspot will only serve that page and i want it in to scenarios one in a internal webserver and in the other case forward it to an external url the problem im getting follwing this is that when is try to go to and sub page it doesnt find it. so for instance if i go to google it will divert it to my IP but it a go to google.com/.../... it will not forward to my page.

In to other case forwarding to a URL iptables doesnt accept this only IPs.

any suggestion or guides i could follow?
thanks.

AliPK
Posts: 3
Joined: Tue Jul 02, 2013 9:37 pm

Re: WiFi with captive portal

Tue Jul 02, 2013 9:41 pm

Hi jonjones

I want to ask you, if you can tell me how you got working your Pi as an access point? Please send me a message

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: WiFi with captive portal

Wed Jul 03, 2013 1:01 am

AliPK wrote:Hi jonjones

I want to ask you, if you can tell me how you got working your Pi as an access point? Please send me a message
Have you googled yet ?
There are plenty of guides showing you how...
What WiFi adapter do you have ?
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

AliPK
Posts: 3
Joined: Tue Jul 02, 2013 9:37 pm

Re: WiFi with captive portal

Wed Jul 17, 2013 2:57 pm

SirLagz wrote:
AliPK wrote:Hi jonjones

I want to ask you, if you can tell me how you got working your Pi as an access point? Please send me a message
Have you googled yet ?
There are plenty of guides showing you how...
What WiFi adapter do you have ?
I am using iomega SPADPT08 the driver should be rt2800usb or rt2870sta. I have try both but i am getting following error message:

Line 2: invalid/unknown driver 'rt2860sta'
1 errors found in configuration file '/etc/hostapd/hostapd.conf'

i havo followed the instructions on: http://learn.adafruit.com/setting-up-a- ... l-software

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: WiFi with captive portal

Thu Jul 18, 2013 4:25 am

run lsmod and paste the output
Did you compile your own drivers for the WiFi dongle ?
If you didn't, you'll need to use nl80211 as the driver
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

AliPK
Posts: 3
Joined: Tue Jul 02, 2013 9:37 pm

Re: WiFi with captive portal

Wed Jul 24, 2013 11:22 am

SirLagz wrote:run lsmod and paste the output
Did you compile your own drivers for the WiFi dongle ?
If you didn't, you'll need to use nl80211 as the driver
output of lsmod is:
Module Size Used by
ipt_MASQUERADE 1638 1
iptable_nat 3835 1
nf_nat 16666 2 ipt_MASQUERADE,iptable_nat
nf_conntrack_ipv4 13052 4 nf_nat,iptable_nat
nf_defrag_ipv4 1335 1 nf_conntrack_ipv4
xt_state 1155 1
nf_conntrack 79069 5 ipt_MASQUERADE,nf_nat,xt_state,iptable_nat,nf_co nntrack_ipv4
iptable_filter 1485 1
ip_tables 11482 2 iptable_filter,iptable_nat
x_tables 16865 5 ip_tables,ipt_MASQUERADE,xt_state,iptable_filter ,iptable_nat
arc4 1676 2
rt2800usb 14940 0
rt2800lib 55351 1 rt2800usb
crc_ccitt 1522 1 rt2800lib
rt2x00usb 11215 1 rt2800usb
rt2x00lib 42334 3 rt2x00usb,rt2800lib,rt2800usb
mac80211 273413 3 rt2x00lib,rt2x00usb,rt2800lib
cfg80211 184163 2 mac80211,rt2x00lib
rfkill 18202 1 cfg80211
snd_bcm2835 16304 0
snd_pcm 77560 1 snd_bcm2835
snd_seq 53329 0
snd_timer 19998 2 snd_pcm,snd_seq
snd_seq_device 6438 1 snd_seq
snd 58447 5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_de vice
snd_page_alloc 5145 1 snd_pcm
leds_gpio 2235 0
led_class 3562 2 leds_gpio,rt2x00lib

i am still getting following error:
Line 2: invalid/unknown driver 'nl80211'
1 errors found in configuration file '/etc/hostapd/hostapd.conf'

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: WiFi with captive portal

Sat Jul 27, 2013 3:01 pm

Are you using hostapd from raspbian repos ?
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

Monergy
Posts: 2
Joined: Fri Aug 09, 2013 10:13 pm

Re: WiFi with captive portal

Fri Aug 09, 2013 10:21 pm

jonjones wrote:Hi all,

I've set up and got working my Pi as an access point. Now I want to create a captive portal where users accept some terms and then are granted access.

I've run through this guide and it works great:\
http://aryo.info/labs/captive-portal-us ... ables.html

However, I want a 'true' captive portal which will trigger a popup on an iPhone/iPad automatically. The above tutorial forwards all on port 80 to the Pi's ip address but that hasn't fixed it.

I've also tried --dport 0:255 in the hope that this would filter all ports but still no joy.

Any help would be greatly appreciated.

Thanks
Jon
Hi Jon

Was wondering if you ever has any success with this project?.. I would like to create something very similar.. We originally tired to do this with an Android device but we could never redirect the traffic with out configuring the connecting device... curious if you did it with the Pi?

noiseboy90
Posts: 5
Joined: Sat Oct 17, 2015 3:38 am

Re: WiFi with captive portal

Thu Nov 26, 2015 5:03 pm

did anyone get anywhere with this? sounds like this is the exact thing id like to do...

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 13 guests