树莓派使用usb无线适配器
wireless adapter必须是树莓派支持的,可以到官方或者 http://shumeipai.net 查看硬件列表
两种方案,一种不行换另一种
# 方案一
## 配置网络接口
sudo nano /etc/network/interfaces
文件内容默认如下:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
修改如下:
DHCP配置:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
STATIC配置:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
## 设置WPA认证
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
修改如下:
network={
ssid="SSID名称"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="密码"
}
## 重启,wlan0会自动开启
# 方案二
## wpa认证文件
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
修改内容如下
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID名称"
proto=RSN
scan_ssid=1
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
psk="密码"
}
## 修改interfaces配置
sudo nano /etc/network/interfaces
DHCP配置:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
STATIC配置:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
## 重启
默认会自动连上可以运行 `sudo iwconfig` 查看配置或者`sudo ifconfig`查看状态