原本打算四天連假就可以將這塊 B+ 搞定, 然後把它放在鄉下, 透過分享器防火牆設定可以從遠端登入樹莓派的 Linux. 但是我照之前這篇作法卻一直連不上鄉下的 WiFi :
# 樹莓派的 Wifi 設定 : 使用迅捷 FW150US
用 ifconfig 指令查詢 wlan0 都只顯示 IPv6 網址, 沒有 Inet4 網址, 表示根本沒有連上 WiFi 分享器 :
pi@raspberrypi:~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:2d:74:39
inet addr:192.168.2.114 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::f6a5:9334:bd66:f9a7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1193 errors:0 dropped:3 overruns:0 frame:0
TX packets:785 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:490303 (478.8 KiB) TX bytes:88818 (86.7 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:200 errors:0 dropped:0 overruns:0 frame:0
TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16656 (16.2 KiB) TX bytes:16656 (16.2 KiB)
wlan0 Link encap:Ethernet HWaddr 08:57:00:16:87:15
inet6 addr: fe80::c953:521c:d1c:85e4/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
晚上在下面文章讀到關於 WPA 實體重複可能導致 WiFi 可能無法連線問題 :
# I can not get my WiFi connection to work (WPA 行程重複問題)
# multiple instances of wpa_supplicant after boot [Solved]
我下 ps ax 指令去查, 發現還真有多個 WPA 實體 :
pi@raspberrypi:~ $ ps ax | grep wpa_supplicant
326 ? Ss 0:00 /sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wla n0.pid -i wlan0 -D nl80211,wext -C /run/wpa_supplicant
926 pts/0 S+ 0:00 grep --color=auto wpa_supplicant
再用 killall 指令殺掉全部 WPA 實體, 這時再用 ifconfig 去看, 會發現 wlan0 不見了 :
pi@raspberrypi:~ $ sudo killall wpa_supplicant
pi@raspberrypi:~ $ ps ax | grep wpa_supplicant
943 pts/0 S+ 0:00 grep --color=auto wpa_supplicant (只剩下一個了)
pi@raspberrypi:~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:2d:74:39
inet addr:192.168.2.114 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::f6a5:9334:bd66:f9a7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:379 errors:0 dropped:0 overruns:0 frame:0
TX packets:301 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31352 (30.6 KiB) TX bytes:44102 (43.0 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:200 errors:0 dropped:0 overruns:0 frame:0
TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16656 (16.2 KiB) TX bytes:16656 (16.2 KiB)
接著以下列指令查詢無線韌體 :
pi@raspberrypi:~ $ apt-cache search firmware wireless (搜尋韌體)
ap-utils - Access Point SNMP Utils for Linux
hostap-utils - Utility programs for Host AP driver for Intersil Prism2/2.5/3
ipxe - PXE boot firmware
ipxe-qemu - PXE boot firmware - ROM images for qemu
linux-wlan-ng - utilities for wireless prism2 cards
wmaloader - firmware downloader for Linksys WMA11B media adapter
firmware-b43-installer - firmware installer for the b43 driver
firmware-b43legacy-installer - firmware installer for the b43legacy driver
atmel-firmware - Firmware for Atmel at76c50x wireless networking chips.
firmware-atheros - Binary firmware for Atheros wireless cards
firmware-ipw2x00 - Binary firmware for Intel Pro Wireless 2100, 2200 and 2915
firmware-iwlwifi - Binary firmware for Intel Wireless cards
firmware-libertas - Binary firmware for Marvell Libertas 8xxx wireless cards
firmware-realtek - Binary firmware for Realtek wired and wireless network adapters
firmware-zd1211 - binary firmware for the zd1211rw wireless driver
libertas-firmware - Firmware for Marvell's libertas wireless chip series (dummy package)
firmware-brcm80211 - Binary firmware for Broadcom 802.11 wireless cards
firmware-ralink - Binary firmware for Ralink wireless cards
firmware-ti-connectivity - Binary firmware for TI Connectivity wireless network adapters
pi@raspberrypi:~ $sudo apt-get install firmware-realtek (安裝瑞昱韌體)
以下列指令重新啟動網路介面結果還是一樣無法連上 :
pi@raspberrypi:~ $sudo /etc/init.d/networking restart
然後我又找到下列文章, 照其說明用指令手動連線 :
# Ubuntu 如何使用指令啟用無線網路 ?
$iwconfig (找無線網卡代號)
$sudo ifconfig wlan0 up (啟用無線網卡)
$sudo iwlist wlan0 scan | more (掃描附近基地台)
$sudo iwconfig wlan0 essid "EDIMAX-tony" (連線基地台)
$sudo iwconfig wlan0 12345678 (基地台密碼)
$sudo dhclient wlan0 (取得 IP)
結果還是連不上.
好吧! 那就照前一次作法重新下載安裝 8188cu 的驅動程式, 然後重開機, 結果還是連不上 :
# 樹莓派的 Wifi 設定 : 使用迅捷 FW150US
最後檢查 /etc/network/interfaces, 才發現原來 wpa-ssid 與 wpa-psk 參數的內容不是用雙引號括起來的, 而是奇怪的符號 :
pi@raspberrypi:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid ¨EDIMAX-tony¨
wpa-psk ¨123456789¨
原來如此! 我是用迷你小鍵盤編輯 interfaces 檔的, 按 Ctrl + " 鍵時都要按兩次才會出現此類似雙引號的符號, 但因為太像了看不出來, 我用筆電透過 Putty SSH 連線來檢查才發現, 經修改後重新啟動網路介面就可正常獲得 Inet 網址了 :
pi@raspberrypi:~ $ sudo nano /etc/network/interfaces (編輯檔案)
pi@raspberrypi:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "EDIMAX-tony" (正常的雙引號)
wpa-psk "1234567890" (正常的雙引號)
pi@raspberrypi:~ $ sudo /etc/init.d/networking restart (重啟網路介面)
[....] Restarting networking (via systemctl): networking.serviceWarning: Unit file of networking.service changed on disk, 'systemctl daemon-reload' recommended.
. ok
pi@raspberrypi:~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:2d:74:39
inet addr:192.168.2.114 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::f6a5:9334:bd66:f9a7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:898 errors:0 dropped:1 overruns:0 frame:0
TX packets:632 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:75720 (73.9 KiB) TX bytes:89779 (87.6 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:200 errors:0 dropped:0 overruns:0 frame:0
TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16656 (16.2 KiB) TX bytes:16656 (16.2 KiB)
wlan0 Link encap:Ethernet HWaddr 08:57:00:16:87:15
inet addr:192.168.2.115 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::fc58:61fc:b069:9a5e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:36 errors:0 dropped:50 overruns:0 frame:0
TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6524 (6.3 KiB) TX bytes:13020 (12.7 KiB)
終於搞定了! But, 到底關鍵原因是啥? 因為胡亂測試所以也說不準, 當然 SSID 帳號與密碼的雙引號是最後的障礙, 但我記得在鄉下測試時不是用迷你小鍵盤, 而是標準鍵盤, 那時所編輯的雙引號應該是正確的, 為何還是連不上? 所以我覺得重複的 WPA 實體可能是主要原因.
參考資料 :
sudo dhclient -v wlan0
iwconfig wlan0
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf:ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf:ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1
network={
ssid="Nerd"
psk="SECRET"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
}
# Wifi Config - Can't get IP Address
# Raspi wifi setup
# Problem wpa_supplicant rapsberry pi 2
# Install and configure a wireless adapter on a Raspberry Pi
# Cutting The Wire – WiFi Configuration
# 10. Raspberry Pi Installation
# ANOTHER RASPBIAN DESKTOP USER INTERFACE UPDATE
# Automatically connect a Raspberry Pi to a Wifi network
Hi, I installed the new version of raspbian and haven't found a way to properly configure my wifi. In previous versions there was a very useful tool called wpa_gui, but it seems it has been removed. How can I configure my wifi now? (with some advanced parameters, not just the password).Posts: 9Joined: Fri Feb 07, 2014 9:48 pm
by JimmyN » Thu Oct 22, 2015 7:13 pm
It's on the taskbar, right side. You'll see the little network icon. Right click on it and select "WiFi Networks Settings. Or you can edit "/etc/dhcpcd.conf" directly if you prefer the "edit it myself" method.
# Raspberry PI B+ first time Setup (1/2 Hr Process to full GUI and WIFI)
# Wifi Config - Can't get IP Address
# Raspi wifi setup
# Problem wpa_supplicant rapsberry pi 2
# Install and configure a wireless adapter on a Raspberry Pi
# Cutting The Wire – WiFi Configuration
# 10. Raspberry Pi Installation
# ANOTHER RASPBIAN DESKTOP USER INTERFACE UPDATE
# Automatically connect a Raspberry Pi to a Wifi network
# Lost network connection after apt-get update/upgrade
# Jessie wpa_gui command not found
# 樹莓派 Raspberry Pi 設定無線網路 WiFi AP,打造無線 IP 分享器
# Jessie wpa_gui command not found
# 樹莓派 Raspberry Pi 設定無線網路 WiFi AP,打造無線 IP 分享器
by JimmyN » Thu Oct 22, 2015 7:13 pm
It's on the taskbar, right side. You'll see the little network icon. Right click on it and select "WiFi Networks Settings. Or you can edit "/etc/dhcpcd.conf" directly if you prefer the "edit it myself" method.
# Raspberry PI B+ first time Setup (1/2 Hr Process to full GUI and WIFI)
太感謝你了!!!
回覆刪除請問Raspberry Pi B
回覆刪除不外接任何無線設備
可以直接連wifi嗎?
只有 Pi 3, Pi zero W 等內建 WIFI 的板子才可以不插網卡直連喔.
回覆刪除我的狀況跟你不太一樣
回覆刪除我是有抓到無線ap (手機熱點)
也有取得配發的ip (192.168.1.234)
還可以指定配發的ip (192.168.1.199)
但網頁就是連不到
外部的ip和無線ap都ping不到
而在同一無線ap所配發的設備(如nb)卻都可以ping到Pi3
怪哉~~~
查了多數的網頁都說取得ip即可上網
我的例子顯然不是如此
只好繼續努力!!
Dear rusy,
回覆刪除我手上約 9 片各式樹莓派只要取得 ip 即可上網, 用連到同一基地台的電腦即可 ping 到樹莓派, 用樹莓派瀏覽器可連線 yahoo 等. 如果要從外網連線到樹莓派必須在路由器上打開虛擬主機才行.
感謝撥冗指導,nat設定好像蠻複雜的
回覆刪除暫時還沒有這類需求!!
目前我手上這台Pi3狀況依舊還是無法透過wifi上網~~~
有人建議我要先做system update
可惜我現在wifi部份設定可能有誤
出不去啊!
其實我一開始玩Pi3是先玩KODI的
可以上網看Youtube熱門影片
酷得很,
所以硬體沒問題!
後來想把自己的java程式放上去玩看看
因此另外用Raspbian並接上RJ45
程式也可以跑可以連線抓其它設備資訊!
之後再設定wifi就發現沒法用了
只能抓到ap配發的ip
卻連gateway和同一網段的nb都ping不到
但nb卻以ping到Pi3
(show第一行後就停在那很久很久....)
怪哉~~~
anyway,我會繼續努力的!
重燒韌體看看.
回覆刪除回覆"wifi連不上外網"問題的後續狀況,
回覆刪除有抓到問題了!
原本上網查很多人都建議修改
/etc/network/interfaces
並且一併修改
/etc/resolv.conf
但我試了二三天仍是沒有改變
其中/etc/resolv.conf內容在重啟wlan0後又打回原形
認真一看才知這個檔內容是自動做出來的
著實訥悶許久為何一堆人都說要改這個檔?
倒是後來我ping熱點gateway有通了(是我先前記錯嗎?)
但同一網段的nb還是ping不到(nb仍可以ping到Pi3)
只是從回應的訊息中看出點端倪
原來是用eth0(RJ45)的ip去ping另一台nb
我把eth0關掉後再用瀏灠器上網即ok了!
sudo ifdown eth0
linux是我讀書時後玩的
那時候能用光碟開機已經是很大噱頭了
工作頭幾年還有機會摸一下HP-UNIX
後來換了工作單位就一直待在windows下
linux反倒生疏很多很多
連vi指令一個也記不起來
真是....老了!!
只好不恥下問再請教大家該如何改善設定呢?
希望是能夠像我的nb一樣
開wifi時就連預設ap,不用動到RJ45網路設定
謝謝大家!
繼續回覆"wifi連不上外網"問題的後續狀況,
回覆刪除上個週末趁著颱風天認真再研究了一下
發現是/etc/network/interfaces設定問題
我在這個設定檔裡加入了指定的靜態ip
所以才會讓wifi即便抓到分配的ip也上不了網
取消後就正常了!
其實,rpi3新版Rasbian已經有良好介面讓我們去設定ip了
我先前是用手動方式完成
(在/etc/network/interfaces中加入設定值)
可能因此與Rasbian機制有衝突吧(?)
故刪除原設定,再於介面上輸入指定的ip即可!
目前wifi / lan 皆可使用
但公司會掃漏洞
所以我沒同時啟用這二個網路介面!
最後,謝謝大家的幫忙與協助!
原來如此, 我也曾經設定固定 ip, 如果要在斷電或 reset 後重新連線時都擁有同一 ip, 設定靜態 ip 是必要的.
回覆刪除