当前位置:网站首页>WiFi wpa_ Detailed description of supplicant hostpad interface
WiFi wpa_ Detailed description of supplicant hostpad interface
2022-07-05 08:00:00 【Drink more hot water-】
wpa_supplicant/hostapd yes Linux Next use as sta/ap Interface for network card operation , The project is basically completed , Organize here .
One 、wpa_supplicant part
wpa_supplicant It's a connection 、 To configure WIFI Tools for . It mainly includes two programs :wpa_supplicant And wpa_cli. The relationship between the two is server And client The relationship between . Usually , We can go through wpa_cli To carry out WIFI Configuration and connection of , If there is a special need , You can write an application to call directly wpa_supplicant Direct development of interfaces .
This article mainly talks about how to pass wpa_cli Conduct WIFI Configuration and connection of .
2. Usage method
2.1 start-up wpa_supplicant application
wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
Be careful :/etc/wpa_supplicant.conf In the document , Add the following code .
ctrl_interface=/var/run/wpa_supplicant
update_config=1
2.2 start-up wpa_cli application
wpa_cli -i wlan0 scan Search the neighborhood wifi The Internet
wpa_cli -i wlan0 scan_result Print search wifi Network results
wpa_cli -i wlan0 add_network Add a network connection
2.21 Such as If you want to connect, the encryption method is :[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] (wpa encryption ) wifi The name is :wifi_name wifi The password is :wifi_psk
wpa_cli -i wlan0 set_network 0 ssid '"wifi_name"'
wpa_cli -i wlan0 set_network 0 psk '"wifi_psk"'
wpa_cli -i wlan0 enable_network 0
2.22 If you want to connect, the encryption method is :[WEP][ESS] (wep encryption )
wifi The name is :wifi_name
wifi The password is :wifi_psk
wpa_cli -i wlan0 set_network 0 ssid '"wpa_name"'
wpa_cli -i wlan0 set_network 0 key_mgmt NONE
wpa_cli -i wlan0 set_network 0 wep_key0 '"wap_psk"'
wpa_cli -i wlan0 enable_network 0
2.23 If you want to connect, the encryption method is :[ESS] ( No encryption )
wifi The name is :wifi_name
wpa_cli -i wlan0 set_network 0 ssid '"wifi_name"'
wpa_cli -i wlan0 set_network 0 key_mgmt NONE
wpa_cli -i wlan0 enable_network 0
2.3 Distribute ip,netmask,gateway,dns
udhcpc -i wlan0 -s /etc/udhcpc.script -q
completion of enforcement , You can connect to the network .
2.4 Save connection
wpa_cli -i wlan0 save_config
2.5 disconnect
wpa_cli -i wlan0 disable_network 0
2.6 Connect to an existing connection
$ wpa_cli -i wlan0 list_network List all saved connections
$ wpa_cli -i wlan0 select_network 0 Connect the 1 A saved connection
$ wpa_cli -i wlan0 enable_network 0 Enabling section 1 A saved connection
2.7 To break off wifi
$ ifconfig wlan0 down
$ killall udhcpc
$ killall wpa_supplicant
Two 、 hostapd part
hostapd yes Host Access Point Daemon , Provide information on Linux The strength of wireless access points WPA2 Encryption and authentication .
To configure hostapd It's simple , It supports WPA2-Personal and Enterprise, Provide for the right to WPA2-Personal Unique modification of , It can make managing it more complex or simpler .
udhcpd -f /etc/wificfg/udhcpd.conf &
hostapd -t /etc/wificfg/hostapd.conf &
/*************************************************************************************************************************/
3、 ... and 、 Actual operation script :
The above is a memo written according to your usual work , Query usage ; Remember the following sta/ap The operation of , And several configuration files under embedded :
1. wpa-supplicant Common operation :
wpa_supplicant -D nl80211 -i wlan0 -c/home/ky/wpa_supplicant.conf -B
wpa_cli -i wlan0 scan
wpa_cli -i wlan0 scan_result
wpa_cli -i wlan0 add_network
wpa_cli -i wlan0 set_network 0 ssid '"ky"'
wpa_cli -i wlan0 set_network 0 psk '"12345678"'
wpa_cli -i wlan0 enable_network 0
udhcpc -i wlan0
wpa_cli -i wlan0 disable_network 0
wpa_cli -i wlan0 disable_network 1
wpa_cli -i wlan3 remove_network 0
wpa_cli -i wlan0 save_config
wpa_cli -i wlan0 list_network
wpa_cli -i wlan0 select_network 2
wpa_cli -i wlan0 enable_network 2
udhcpc -i wlan0
wpa_supplicant.conf Profile contents :
ctrl_interface=/var/run/wpa_supplicant
update_config=1
network={
ssid="hky"
psk="12345678"
}
2.hostapd Shoushun :
ap The model is relatively simple
udhcpd -f /etc/wificfg/udhcpd.conf &
hostapd -t /etc/wificfg/hostapd.conf &
udhcpd.conf Profile contents : It is similar to the router configuration interface
It is worth noting that Lease documents (lease_file ) This configuration file , Usually based on /var/tmp/ In the catalog ,WiFi AP The mode cannot be assigned IP Maybe this file was not created , use touch Just build one
start 192.168.219.2
end 192.168.219.254
interface wlan1
lease_file /etc/wificfg/udhcpd.lease
opt dns 168.95.1.1 192.168.10.2 192.168.10.10
option subnet 192.168.0.0 netmask 255.255.255.0
opt router 192.168.10.2
opt wins 192.168.10.10
option dns 129.219.13.81
option domain local
option lease 864000
hostapd.conf Profile contents : Formulated the AP Of ssid password encryption a/b/g/n Etc , Of course, the working mode can also be WiFi Module commands to change
#
# This will give you a minimal, insecure wireless network.
#
# DO NOT BE SATISFIED WITH THAT!!!
#
# A complete, well commented example configuration file is
# available here:
#
# /usr/share/doc/hostapd/hostapd.conf
#
# For more information, look here:
#
# http://wireless.kernel.org/en/users/Documentation/hostapd
# ctrl_interface=/var/run/hostapd
ctrl_interface_group=root
# Some usable default settings...
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
# Uncomment these for base WPA & WPA2 support with a pre-shared key
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# DO NOT FORGET TO SET A WPA PASSPHRASE!!
wpa_passphrase=12345678
# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211
# Customize these for your local configuration...
interface=wlan1
hw_mode=g
channel=11
ssid=ssidtest
over 了
边栏推荐
- Bootloader implementation of PIC MCU
- How to realize audit trail in particle counter software
- C WinForm [realize the previous and next selection pictures] - practice 7
- MySQL blind note common functions
- Train your dataset with yolov4
- How to excavate and research ideas from the paper
- Global and Chinese markets for medical oxygen machines 2022-2028: Research Report on technology, participants, trends, market size and share
- TCP and UDP
- Significance and requirements of semiconductor particle control
- 研究發現,跨境電商客服系統都有這五點功能!
猜你喜欢

