前面有一篇 NanoPi – USB 網路卡 ( WiFi AP 應用 ) 真的要測試的同學應該都失敗了,因為文章內的網卡是多年前的產品使用 Ralink RT2573 晶片,雖然原生支援預設 hostapd nl80211 driver ,可是根本就買不到了。
友善之臂官網有賣 EDUP EP-N8508 USB WiFi ,使用的是 Realtek8188CUS 晶片,經過九九八十一難安裝過程如下
--
環境準備
1 2 |
# apt update # apt install git pkg-config libnl-3-dev libnl-genl-3-dev libssl-dev |
--
設定 wlan 固定 IP
1 2 3 4 5 6 7 |
# vi /etc/network/interfaces allow-hotplug wlan0 auto wlan0 iface wlan0 inet static address 172.17.1.1 netmask 255.255.255.0 |
重新啟動網路讓設定生效
1 |
# systemctl restart NetworkManager |
--
安裝支援 RTL8188 的 hostapd 版本
1 2 3 4 5 |
# cd /home/pi # git clone https://github.com/lostincynicism/hostapd-rtl8188.git # cd hostapd-rtl8188/hostapd # make # make install |
驗證是否安裝完成
1 2 3 4 5 |
root@NanoPi-NEO:/home/pi/hostapd-rtl8188/hostapd# hostapd -v hostapd v2.4 for Realtek rtl871xdrv User space daemon for IEEE 802.11 AP management, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator Copyright (c) 2002-2015, Jouni Malinen <j@w1.fi> and contributors |
--
將 wlan 脫離 NetworkManager 管理
1 2 3 4 5 |
root@NanoPi-NEO:/home/pi/hostapd-rtl8188/hostapd# nmcli dev DEVICE TYPE STATE CONNECTION eth0 ethernet connected Wired connection 1 wlan0 wifi disconnected -- lo loopback unmanaged -- |
重新啟動 NetworkManager
1 |
# systemctl restart NetworkManager |
wlan0 已經脫離 NetworkManager 管理
1 2 3 4 5 |
root@NanoPi-NEO:/home/pi/hostapd-rtl8188/hostapd# nmcli dev DEVICE TYPE STATE CONNECTION eth0 ethernet connecting (getting IP configuration) Wired connection 1 lo loopback unmanaged -- wlan0 wifi unmanaged -- |
--
hostapd.conf
1 2 3 4 5 6 7 8 9 |
vi /etc/hostapd.conf interface=wlan0 driver=nl80211 ssid=DAEGateway channel=8 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 |
啟動程式測試
1 |
# hostapd -d /etc/hostapd.conf |
如果執行訊息沒有錯誤停止,那就是已經成功完成了
--
自訂 hostapd service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# vi /lib/systemd/system/hostapd.service [Unit] Description=hostapd [Service] Type=idle Restart=on-failure RestartSec=3s ExecStart=/usr/sbin/hostapd -d /etc/hostapd.conf ExecStop=/bin/kill $MAINPID [Install] WantedBy=multi-user.target |
開機執行及啟動
1 2 |
# systemctl enable hostapd # systemctl start hostapd |
--
RT8188CUS 晶片資訊
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
root@NanoPi-NEO:~# lsusb Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 002: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub root@NanoPi-NEO:~# lsmod Module Size Used by rtl8192cu 81920 0 rtl_usb 20480 1 rtl8192cu rtl8192c_common 49152 1 rtl8192cu rtlwifi 73728 3 rtl_usb,rtl8192c_common,rtl8192cu nls_ascii 16384 1 8189es 1024000 0 brcmfmac 180224 0 brcmutil 16384 1 brcmfmac xradio_wlan 110592 0 88XXau 1753088 0 8821cu 1683456 0 g_mass_storage 16384 0 |
--
4,884 total views, 4 views today