继上一篇无线网卡驱动安装后实现无线上网
***********************************************************************************************************************************
Wireless Tools 提供了一个通用的方法设置无线网络接口,最高可达WEP安全等级。虽然WEP是一种较弱的安全方式,但它也是最普遍使用的加密方式,使用iwconfig而不用wpa_supplicant
连接wep:
iwconfig
ifconfig eth1 up
iwlist eth1 scan -->搜索并显示无线网络
iwconfig eth1 channel x -->设置无线频道
iwconfig eth1 mode managed -->设置网卡模式
iwconfig eth1 ap xx:xx:xx:xx:xx:xx
iwconfig eth1 key s:12345 /iwconfig eth1 enc:3132333435(12345的hex值) -->密码(key加上前缀s:意味着它是一个ASCII密钥,否则它就是一个16进制密钥。)
iwconfig eth1 key on
iwconfig eth1 essid sychip_demo
iwconfig eth1 192.168.x.x netmask 255.255.255.0
route add default gw 192.168.x.x
ping xxx -->测试
断开wep:iwconfig eth1 enc off ( enc open 指定开放安全性(最安全) enc restricted 指定限制安全性(较不安全))
**********************************************************************************************************************************
连接wpa
Wpa_supplicant是linux系统下一个非常强大的无线网卡管理程序,http://w1.fi/wpa_supplicant/
1.编译wpa_supplicant需要用到openssl的头文件和lib,需要编译安装openssl
2.查看readme,wpa_supplicant.conf配置模板文件
proto: list of accepted protocols -->协议
# WPA = WPA/IEEE 802.11i/D3.0
# RSN = WPA2/IEEE 802.11i (also WPA2 can be used as an alias for RSN) -->WPA2
# If not set, this defaults to: WPA RSN
auth_alg:list of allowed IEEE 802.11 authentication algorithms -->认证算法
# OPEN = Open System authentication (required for WPA/WPA2)
# SHARED = Shared Key authentication (requires static WEP keys)
# LEAP = LEAP/Network EAP (only used with LEAP)
# If not set, automatic selection is used (Open System with LEAP enabled if
# LEAP is allowed as one of the EAP methods).
pairwise: list of accepted pairwise (unicast) ciphers for WPA -->单播
# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]
# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]
# NONE = Use only Group Keys (deprecated, should not be included if APs support
# pairwise keys)
# If not set, this defaults to: CCMP TKIP
group: list of accepted group (broadcast/multicast) ciphers for WPA -->广播/组播
# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]
# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]
# WEP104 = WEP (Wired Equivalent Privacy) with 104-bit key
# WEP40 = WEP (Wired Equivalent Privacy) with 40-bit key [IEEE 802.11]
# If not set, this defaults to: CCMP TKIP WEP104 WEP40
The key used in WPA-PSK mode can be entered either as 64 hex-digits, i.e.,32 bytes or as an ASCII passphrase(in which case, the real PSK will be generated using the passphrase and SSID)
wpa_cli是命令行界面下的无线网连接工具。
通过wpa_cli管理备选的网络列表。在备选网络中启用的网络,树莓派会自动试图连接。
输入sudo wpa_cli启动wpa_cli的命令行界面(必须sudo)。常用的指令如下:
status:列出目前的联网状态。
list:列出所有备选网络。目前正连接到的网络会标[CURRENT],禁用的网络会标[DISABLE]。
add_network:增加一个备选网络,输出新网络的号码(这个号码替代下文的[network_id])。注意新网络此时是禁用状态。
set_network [network_id] ssid “Your SSID”:设置无线网的名称(SSID)
set_network [network_id] key_mgmt WPA-PSK:设置无线网的加密方式为WPA-PSK/WPA2-PSK
set_network [network_id] psk “Your Password”:设置无线网的PSK密码
enable_network [network_id]:启用网络。启用后如果系统搜索到了这个网络,就会尝试连接。
disable_network [network_id]:禁用网络。
save_config:保存配置.