Acwing-宠物小精灵之收服-(多维01背包+正序倒序+两种形式dp求答案)

The research found that the cross-border e-commerce customer service system has these five functions!

Consul安装

Carrier period, electrical speed, carrier period variation

Programming knowledge -- basis of C language
![Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine](/img/f9/fc4f0bbce36b3c1368d838d723b027.jpg)
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
![C WinForm [help interface - send email] - practice five](/img/2a/c4e7abe054e6fdd45acc7d297a033d.jpg)
C WinForm [help interface - send email] - practice five

Network port usage

Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
![C WinForm [get file path -- traverse folder pictures] - practical exercise 6](/img/8b/1e470de4e4ecd4fd1bb8e5cf23f466.jpg)
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
随机推荐
Temperature sensor DS18B20 principle, with STM32 routine code
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
Markdown tips
Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
Create inf module in AMI code
Halcon's practice based on shape template matching [2]
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
Explain STM32 startup file in detail
Realization of binary relation of discrete mathematics with C language and its properties
软件设计师:03-数据库系统
Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
C # joint configuration with Halcon
The firmware of the connected j-link does not support the following memory access
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
Beijing Winter Olympics opening ceremony display equipment record 3
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
Extended application of single chip microcomputer-06 independent key
Carrier period, electrical speed, carrier period variation
Global and Chinese market of digital shore durometer 2022-2028: Research Report on technology, participants, trends, market size and share
1-stm32 operation environment construction