您好,登錄后才能下訂單哦!
小編給大家分享一下樹莓派怎么配置成一個無線AP,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
樹莓派 RaspberryPI 2 Model B
USB Wifi
我買的USB Wifi具體信息是IDEMAC SL-1506N 無線usb網(wǎng)卡 rt5370芯片 11n網(wǎng)卡 接收器 AP
, 供參考吧。淘寶上很多。
主要包括hostapd,dnsmasq
首先插上USB Wifi
先需要在內(nèi)核中啟動NAT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
保存iptables的配置
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
編輯配置文件 /etc/network/interfaces
如果存在以下內(nèi)容,就注釋掉,像下面這個樣子
#auto wlan0 #iface wlan0 inet manual #wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
文件末尾添加以下內(nèi)容
allow-hotplug wlan0 iface wlan0 inet static address 192.168.10.1 netmask 255.255.255.0 up iptables-restore < /etc/iptables.ipv4.nat
修改/etc/default/ifplugd
成
INTERFACES="eth0" HOTPLUG_INTERFACES="eth0" ARGS="-q -f -u0 -d10 -w -I" SUSPEND_ACTION="stop"
執(zhí)行 sudo ifup wlan0
使配置生效
修改/etc/sysctl.conf
,確保其中包含
net.ipv4.ip_forward = 1
執(zhí)行sudo sysctl -p
重新加載配置
sudo apt-get install hostapd
創(chuàng)建文件/etc/hostapd/hostapd.conf
,填寫內(nèi)容
interface=wlan0 driver=nl80211 ssid=MyPI hw_mode=g channel=6 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=12345678 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP
ssid和wpa_passphrase是可以修改的。(我試過不用密碼的那種配置,但是連不上網(wǎng))
打開文件/etc/default/hostapd
,將
#DAEMON_CONF=""
修改為
DAEMON_CONF="/etc/hostapd/hostapd.conf"
運行sudo service hostapd start
,重啟hostapd服務(wù)
sudo apt-get install dnsmasq
打開配置文件/etc/dnsmasq.conf
,直接在末尾添加
no-resolv listen-address=192.168.10.1 interface=wlan0 dhcp-range=192.168.10.100,192.168.10.200,12h dhcp-option=option:router,192.168.10.1 server=114.114.114.114 server=8.8.8.8 server=8.8.4.4
保存完后,重啟dnsmasq服務(wù)
sudo service dnsmasq restart
以上是“樹莓派怎么配置成一個無線AP”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。