使用busybox中的udhcpd工具实现WIFI热点

主板:Hisi3516CV500

WIFI模块:RTL8723BU

一、使能设备的DHCP功能

1、进入内核,开启DHCP功能,配置如下:

       Networking --->

       [*]Networking support

           Networking options --->

              <*>Packet socket

              [*]   IP:DHCP support

              [*]Network packet filtering(replaces ipchains)

2、进入BusyBox,开启dhcp功能,配置如下:

       Networking Utilities --->

          udhcp Server/Client --->

             [*]udhcp Server(udhcpd)

             [*]udhcp Client(udhcpc)

3、编译BusyBox,得到busybox二进制文件,将该文件拷贝到系统的/bin文件中。

4、进入系统的/bin文件,执行如下命令:

ln -s busybox udhcpd

ln -s busybox udhcpc

5、拷贝busybox里的examples/udhcp/udhcpd.conf文件到板子中,根据自己的时间网卡情况,修改udhcpd.conf文件。

二、编译hostapd工具

1、下载wpa_supplicant源码,地址:https://download.csdn.net/download/itolddd9720/10969939

解压wpa_supplicant_hostapd文件夹下的wpa_supplicant_8_kk_4.4_rtw_r25669.20171213.tar.gz文件。

2、进入wpa_supplicant_8_kk_4.4_rtw_r25669.20171213/hostapd,修改Makefile里的编译器,之后执行make,得到hostapd工具,放入设备中。

3、在板子中创建hostapd.conf文件,填入如下内容:

#sets the wifi interface to use, is wlan1 in most cases
interface=wlan1
#driver to use, nl80211 works in most cases
driver=nl80211
#sets the ssid of the virtual wifi access point
ssid=hi3516
#sets the mode of wifi, depends upon the devices you will be using. It can be a,b,g,n. Setting to g ensures backward compatiblity.
hw_mode=g
#sets the channel for your wifi
channel=6
#macaddr_acl sets options for mac address filtering. 0 means “accept unless in deny list”
macaddr_acl=0
#setting ignore_broadcast_ssid to 1 will disable the broadcasting of ssid
ignore_broadcast_ssid=0
#Sets authentication algorithm
#1 - only open system authentication
#2 - both open system authentication and shared key authentication
auth_algs=1
#####Sets WPA and WPA2 authentication#####
#wpa option sets which wpa implementation to use
#1 - wpa only
#2 - wpa2 only
#3 - both
wpa=3
#sets wpa passphrase required by the clients to authenticate themselves on the network
wpa_passphrase=12345678
#sets wpa key management
wpa_key_mgmt=WPA-PSK
#sets encryption used by WPA
wpa_pairwise=TKIP
#sets encryption used by WPA2
rsn_pairwise=CCMP
保存。

三、开启设备WIFI热点

1、开启wlan1,并配置IP

ifconfig wlan1 192.168.0.1 netmask 255.255.255.0

2、开启dhcp服务器

udhcpd udhcpd.conf

3、开启wifi

hostapd hostapd.conf

 

此时WIFI已经开启,SSID是hi3516,密码12345678,手机连上去能正常获取IP。

你可能感兴趣的:(linux日常)