熱門文章

2014年9月19日 星期五

Raspberry pi 安裝 wireless usb 無線網卡

安裝 wireless usb 無線網卡
一、安裝驅動程式
1.更新package database
$ sudo apt-get update
2.先把usb插上去之後,輸入lsusb,查看看型號為何,找出無線網路晶片
$ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 083a:a701 Accton Technology Corp. SMCWUSBS-N3 EZ Connect N Wireless Adapter [Ralink RT3070]
3.使用 apt-cache來查看有哪些驅動
$ apt-cache search ralink
顯示
firmware-ralink - Binary firmware for Ralink wireless cards
所以這邊知道要安裝firmware-ralink
$ sudo apt-get install firmware-ralink
使用lsmod,查看看ralink有沒有被載入,使用ifconfig,看看wlan0有沒有起來
插入[閱讀全文]分隔$ sudo lsmod
使用dmesg看看韌體有沒有load進來
$ dmesg
呼叫wlan0掃瞄附近的 AP
$ sudo iwlist wlan0 scan

或是
$ sudo iwlist wlan0 scan | grep SSID

如果有掃瞄到,代表有正確的驅動起來,現在連上無線AP
安裝wpa client 驅動
$ sudo apt-get install wpasupplicant

編輯 interfaces
sudo nano /etc/network/interfaces

加入以下設定
----------------------------------------------
auto lo
iface lo inet loopback
#如果eth0 抓不到的話, 可以試著把它打開
auto eth0
iface eth0 inet dhcp
#自動開啟wlan0
auto wlan0
allow-hotplug wlan0
#使用dhcp配置
iface wlan0 inet dhcp
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
# wpa 檔案放在此
wpa-conf /etc/wpa.conf
-----------------------------------------------
新增 wpa.conf 檔
sudo nano /etc/wpa.conf

而 wpa.config 的內容如下,其中的SSID更換成要連的無線AP SSID="MyAP",而 psk 填入連線的密碼(ex:12345678)
------------------------------------------
 network={
  ssid="MyAP"
  proto=RSN
  key_mgmt=WPA-PSK
  pairwise=CCMP TKIP
  group=CCMP TKIP
  psk="12345678"
}
--------------------------------------------
不過這邊使用密碼是明碼不太好, 可以使用 wpa_passphrase 把密碼加密一下, wpa_passphrase的輸入格式如下
wpa_passphrase <ssid> [passphrase]

所以輸入
$ wpa_passphrase MyAP 12345678
就會出現
-------------------------------------------------------------------------------
 network={
  ssid="MyAp"
    #psk="12345678"
    psk=b2449175398db27f75a0790f780cdacd0cbf8529e9e29fa051bdf3248f1fd595
}
---------------------------------------------------------------------------------
再把他產生出來的 psk 這段貼入wpa.conf中就可以了
然後重新啟動網卡
$ sudo /etc/init.d/networking restart
顯示
[warn] Running /etc/init.d/networking restart is deprecated because it may not re-enable some interfaces ... (warning).
[....] Reconfiguring network interfaces...Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/78:cd:8e:83:9e:21
Sending on   LPF/wlan0/78:cd:8e:83:9e:21
Sending on   Socket/fallback
DHCPRELEASE on wlan0 to 192.168.1.1 port 67
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 192.168.1.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.104 -- renewal in 41681 seconds.
ifup: interface wlan0 already configured
done.
當一切搞定後, 重新reboot應該就可以了