4

SCENARIO

I have my headless RPi 4 running Raspbian Buster Lite setup as a NAT router, using the internal antenna wlan0 to connect to the WAN, and an external USB antenna wlan1 with its own SSID. I am achieving this using dnsmasq and hostapd. IPTABLES is setup to allow ipv4 traffic to flow between wlan0 and wlan1, thus sharing WAN traffic on wlan0 with the LAN traffic on wlan1. Connecting wlan0 to networks which only require the SSID and PSK is easy enough using wpa_cli or wpa_supplicant works fine.

THE ISSUE

Certain public WiFi APs require a web login before allowing traffic on their network. On a headless RPi, this doesn’t work so well.

BEHAVIOUR

Currently, when connecting to such a public AP, I am able to connect to their network, as when I run

ifconfig wlan0

I can see that I have been assigned an IP by the host router, but I have no internet.

If I try using w3m to try to force a load of their logon page, w3m is not able to display the page.

WHAT NEXT?

Is there a way to acknowledge the logon page with w3m or some other CLI browser?

Or, is there another way to connect to such networks using the CLI? Perhaps by assigning my mobile’s MAC address to wlan0, so that I can acknowledge the logon page on my mobile? Is that possible, and would it work? How would I do that?

UPDATE

Using lynx produced the same result.

$ lynx mcd-en.datavalet.io

Welcome to datavalet!

ACKNOWLEDGMENTS

A big THANK YOU to the community for being a great sounding board for projects like this one.

1
  • 1
    It seems you have given the answer in your question. That's not the way this site works. You should make a regular answer and accept it after two days. Only this will finish the question and it will not pop up again after months.
    – Ingo
    Commented Nov 17, 2019 at 20:38

4 Answers 4

3

If the w3m text browser does not work you can try to use the classic text browser lynx. It is also available from the Raspbian repository.

You can also use scripting for login. I have done it with curl but it has taken me some days of development. You have to analyze the HTML source pages from the login page to GET and PUT the right responses for username and password. You may also consider to use python3 with its http libraries to do the work. But because this are more general programming issues you should better ask at https://stackoverflow.com for this.

3
  • 1
    Using lynx presented the same issue as with w3m. I was able to bring up the splash page by browsing to Google. It forwarded me to a working version of the Splash page. Still couldn’t activate the OK button, but when I browsed to Google on my mobile device connected on wlan1, it forwarded me to the Splash page where I was able to tap OK and connect. I had to trigger the splash on the Pi before it would trigger on the mobile. Commented Nov 17, 2019 at 5:43
  • 1
    @SirachMatthews Please next time add additional info to your question :-)
    – Ingo
    Commented Nov 17, 2019 at 9:39
  • That was my plan. I made the comment late at night, and wanted to have a fresh mind before updating my question with better details than the limited space of the comment. Still foggy brained, but at my PC, so shall now add the details. Thanks again! Communities like this are fantastic! Commented Nov 17, 2019 at 19:24
1

BE FORWARDED TO THE SPLASH PAGE

Rather than trying to access the splash directly, try to get it to forward you to the splash page.

$ lynx www.google.com

You should be notified about loading an html file. Agreeing to the prompt will bring up the splash page in the terminal on your mobile device connected to the Pi on wlan1. The virtual keyboard may or may not be interpreted fully by lynx or w3m. With the splash screen still up, switched to a web browser on your mobile device and navigated to some known website, like www.google.com, and you should be forwarded to the splash page where you can simply tap the Accept button, thus completing the connection.

THE KEY TO CONNECTING

  1. Connect wlan0 to host network using wpa_supplicant
  2. Use w3m or lynx to navigate to some known website
  3. Accept the browser's request to forward to the splash page
  4. Connect mobile device to SSID broadcast on wlan1
  5. On mobile device, browse to a known website
  6. The splash page for the host network should appear

Once you do whatever is asked of you on the splash page, you RPi should now be connected to the host network with internet being shared on devices connected on wlan1. New devices connecting to the RPi on wlan1 will not have to acknowledge the host network's splash page until the host network's lease time expires, at which point, you should just have to repeat steps 2 to 6 above.

1

Or, is there another way to connect to such networks using the CLI? Perhaps by > assigning my mobile’s MAC address to wlan0, so that I can acknowledge the logon page on my mobile? Is that possible, and would it work? How would I do that?

I've used the reverse to get around this issue in the past, simply because changing the MAC address on my laptop is straightforward.

Find the MAC address of wlan0 on the Pi with ifconfig, change the MAC address of your other device to match, login through the splash page on that device, and connect the Pi to the network.

1
  • Thank you for your suggestion and valued input. Unfortunately, the mobile devices mentioned are Apple devices, so not as easy to change their MAC address. Commented Nov 23, 2019 at 20:56
1

On a headless system you can install browsh: that's a text frontend to Firefox. It can display pretty much any page that Firefox can, but in text mode over SSH. Don't forget to install Firefox too.

Another option is to set up X forwarding and use Firefox directly, with the graphical interface displayed on the computer which runs the SSH client. If you're using Windows (perhaps with Putty?), you can try Xming.

1
  • I am intrigued by this idea. In practice, I have found it quite challenging to find the right balance of compatibility between Firefox an browsh versions. A good idea, so thank you very much for sharing. I may have to explore further for use with future projects. Commented Nov 23, 2019 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.