from:http://blog.csdn.net/sparksalmon/article/details/8445287
最近一直在开发机顶盒上的无线功能,把这一段的经验记录下来,以后还有需要的时候。
硬件、驱动和系统
- USB无线网卡:ralink3070
- 驱动:ralink3070的驱动源代码
- 操作系统:linux
内核模块和工具
- 内核模块:源码编译的内核模块rt5370sta.ko
- 工具:iwconfig,iwpriv,iwlist
使用时首先加载内核模块
insmod /root/modules/rt5370sta.ko
激活无线网卡(会加载无线的默认配置文件 /etc/Wireless/RT2870STA/RT2870STA.dat,相关设置可参考资料1)
ifconfig ra0 up
无线扫描结果与无线设置
无线热点扫描
iwlist ra0 scan
无线热点信息查看与设置
iwpriv ra0 set
iwpriv ra0 show
查看无线连接状态
iwpriv ra0 connStatus
使用iwpriv设置好无线参数,如果能连接上无线,使用iwconfig就能看到刚才所连接无线的essid。
下面主要说明一下无线扫描结果与无线连接设置之间的关系
1. 认证方式:开放或者共享,密码:无
Cell 03 - Address: 00:21:27:80:88:00Protocol:802.11b/gESSID:"wlan_test"Mode:ManagedFrequency:2.437 GHz (Channel 6)Quality=94/100 Signal level=-53 dBm Noise level=-92 dBmEncryption key: offBit Rates:54 Mb/s
iwpriv ra0 set NetworkType=Infraiwpriv ra0 set AuthMode=WEPAUTOiwpriv ra0 set EncrypType=NONEiwpriv ra0 set SSID="wlan_test"
2. 认证方式:开放或者共享,密码:有,加密方式:WEP
Cell 03 - Address: 00:21:27:80:88:00Protocol:802.11b/gESSID:"wlan_test"Mode:ManagedFrequency:2.437 GHz (Channel 6)Quality=94/100 Signal level=-53 dBm Noise level=-92 dBmEncryption key: onBit Rates:54 Mb/s
iwpriv ra0 set NetworkType=Infraiwpriv ra0 set AuthMode=WEPAUTOiwpriv ra0 set EncrypType=WEPiwpriv ra0 set SSID="wlan_test"
3. 认证方式:WPAPSK,加密方式:TKIP
Cell 03 - Address: 00:21:27:80:88:00Protocol:802.11b/gESSID:"wlan_test"Mode:ManagedFrequency:2.437 GHz (Channel 6)Quality=100/100 Signal level=-17 dBm Noise level=-92 dBmEncryption key: onBit Rates:54 Mb/sIE: WPA Version 1Group Cipher : TKIPPairwise Ciphers (1) : TKIPAuthentication Suites (1) : PSK
iwpriv ra0 set NetworkType=Infraiwpriv ra0 set AuthMode=WPAPSKiwpriv ra0 set EncrypType=TKIPiwpriv ra0 set SSID="wlan_test"iwpriv ra0 set WPAPSK="12345678"
4. 认证方式:WPAPSK,加密方式:AES
Cell 03 - Address: 00:21:27:80:88:00Protocol:802.11b/gESSID:"wlan_test"Mode:ManagedFrequency:2.437 GHz (Channel 6)Quality=100/100 Signal level=-15 dBm Noise level=-92 dBmEncryption key: onBit Rates:54 Mb/sIE: WPA Version 1Group Cipher : CCMPPairwise Ciphers (1) : CCMPAuthentication Suites (1) : PSK
iwpriv ra0 set NetworkType=Infraiwpriv ra0 set AuthMode=WPAPSKiwpriv ra0 set EncrypType=AESiwpriv ra0 set SSID="wlan_test"iwpriv ra0 set WPAPSK="12345678"
5. 认证方式:WPA2PSK,加密方式:TKIP
Cell 03 - Address: 00:21:27:80:88:00Protocol:802.11b/gESSID:"wlan_test"Mode:ManagedFrequency:2.437 GHz (Channel 6)Quality=100/100 Signal level=-17 dBm Noise level=-92 dBmEncryption key: onBit Rates:54 Mb/sIE: IEEE 802.11i/WPA2 Version 1Group Cipher : TKIPPairwise Ciphers (1) : TKIPAuthentication Suites (1) : PSKPreauthentication Supported
iwpriv ra0 set NetworkType=Infraiwpriv ra0 set AuthMode=WPA2PSKiwpriv ra0 set EncrypType=TKIPiwpriv ra0 set SSID="wlan_test"iwpriv ra0 set WPAPSK="12345678"
6. 认证方式:WPA2PSK,加密方式:AES
Cell 03 - Address: 00:21:27:80:88:00Protocol:802.11b/gESSID:"wlan_test"Mode:ManagedFrequency:2.437 GHz (Channel 6)Quality=100/100 Signal level=-17 dBm Noise level=-92 dBmEncryption key: onBit Rates:54 Mb/sIE: IEEE 802.11i/WPA2 Version 1Group Cipher : CCMPPairwise Ciphers (1) : CCMPAuthentication Suites (1) : PSKPreauthentication Supported
iwpriv ra0 set NetworkType=Infraiwpriv ra0 set AuthMode=WPA2PSKiwpriv ra0 set EncrypType=AESiwpriv ra0 set SSID="wlan_test"iwpriv ra0 set WPAPSK="12345678"
7. 认证方式:自动(WPAPSK/WPA2PSK),加密方式:自动(AES或TKIP)
Cell 04 - Address: 00:21:27:80:88:00Protocol:802.11b/gESSID:"wlan_test"Mode:ManagedFrequency:2.437 GHz (Channel 6)Quality=100/100 Signal level=-47 dBm Noise level=-92 dBmEncryption key: onBit Rates:54 Mb/sIE: WPA Version 1Group Cipher : TKIPPairwise Ciphers (2) : TKIP CCMPAuthentication Suites (1) : PSKIE: IEEE 802.11i/WPA2 Version 1Group Cipher : TKIPPairwise Ciphers (2) : TKIP CCMPAuthentication Suites (1) : PSKPreauthentication Supported
注意事项
1. 无线热点之间切换的问题
如果已经连接上一个无线热点,切换到另一个时,直接通过iwpriv设置,新无线不会生效。
我通过调用iwconfig ra0 essid off解决了这个问题,不知道是否合适,有待进一步的查找资料和验证。
2. 路由的问题
开机设置了有线连接的默认路由,当无线连接后,也设置了一个默认路由
两个默认的路由网段一样时,会导致不插网线,但连上无线时,ping不通无线路由器。
删除之前的默认路由,或者关闭eth0能解决问题,但还是要注意无线网卡和有线网卡共同工作时可能会出现问题。