使用 Kubuntu 连接到公共 Wifi

使用 Kubuntu 连接到公共 Wifi

当我想用我的 Android 手机登录公共 Wifi 时,我会收到注册此 Wifi 的通知,然后它会打开我的默认浏览器,我必须在其中同意服务条款。

如果我尝试使用我的 kubuntu 机器连接到此 Wifi,它只会告诉我已连接,但无法访问互联网。

我是否需要更改某些设置或为此安装特殊程序?

答案1

同意条款页面来自 WiFi 网络所有者的强制门户。一种可能的解决方案是添加/etc/NetworkManager/dispatcher.d/90-open_captive_portal脚本ArchLinux 维基

#!/bin/sh -e
# Script to dispatch NetworkManager events
#
# Runs shows a login webpage on walled garden networks.
# See NetworkManager(8) for further documentation of the dispatcher events.

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

if [ -x "/usr/bin/logger" ]; then
    logger="/usr/bin/logger -s -t captive-portal"
else
    logger=":"
fi

wait_for_process() {
    PNAME=$1
    while [ -z "$(/usr/bin/pgrep $PNAME)" ]; do
        sleep 3;
    done
}

#launch the browser, but on boot we need to wait that nm-applet starts
start_browser() {
    local user="$1"
    local display="$2"

    export DISPLAY="$display"
    wait_for_process nm-applet

    export XAUTHORITY="/home/$user/.Xauthority"

    $logger "Running browser as '$user' with display '$display' to login in captive portal"
    sudo -u "$user" --preserve-env=DISPLAY,XAUTHORITY -H xdg-open http://capnet.elementary.io 2>&1 > /dev/null
}

# Run the right scripts
case "$2" in
    connectivity-change)
    $logger -p user.debug "dispatcher script triggered on connectivity change: $CONNECTIVITY_STATE"
    if [ "$CONNECTIVITY_STATE" = "PORTAL" ]; then
        # Match last column of who's output with ' :[at least one digit] '
        who | awk '$NF ~ /\(:[0-9]+\)/ { print $1 " " substr($NF, 2, length($NF)-2) };' | \
        while read user display; do
            start_browser $user $display || $logger -p user.err "Failed for user: '$user' display: '$display'"
        done
    fi
    ;;
    *)
    # In a down phase
    exit 0
    ;;
esac

添加脚本后,需要重新启动 NetworkManager 服务或重新启动系统。

几年前,我在 Debian 上遇到了同样的问题。简单地打开浏览器并尝试导航到某个页面是行不通的,我必须找出门户的地址作为解决方法 - 而且这种情况经常发生变化。这给了我永久的解决方案。

相关内容