WIFIonICE

Posted on Thu 15 June 2017 in linux

If you are a commuter or just travel frequently with ICEs through Germany you may enjoy the free WiFi which is available since 2017. However, before you will be able to access the WiFi on the train you need to open the landing page with a webbrowser to confirm the ToS. The annoying part of this is that during this time all opened applications will fail to access the Internet and will complain about a wrong certificate due to the forced redirection to the landing page. This makes sense from a security point of view, but for usability reasons these popup windows are annoying. To circumvent this behaviour the NetworkManager can be used to automatically join the WIFIonICE network without any manual actions.

NetworkManager Setup

In the first step, make sure that the network manager is installed (it should be installed by default if you are using gnome as desktop environment). Additionally, make sure that curl is installed to open webpages from command line.

Then, create the wifionice.sh script in the /etc/NetworkManager/dispatcher.d/ directory with the following content:

Updated script because landing page URL was changed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

interface=$1
status=$2

# essid when script should be called
ESSID="WIFIonICE"

# interface for which script should be called
INTERFACE="wlp1s0"

# url login page
URL="http://www.wifionice.de/de/"

if [ "${interface}" = "${INTERFACE}" ]; then
    # get current essid
    essid=$(iwgetid -r)

    if [ "${essid}" == "${ESSID}" ]; then
        case "${status}" in
            up)
                logger Login to WIFI on ICE
                curl --silent ${URL}?login > /dev/null
                ;;
            down)
                logger Logout from WIFI on ICE
                curl --silent ${URL}?logout > /dev/null
                ;;
        esac
    fi
fi

Adapt the INTERFACE name to your WiFi device name.

The script must be executable and belong to the root user to be callable by the network manager:

chown root:root /etc/NetworkManager/dispatcher.d/wifionice.sh
chmod u+x /etc/NetworkManager/dispatcher.d/wifionice.sh

That's it already. Just deactivate and activate the WiFi again to see if the automatic login is working correctly. If not check the corresponding logs.