命令模式下配置树莓派的wifi

#查看网络连接情况
iwconfig
#安装命令操作包
apt-get install wireless-tools wpasupplicant firmware-realtek
#扫描无线
iwlist wlan0 scan
#生成无线配置,必须输入密码,若无密码暂时胡乱打一个。生成配置后清空密码项
wpa_passphrase SSID名称 密码
#配置样例
#network={
# ssid=”SSID名称”
# #psk=”密码”
# psk=4b7084a26fea96aaf67518820cc1151fb8f47c5fc0674cd6e877a2ecd70b596e
#}
#存入配置文件
vi /etc/wpa_supplicant/wpa_supplicant.conf
#设置自动获取ip
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
#关闭wifi
ifdown wlan0
#激活重连
ifup wlan0