hostapd_cli 使用命令
hostapd_cli 软件介绍
1、功能介绍
hostapd_cli 是一款用作无线 AP 功能的客户端程序。它需要与 hostapd 主程序配置使用。hostapd 的使用可以参考 《hostapd 使用手册》。
注:本篇文档均是针对 SylixOS 下的 hostapd_cli 的使用说明。
2、工具使用
hostapd_cli 的编译
注意事项:
要启动 hostapd_cli ,就必须先在 hostapd 的配置文件中,指定好一个控制接口的路劲。即需要在配置文件中,对 ctrl_interface 进行设置
主要流程:
1. 配置方式一: shell 交互方式
使用此方式,可以借助 hostapd_cli 提供的交互命令与 hostapd 进行通信,从而获取当前 AP 的状态,或者对 AP 的配置进行动态修改。这种方式的启动,无需跟任何参数,直接运行 hostapd_cli 即可。如下所示:
[root@sylixos:/root]#
[root@sylixos:/root]# hostapd_cli
hostapd_cli v2.9
Copyright (c) 2004-2019, Jouni Malinen <j@w1.fi> and contributorsThis software may be distributed under the terms of the BSD license.
See README for more details.Selected interface 'wl3'Interactive mode>
>
>
>
2. 配置方式二: 带参数运行
如果不想使用第一种 shell 交互式的操作,则可以使用带参数运行 hostapd_cli 的方式去使用 hostapd_cli。如想要修改 ssid ,那在使用第一种方式时,操作如下:
如果使用第二种方式,那么可以直接跟上需要配置的内容作参数即可,使用方法如下:
3、hostapd_cli 常用 AP 操作
hostapd 可以使用 set 命令,在 hostapd 启动后,对 hostapd 配置文件,即 hostapd.conf
内所有的配置项进行配置,从而实现动态修改配置的目的。
- 使用 set 命令进行修改时,修改的内容是对应的内存里变量的内容,并不是修改 hostapd 配置文件的内容,因此在使用 set命令完成所有的配置修改后,需要使用 reload 命令将这些配置重新加载。
- 有些配置内容即使按照 set 、reload 配置后,也是无法更新的。比如隐藏 ssid 功能,此时需要再 set 命令配置完成后,先使用 disable 命令,禁用 hostapd,然后再使用 enable 启动 hostapd,从而实现配置更新。
以下是常用的一些 AP 配置操作,本节借助第二种方式进行配置说明:
[root@sylixos:/root]# hostapd_cli set ssid Test
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli reload
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli set wpa_passphrase 12345678
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli reload
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli set channel 11
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli reload
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli set ignore_broadcast_ssid 1
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli disable
Selected interface 'wl3'
OK
[root@sylixos:/root]# hostapd_cli enable
Selected interface 'wl3'
OK
注意:上述修改均不会修改 hostapd.conf 配置文件
当然对于热点的 ssid 密码及加密方式,也有一种方式可以设置完后,自动修改 hostapd.conf ,其shell 交互操作如下:
> help
commands:ping = pings hostapdmib = get MIB variables (dot1x, dot11, radius)relog = reload/truncate debug log output filestatus = show interface status infosta <addr> = get MIB variables for one stationall_sta = get MIB variables for all stationslist_sta = list all stationsnew_sta <addr> = add a new stationdeauthenticate <addr> = deauthenticate a stationdisassociate <addr> = disassociate a stationsa_query <addr> = send SA Query to a stationwps_pin <uuid> <pin> [timeout] [addr] = add WPS Enrollee PINwps_check_pin <PIN> = verify PIN checksumwps_pbc = indicate button pushed to initiate PBCwps_cancel = cancel the pending WPS operationwps_nfc_tag_read <hexdump> = report read NFC tag with WPS datawps_nfc_config_token <WPS/NDEF> = build NFC configuration tokenwps_nfc_token <WPS/NDEF/enable/disable> = manager NFC password tokenwps_ap_pin <cmd> [params..] = enable/disable AP PINwps_config <SSID> <auth> <encr> <key> = configure APwps_get_status = show current WPS statusdisassoc_imminent = send Disassociation Imminent notificationess_disassoc = send ESS Dissassociation Imminent notificationbss_tm_req = send BSS Transition Management Requestget_config = show current configurationhelp = show this usage helpinterface [ifname] = show interfaces/select interfaceraw <params..> = send unprocessed commandlevel <debug level> = change debug levellicense = show full hostapd_cli licensequit = exit hostapd_cliset <name> <value> = set runtime variablesget <name> = get runtime infoset_qos_map_set <arg,arg,...> = set QoS Map set elementsend_qos_map_conf <addr> = send QoS Map Configure framechan_switch <cs_count> <freq> [sec_channel_offset=] [center_freq1=][center_freq2=] [bandwidth=] [blocktx] [ht|vht]= initiate channel switch announcemenths20_wnm_notif <addr> <url>= send WNM-Notification Subscription Remediation Requesths20_deauth_req <addr> <code (0/1)> <Re-auth-Delay(sec)> [url]= send WNM-Notification imminent deauthentication indicationvendor <vendor id> <sub command id> [<hex formatted data>]= send vendor driver commandenable = enable hostapd on current interfacereload = reload configuration for current interfacedisable = disable hostapd on current interfaceerp_flush = drop all ERP keyslog_level [level] = show/change log verbosity levelpmksa = show PMKSA cache entriespmksa_flush = flush PMKSA cacheset_neighbor <addr> <ssid=> <nr=> [lci=] [civic=] [stat]= add AP to neighbor databaseremove_neighbor <addr> <ssid=> = remove AP from neighbor databasereq_lci <addr> = send LCI request to a stationreq_range = send FTM range requestdriver_flags = show supported driver flagsaccept_acl =Add/Delete/Show/Clear accept MAC ACLdeny_acl =Add/Delete/Show/Clear deny MAC ACLpoll_sta <addr> = poll a STA to check connectivity with a QoS null frame
>
>
>
此时,这些命令里 wps_config 命令可以用于修改无线热点的名称,密码和加密方式。命令格式如下:
hostapd_cli wps_config <new SSID> <auth> <encr> <new key>
examples:hostapd_cli wps_config testing WPA2PSK CCMP 12345678hostapd_cli wps_config "no security" OPEN NONE ""<auth> must be one of the following: OPEN WPAPSK WPA2PSK WPAPSKALL
<encr> must be one of the following: NONE WEP TKIP CCMP
注意, WPAPSKALL 是 SylixOS 添加的,原始版本的 hostapd_cli 只支持 wpa 和 wpa2,即对应 hostapd.conf 文件中的 wpa 参数只能设置为 1 和 2, 不能设置为 3。而在 Spirit 产品中,需要让 AP 同时支持 wpa 和 wpa2,因此此处添加了 WPAPSKALL 这个选项
综上,在 hostapd_cli 的命令行界面里可以使用如下命令修改 ssid 和密码,如下命令会将 hostapd 开启的无线热点的名称和密码分别修改成:EdgerOS 和 987654321。其加密信息为 CCMP 的 WPA2PSK 加密。
>wps_config EdgerOS WPA2PSK CCMP 987654321
当然,如果只想借助 hostapd_cli 修改一下 ssid 和密码,不想进入其命令操作界面,那么也可以直接在 hostapd_cli 启动时跟上面的命令即可,此时 hostapd_cli 只会去配置 ssid 和密码,不会进入命令行界面,操作如下:
[root@sylixos:/root]# hostapd_cli wps_config testAP WPAPSKALL CCMP 12345678
- 实时获取无线热点相关状态信息
获取无线热点信息以及相关状态有两种方式:
最常见的一种就是使用 hostapd_cli 提供的相关命令来获取,比如 status ,get_config 等命令。具体使用方法,可以参考上一节内容。
以下是 使用这两个命令,获取到的一个无线信息:> status state=ENABLED phy=phy0 freq=2462 num_sta_non_erp=0 num_sta_no_short_slot_time=0 num_sta_no_short_preamble=0 olbc=0 num_sta_ht_no_gf=0 num_sta_no_ht=0 num_sta_ht_20_mhz=0 num_sta_ht40_intolerant=0 olbc_ht=0 ht_op_mode=0x0 cac_time_seconds=0 cac_time_left_seconds=N/A channel=11 secondary_channel=0 ieee80211n=1 ieee80211ac=0 beacon_int=100 dtim_period=2 ht_caps_info=000e ht_mcs_bitmask=ffff0000000000000000 supported_rates=02 04 0b 16 0c 12 18 24 30 48 60 6c max_txpower=20 bss[0]=wl3 bssid[0]=20:32:33:59:28:04 ssid[0]=EdgerOS num_sta[0]=1
> get_config bssid=20:32:33:59:28:04 ssid=EdgerOS wps_state=configured passphrase=987654321 psk=d1b952932f9c3c4db8fe39930c2b88d6849a01a66a7e58a2c41f82c3724549c8 wpa=2 key_mgmt=WPA-PSK group_cipher=CCMP rsn_pairwise_cipher=CCMP >
另一种方式,是如果使用的无线网卡本身具备 proc 文件系统功能,那么也可以采用访问 proc 文件的方式去获取无线相关信息。如SylixOS 目前支持的 RTL8192EU 无线网卡,就是支持 proc 文件系统的,此时在SylixOS 下,可以使用如下方式,去获取无线网卡的相关信息:
获取射频信息:
[root@sylixos:/root]# cat /proc/net/rtl8192eu/wl3/rf_info cur_ch=11, cur_bw=0, cur_ch_offet=0 oper_ch=11, oper_bw=0, oper_ch_offet=0
获取 ap 信息:
[root@sylixos:/root]# cat /proc/net/rtl8192eu/wl3/ap_info SSID=EdgerOS sta's macaddr:20:32:33:59:28:04 cur_channel=11, cur_bwmode=0, cur_ch_offset=0 wireless_mode=0xb, rtsen=0, cts2slef=0 state=0x10, aid=0, macid=32, raid=0 qos_en=1, ht_en=1, init_rate=0 bwmode=0, ch_offset=0, sgi_20m=1,sgi_40m=1 ampdu_enable = 1 agg_enable_bitmap=0, candidate_tid_bitmap=0 ldpc_cap=0x0, stbc_cap=0x0, beamform_cap=0x0
获取发送参数信息:
[root@sylixos:/root]# cat /proc/net/rtl8192eu/wl3/tx_info_msg status=AP mode ============================== macaddr=9c:2e:a1:fa:5f:77 Tx_Data_Rate=MCS15 BW=20M,sgi=1
获取所有 STA 信息:
[root@sylixos:/root]# cat /proc/net/rtl8192eu/wl3/all_sta_info ============================== sta's macaddr:ff:ff:ff:ff:ff:ff rtsen=0, cts2slef=0 state=0x1, aid=0, macid=1, raid=0 qos_en=0, ht_en=0, init_rate=22 bwmode=0, ch_offset=0, sgi_20m=0,sgi_40m=0 ampdu_enable = 0 tx_amsdu_enable = 0 agg_enable_bitmap=0, candidate_tid_bitmap=0 sleepq_len=0 sta_xmitpriv.vo_q_qcnt=0 sta_xmitpriv.vi_q_qcnt=0 sta_xmitpriv.be_q_qcnt=0 sta_xmitpriv.bk_q_qcnt=0 capability=0x0 flags=0x0 wpa_psk=0x0 wpa2_group_cipher=0x0 wpa2_pairwise_cipher=0x0 qos_info=0x0 dot118021XPrivacy=0x4 rx_data_uc_pkts=0 rx_data_mc_pkts=0 rx_data_bc_pkts=0 rx_uc_bytes=0 rx_mc_bytes=0 rx_bc_bytes=0 rx_tp =0 (Kbps) tx_data_pkts=0 tx_bytes=0 tx_tp =0 (Kbps) ============================== ============================== sta's macaddr:00:e0:4c:b7:91:5d rtsen=0, cts2slef=0 state=0x10, aid=0, macid=32, raid=0 qos_en=1, ht_en=1, init_rate=0 bwmode=1, ch_offset=2, sgi_20m=1,sgi_40m=1 ampdu_enable = 1 tx_amsdu_enable = 0 agg_enable_bitmap=0, candidate_tid_bitmap=0 sleepq_len=0 sta_xmitpriv.vo_q_qcnt=0 sta_xmitpriv.vi_q_qcnt=0 sta_xmitpriv.be_q_qcnt=0 sta_xmitpriv.bk_q_qcnt=0 capability=0x0 flags=0x0 wpa_psk=0x0 wpa2_group_cipher=0x0 wpa2_pairwise_cipher=0x0 qos_info=0x0 dot118021XPrivacy=0x0 rx_data_uc_pkts=0 rx_data_mc_pkts=0 rx_data_bc_pkts=0 rx_uc_bytes=0 rx_mc_bytes=0 rx_bc_bytes=0 rx_tp =0 (Kbps) tx_data_pkts=0 tx_bytes=0 tx_tp =0 (Kbps) ==============================
hostapd_cli 使用命令相关推荐
- 交叉编译使用 hostapd-2.0 在开发板上开机自启动无线网卡 AP 功能
文章目录 交叉编译 使用 hostapd 使用 DHCP 分配 IP 查看状态 开机自启动 1. MDEV 配置文件 2. MDEV 执行的脚本 参考链接 交叉编译 tar xzf hostapd-2 ...
- linux rtl8723bu 蓝牙,RTL8723BU(wifi Bluetooth) 移植
源码:RTL8723BU_WiFi_linux_v4.4.2_18635_BTCOEX20151228-664a.20161006.zip 下载地址:https://download.csdn.net ...
- Hostapd的安装与使用
hostapd编译安装: 解压源码包: tar zxvf hostapd-2.0.tar.gz cd hostapd-2.0/hostapd/ cp defconfig .config 修改配置文件: ...
- RTL8723BU(wifi Bluetooth) 移植
源码:RTL8723BU_WiFi_linux_v4.4.2_18635_BTCOEX20151228-664a.20161006.zip 下载地址:https://download.csdn.net ...
- 开发调试指令大全--(博通开发调试命令)
博通开发调试命令 前言 1.命令行基本语法 1.bcm常见命令行 (1)查看软件版本信息 (2)查看无线硬件版本信息 (3)查看无线状态 (4)查看无线驱动统计信息 (5)无线驱动加载map文件信息 ...
- Wi-Fi 命令大全
# iwlist 用于对 /proc/net/wireless 文件进行分析,得出无线网卡相关信息 # iwlist wlan0 scanning 搜索当前无线网络 # iwlist wlan0 fr ...
- 详细记录丨Realtek RTL8188FU WiFi 命令编译
道阻且长,行则将至.埋头苦干,不鸣则已,一鸣惊人!加油,骚年! Hello 大家好,上篇文章我总结了 WiFi 驱动移植及内核配置的教程. 本篇文章介绍一下 WiFi 相关命令的交叉编译,希望对您能有 ...
- WiFi 信道相关的adb命令
最近遇到个问题,客户用我们的平板开启WiFi热点当做主设备分享WiFi,他们的产品作从设备.如果WiFi的信道是13的话从设备就无法连接,研究了下原来是WiFi国家码配置成US了,把WiFi国家码配置 ...
- Kubectl 常用命令, 开发人员常用k8s命令
Kubectl 常用命令: 什么是常用,我用的,就是常用的
- ECS(Linux)连接RDS,使用命令行方式连接实例
使用命令行方式连接实例 通过命令行连接RDS MySQL数据库,连接方式如下: mysql -h<连接地址> -P<端口> -u<用户名> -p -D<数据库 ...
最新文章
- 9月热文精选,为你的假期加点料
- irsend 树莓派 php,用树莓派给家用电器加上智能(红外篇)
- python变量词是什么意思_python1变量,表达式和语句
- 转:STL:string 大小(Size)和容量(Capacity)
- vue 部门tree样式_vue+Element实现tree树形数据展示
- c++如何获取文件时间_如何在Windows 10上获取文件或文件夹的所有权
- ScaleGestureDetector使用注意事项
- Tip of the day的bug
- Sql为什么连接不上服务器上的数据库
- 确定一个整数是否是2的幂
- 用JAVA实现小学四则运算
- snmp连接工具_网络管理员的5款最佳网络配置管理工具,收藏了
- 轻快pdf阅读器 电子书阅读软件电脑版
- Fluent动网格知识汇总
- ftp怎么用计算机打开 不用浏览器打开,win7 访问ftp站点 不用浏览器显示
- 直播网站html代码,怎么生成嵌入网页直播的HTML代码
- 数据模拟:利用Java模拟数据(姓名,邮箱,地址,电话等信息,时间,工资,1-10随机数)并存入mysql
- Google Cloud Platform 注册
- 几款常见蓝牙芯片整理
- Flink状态一致性检查点
热门文章
- 真正理解nodeJS,nodejs是什么,深入理解node
- 深入 Parcel架构与流程
- No serializer found for class com.yumoxuan.domain.Store and no properties discovered to create BeanS
- 听华应龙的课我会用计算机吗体会,听华应龙老师课有感
- 快速学习-Saturn作业编排
- (笔记)Spring实战_征服数据库(5)_Spring与Java持久化API
- ClassNotFound找不到 redis.clients.jedis.JedisShardInfo
- 卷积神经网络结构相关
- 使用Quick BI 制作企业数据分析报表
- 广义表详解(C语言版)