3

When we travel with a laptop, we often find ourselves in an airport, train station, or other establishment which offers free Wirless network access. But - these often require, upon connection, visiting some web page to approve the proprietors' ridiculous terms/conditions in order to actually full enable the connection (i.e. actually route your IP traffic to relevant places).

Unfortunate as this situation might be, we are forced to live with it. Unfortunately, while smartphones are typically configured to load the relevant web page upon connection - many/most Linux distributions don't do this, treating these two-phase-connection WLANs as any old wireless network. So, when you then try to use your browser, or other network-based program - you can actually connect to where you want to.

Now, sometimes, these networks are "kind" enough to at least redirect HTTP traffic, so that whatever URL you used, the terms & conditions acceptance page loads. But - even this can be problematic: You might get complaints about an invalid security certificate / man-in-the-middle attack, and your browser may refused to load the page.

My question: How do I arrange, upon connecting to the WLAN (e.g. with NetworkManager or otherwise), for a web browser to be launched, to load the terms & conditions page?

Notes:

  • In my experience, the page to load is the root page on the HTTP port on the gateway machine you got in your DHCP lease. So, an answer which makes this assumption is already pretty good and maybe good enough.
  • I would be fine with a mechanism that just auto-accepts rather than loads the page in a browser window - although that is more of a programming challenge, so probably not very relevant.
  • My specific laptop runs LXQt on Lubuntu (and soon perhaps Q4OS), but I would rather have a more general answer if possible.
3
  • 1
    I don’t know about LXQt, but GNOME at least has supported sign-on pages for years — it pops up a separate window to handle whatever is required. Commented Sep 8 at 18:26
  • @StephenKitt: So, do you think I should amend the question to make it LXQt-specific? Or - can something be set up that would work for different desktop environments? Commented Sep 8 at 18:31
  • 1
    I think it’s useful as-is; there may well be a generic solution! One possibility that springs to mind is to use Firefox; it can handle sign-on pages as well. In any case, if LXQt doesn’t have built-in support for this, I imagine a solution that would work on LXQt would also work in other desktop environments. Commented Sep 8 at 18:41

1 Answer 1

1

I don't think there's a simple, generic way to solve this, there are too many possibilities to consider, e.g. are you running network mangler, what method to bring up a wifi interface are you using, does your distro use systemd (very likely these days, but not guaranteed), ...

A good starting point (assuming you have systemd, solution would need to be amended for others) is to run this script (couldn't test, not captive portals anywhere near me):

#!/usr/bin/env bash
exec 3<> /dev/tcp/www.google.com/80
echo -e "GET /generate_204 HTTP/1.0\r\nHost: www.google.com\r\n\r\n" >&3
cat <&3 | grep -q '204 No Content'
result="${PIPESTATUS[1]}"
exec 3>&-
if [[ $result -ne 0 ]]; then
  gateway=$(ip r | awk '/default/{print $3}')
  xdg-open  "http://${gateway}"
fi

Unit file shamelessly snaffled from here

[Unit]
Description=my vm service
PartOf=graphical-session.target
After=graphical-session.target

[Service]
Type=exec
Restart=no
ExecStart=/usr/bin/vmplayer /home/myuser/vmware/myVm.vmx

[Install]
WantedBy=graphical-session.target

And making it active: Finally place the unit under: $HOME/.config/systemd/user/ directory and to enable/start it you should use systemctl --user ... (also snaffled from above):

systemctl --user enable myService.service
systemctl --user start myService.service

It assumes that the portal is indeed on the gateway (quite likely in my experience). Now you need to create a systemd-service file that invokes the script when wifi comes up. It assumes that xdg-open is installed and that you have a browser that xdg-open knows about.

As I said, I don't think this can be answered generically, but this starting point is too chunky for a comment ... 😬

2
  • "Now you need to create a systemd-service file that invokes the script when wifi comes up" <- isn't there already a directory of scripts like that in Debian-based distros? if-up.d? Commented Sep 9 at 8:28
  • Which would usually be triggered before a login? As I said: it's a thought model more than an answer ... Commented Sep 9 at 19:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.