linux wifiAP热点设置

1、配置/etc/udhcpd.conf

start 192.168.1.20
end 192.168.1.50
interface wlan0
max_leases 30

option subnet 255.255.255.0
option router 192.168.1.1
option dns 8.8.8.8
option lease 8
logfile /var/log/udhcpd.log
option lease 86400 # 指定租约时间(单位:秒)
#remaining yes

2、配置/etc/hostapd.conf(在文件末尾添加)

interface=wlan0
driver=nl80211
ssid=wifi热点名
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=密码
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

其中hw_mode是wifi制式,a代表是5g,g代表2.4g,2.4G可以写:hw_mode=g

3、设置开启启动/etc/init.d/S88autowifi_AP(添加可执行权限)

#!/bin/sh
### BEGIN INIT INFO
# Provides: hostapd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
### END INIT INFO

#加载WIFI驱动
cd /lib/modules/5.10.172/
insmod rtl8188fu.ko
cd ~

#设置wlan0 IP 与udhcpd中一致
ifconfig wlan0 192.168.1.1

case "$1" in
  start)
    /usr/sbin/hostapd -B /etc/hostapd.conf
    /usr/sbin/udhcpd /etc/udhcpd.conf
    ;;
  stop)
    killall hostapd
    killall udhcpd
    ;;
  *)
    echo "Usage: /etc/init.d/autoWifiAP {start|stop}"
    exit 1
    esac
exit 0

 

posted @ 2024-07-03 19:43  *^VV^*  阅读(36)  评论(0编辑  收藏  举报