wiki地址:https://wiki.archlinux.org/title/ConnMan
配置文件路径为: /var/lib/connman
路径下目录内容如下图:
wifi_*文件夹内为wifi的配置文件settings和数据文件data,settings内容如下:
[wifi_4479a2e30e16_577234225232d3547_managed_psk]
Name=wifi名字
SSID=577234225232d3547
Frequency=5180
Favorite=true
AutoConnect=true
Modified=2024-03-22T01:56:40.680788Z
Passphrase=1234567890
IPv4.method=dhcp
IPv6.method=auto
IPv6.privacy=disabled
IPv4.DHCP.LastAddress=192.168.1.219
connmanctl指令的具体介绍就不说了,先上个help
bash
connmanctl> help
state Shows if the system is online or offline
technologies Display technologies
clock Get System Clock Properties
enable <technology>|offline Enables given technology or offline mode
disable <technology>|offline Disables given technology or offline mode
tether <technology> on|off
wifi [on|off] <ssid> <passphrase> Enable, disable tethering, set SSID and passphrase for wifi
services [<service>] Display services
--properties [<service>] (obsolete)
peers [peer] Display peers
scan <technology> Scans for new services for given technology
connect <service/peer> Connect a given service or peer
disconnect <service/peer> Disconnect a given service or peer
move-before <service> <target service> Move <service> before <target service>
move-after <service> <target service> Move <service> after <target service>
config <service> Set service configuration options
--nameservers <dns1> [<dns2>] [<dns3>]
--timeservers <ntp1> [<ntp2>] [...]
--domains <domain1> [<domain2>] [...]
--ipv6 off|auto [enable|disable|preferred]|
manual <address> <prefixlength> <gateway>
--proxy direct|auto <URL>|manual <URL1> [<URL2>] [...]
[exclude <exclude1> [<exclude2>] [...]]
--autoconnect yes|no
--ipv4 off|dhcp|manual <address> <netmask> <gateway>
--remove Remove service
monitor [off] Monitor signals from interfaces
--services [off] Monitor only services
--tech [off] Monitor only technologies
--manager [off] Monitor only manager interface
--vpnmanager [off] Monitor only VPN manager interface
--vpnconnection [off] Monitor only VPN connections
agent on|off Agent mode
vpnconnections [<connection>] Display VPN connections
vpnagent on|off VPN Agent mode
session on|off|connect|disconnect|configEnable or disable a session
--bearers <technology1> [<technology2> [...]]
--type local|internet|any
--ifname [<interface_name>]
--srciprule yes|no
peer_service register|unregister <specs> <master>
Where specs are:
bjr_query <query> bjr_response <response>
upnp_service <service> upnp_version <version>
wfd_ies <ies>
(Un)Register a Peer Service
help Show help
exit Exit
quit Quit
简单说一下主要指令
bash
# 搜索wifi
scan wifi
# 获取wifi列表
services
# 显示一个wifi状态
services wifi_4479a2e30e16_5445535431363838_managed_psk
# 注册,连接前必须先注册
agent on
# 连接
connect wifi_4479a2e30e16_5445535431363838_managed_psk
# 断开
disconnect wifi_4479a2e30e16_5445535431363838_managed_psk
# 设置自动连接
config wifi_4479a2e30e16_5445535431363838_managed_psk --autoconnect no
config wifi_4479a2e30e16_5445535431363838_managed_psk--autoconnect yes
# 移除
config wifi_4479a2e30e16_5445535431363838_managed_psk --remove
部分指令结果说明
bash
connmanctl> services
*AO eeeeeee-0-5G wifi_4479a2e30e16_5775556786756e2d322d3547_managed_psk
ZiFiT wifi_4479a2e30e16_5a69466954_managed_psk
WYY-IoT wifi_4479a2e30e16_5759592d496f54_managed_psk
wifi_4479a2e30e16_hidden_managed_none
TEST1688 wifi_4479a2e30e16_5445535431363838_managed_psk
Xiaomi_ABC7 wifi_4479a2e30e16_5869616f6d695f41424337_managed_psk
ZSYS wifi_4479a2e30e16_5a535953_managed_psk
360WiFi-9BDFFF wifi_4479a2e30e16_333630576946692d394244464646_managed_psk
ChinaUnicom-9D28 wifi_4479a2e30e16_4368696e61556e69636f6d2d39443238_managed_psk
YP wifi_4479a2e30e16_5950_managed_psk
ChinaNet-3tNs wifi_4479a2e30e16_4368696e614e65742d33744e73_managed_psk
ChinaUnicom-9D28-5G wifi_4479a2e30e16_4368696e61556e69636f6d2d394432382d3547_managed_psk
# 说明
每行名称前4个字节表示状态
第1个字母为Favorite状态
第2个字母为AutoConnect状态
第3个字母为State状态
第3个字母为空格,也不排除可能为其他
Favorite 为True时,第一个字母为 *, False时为空
AutoConnect 为True时,第二字母为 A, False时为空
State = idle 时, 为空
State = association 时,第3个字母为a
State = configuration 时,第3个字母为c
State = ready 时,第3个字母为R
State = online 时,第3个字母为O
bash
connmanctl> services wifi_4479a2e30e16_5775597559756e2d322d3547_managed_psk
/net/connman/service/wifi_4479a2e30e16_5775597559756e2d322d3547_managed_psk
Type = wifi
Security = [ psk, wps ]
State = online
Strength = 71
Favorite = True
Immutable = False
AutoConnect = True
Name = wifi名字
Ethernet = [ Method=auto, Interface=wlan0, Address=44:79:A2:E3:0E:16, MTU=1500 ]
IPv4 = [ Method=dhcp, Address=192.168.1.6, Netmask=255.255.255.0, Gateway=192.168.1.1 ]
IPv4.Configuration = [ Method=dhcp ]
IPv6 = [ Method=auto, Address=240e:3b1:f1f1:43e0:4679:a2ff:fee3:e16, PrefixLength=64, Privacy=disabled ]
IPv6.Configuration = [ Method=auto, Privacy=disabled ]
Nameservers = [ fe80::1, 192.168.1.1, fe80::1 ]
Nameservers.Configuration = [ ]
Timeservers = [ 192.168.1.1 ]
Timeservers.Configuration = [ ]
Domains = [ ]
Domains.Configuration = [ ]
Proxy = [ Method=direct ]
Proxy.Configuration = [ ]
Provider = [ ]
# 说明:
Favorite 使用config ***** --remove 指令修改
AutoConnect 使用config ***** --autoconnect no 指令修改
State 值:association->configuration->ready->online