树莓派使用无线网卡
1.插入无线网卡开机 我这里用的是EDUP
2.ssh连接PI。连接方法上篇文章已讲。
3.输入命令 lsusb 查看 网卡是否准备就绪,应当看到如下类似内容
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
4.确认下 输入iwconfig
可以看到wlan0
wlan0 unassociated Nickname:"<WIFI@REALTEK>"
Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
5.如果没有wlan0就安装下,输入命令
sudo apt-get install wireless-tools wpasupplicant firmware-realtek 反正我没遇到。
6.扫描周边wifi
iwlist wlan0 scan
输出类似
wlan0 Scan completed :
Cell 01 - Address: C8:3A:35:3B:1B:A0
ESSID:"Tenda_3B1BA0"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd180050f20101000050f20401000050f20401000050f2020c00
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30140100000fac040100000fac040100000fac020c00
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Quality=36/100 Signal level=94/100
7.连接 wpa_passphrase SSID名称 密码
输出 ,成功的话输出
network={
ssid="Tenda_3B1BA0"
#psk="密码"
psk=961258880744743c1449ebbf8ac11453d0ddb832cb403a579597b9e2c5565d42
}
复制这段回显并保存到自己的配置文件
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
然后配置/etc/network/interfaces
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
pre-up wpa_supplicant -B w -D wext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
post-down killall -q wpa_supplicant
如果设置固定IP地址,配置内容如下:
allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
address 192.168.1.137
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
连接网络 sudo ifup wlan0
sudo ifdown wlan0
需要注意的是我这里输入
sudo ifup wlan0
他提示ifup: interface wlan0 already configured
但仍然无法连接网络。这里我执行
sudo ifdown wlan0 后再开启下就ok了。
发表回复