試用 Banana Pi R1 - 設定成無線的 AP

星期一, 19th 十二月 2016

參考網站:
Banana Pi R1 (BPi-R1) Part 3 無線router設定 講 iT
Banana Pi Router - BPi-R1 Manual for HW setup and basic router functionalities

為了能讓 Wireless AP 發送的 IP 和 LAN 的 IP 在同一個網段,所以要改用 bridge
1. 安裝 bridge-utils 套件
# apt-get install bridge-utils2. 修改網路設定
# vim /etc/network/interfaces

auto eth0.101

# dhcp configuration
iface eth0.101 inet dhcp

auto eth0.102
iface eth0.102 inet static
        address 192.168.85.1
        netmask 255.255.255.0

改成
auto eth0.101

# dhcp configuration
iface eth0.101 inet dhcp

auto eth0.102
iface eth0.102 inet manual

auto wlan0
iface wlan0 inet manual

auto br0
iface br0 inet static
        address 192.168.85.1
        netmask 255.255.255.0
        network 192.168.85.0
        bridge_waitport 0
        bridge_ports eth0.102 wlan0

3. 重新啟動網路
# service networking restart

4. 安裝 hostapd-rtl 套件
# apt-get install hostapd-rtl

5. 修改設定檔 /etc/hostapd/hostapd.conf
修改
# 介面 
bridge=br0
# SSID
ssid=BPI-R1
# 金鑰密碼
wpa_passphrase=ICanHasBananaz

6. 檢查設定檔 /etc/hostapd/hostapd.conf 設定是否正確
# /usr/sbin/hostapd -dd /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
ctrl_interface_group=0
Line 19: invalid WPA passphrase length 6 (expected 8..63)
WPA-PSK enabled, but PSK or passphrase is not configured.
2 errors found in configuration file '/etc/hostapd/hostapd.conf'
Failed to set up interface with /etc/hostapd/hostapd.conf
hostapd_init: free iface 0x82b128
Failed to initialize interface

上面的檢查結果就是密碼設的太短!

6. 設定 hostapd 啟動時會自動載入設定檔
修改 /etc/default/hostapd
# sed -i 's/^#DAEMON_CONF/DAEMON_CONF/' /etc/default/hostapd

啟動 hostapd
# service hostapd restart
[ ok ] Stopping advanced IEEE 802.11 management: hostapd.
[....] Starting advanced IEEE 802.11 management: hostapdioctl[RTL_IOCTL_HOSTAPD]: Operation not supported. ok

7. 修改 DHCP Server 設定檔
# sed -i 's/interface=eth0.102/#interface=br0/' /etc/dnsmasq.conf

8. 重新啟動 DHCP Server
# service dnsmasq restart
[ ok ] Restarting DNS forwarder and DHCP server: dnsmasq.