大网数据广告活动
服务器运维问答

systemd: how to selectively disable wpa_supplicant for a specific WLAN interface?

· 52CE 我爱测

On a Linux system with systemd and networkd I need to operate a WLAN access point on one WLAN interface, while operating further (hotplug) WLAN interfaces in normal station ("client") mode. As it turns out, wpa_supplicant.service…

问题原文

原帖链接 · TheDiveO · CC BY-SA 3.0

On a Linux system with systemd and networkd I need to operate a WLAN access point on one WLAN interface, while operating further (hotplug) WLAN interfaces in normal station ("client") mode.

As it turns out, wpa_supplicant.service goes live on all my WLAN interfaces, which would be fine, if only all these WLAN interfaces would operate in station/client mode. However, while wpa_supplicant.service serves a WLAN interface, it's not possible (anymore?) that hostapd.service operates that WLAN interface in AP access point mode.

So I want to disable wpa_supplicant.service for a specific interface only, say wls35u2. My idea was to have a [email omitted] unit that I can selectively disable, but to leave wpa_supplicant.service enabled. However, this does not seem to work or I'm doing something wrong in the [email omitted].

So, how can I disable the WPA supplicant service on a specific interface only without globally disabling it?

社区高分解答

原帖链接 · rweisse · CC BY-SA 3.0

I had the same problem. @Nproject found a nice solution. But you don't have to modify each of this procedures. Simply go to the end of the file Nproject mentioned (/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant) and modify the following if clause:

ORIGINAL

if [ "$ifwireless" = "1" ] && \
    type wpa_supplicant >/dev/null 2>&1 && \
    type wpa_cli >/dev/null 2>&1
then
        case "$reason" in
        PREINIT)        wpa_supplicant_start;;
        RECONFIGURE)    wpa_supplicant_reconfigure;;
        DEPARTED)       wpa_supplicant_stop;;
        esac
fi

Add [ "$interface" != "TheInterfaceWPASupplicantShouldBeDisabledOn" ] in this way:

MODIFIED

if [ "$ifwireless" = "1" ] && [ "$interface" != "TheInterfaceWPASupplicantShouldBeDisabledOn" ]  && \
    type wpa_supplicant >/dev/null 2>&1 && \
    type wpa_cli >/dev/null 2>&1
then
        case "$reason" in
        PREINIT)        wpa_supplicant_start;;
        RECONFIGURE)    wpa_supplicant_reconfigure;;
        DEPARTED)       wpa_supplicant_stop;;
        esac
fi

Additionally this will prevent the Network Manager (GUI) in your taskbar to show up this interface.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-08-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。