用樹莓派開Wifi熱點



安裝軟件

首先設置軟件源:

vim /etc/apt/sources.list

查看軟件源后面的版本,如果是wheezy,需要換成jessie
wheezy是基於deb 7的版本
而現在是基於jessie

也可以直接拿這個:

deb http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contrib
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contrib

安裝:

apt install -y dnsmasq hostapd dhcpcd5

設置並開啟dhcp服務

1. 配置網卡

vim /etc/network/interfaces

將wlan0網卡的配置改成這樣,如果之前沒有wlan0的配置,則直接粘貼即可:
如果不配置這個,則dhcp配置無效

allow-hotplug wlan0
iface wlan0 inet manual

2. dhcp配置

vim /etc/dhcpcd.conf

添加這個:

interface wlan0
static ip_address=10.10.10.1/24
static routers=10.10.10.1
static domain_name_servers=10.10.10.1 8.8.8.8

3. 重啟dhcp服務

service dhcpcd restart

建議這之后重啟下樹莓派,不然dhcp不生效

熱點配置

1. 建立配置文件

vim /etc/hostapd/hostapd.conf

填入如下內容:

interface=wlan0
driver=nl80211
ssid=rpi
hw_mode=g
channel=6
wmm_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

2. 測試是否有效

/usr/sbin/hostapd /etc/hostapd/hostapd.conf

此時可搜索到熱點

3. 設置自動啟動

vim /etc/default/hostapd

改一行:

DAEMON_CONF="/etc/hostapd/hostapd.conf"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM