Linux操作系統的無線網絡命令(2)
rts:指定RTS/CTS握手方式,使用RTS/CTS握手會增加額外開銷,但如果無線網絡中有隱藏無線節點或者有很多無線節點時可以提高性能。
後面的參數指定一個使用該機制的最小包的大小,如果該值等於最大包大小,則相當於禁止使用該機制。可以使用auto/off/fixed
參數。
示例:
#iwconfig eth0 rts 250
#iwconfig eth0 rts off
frag:設置發送數據包的分片大小。設置分片會增加額外開銷,但在噪聲環境下可以提高數據包的到達率。一般情況下該參數小於最大包大小,有些支持Burst模式的無線網卡可以設置大於最大包大小的值來允許Burst模式。還可以使用auto/fixed/off參數。
示例:
#iwconfig eth0 frag 512
#iwconfig eth0 frag off
key/enc[ryption]:設置無線網卡使用的加密密鑰,此處為設置WEP模式的加密key,如果要使用WPA,需要wpa_supplicant工具包。
密鑰參數可以是 XXXX-XXXX-XXXX-XXXX 或者 XXXXXXXX 格式的十六進制數值,也可以是s:xxxxxx的ASCII字符。如果在密鑰參數之前加了[index],則只是設置該索引值對應的密鑰,並不改變當前的密鑰。直接指定[index]值可以設置當前使用哪一個密鑰。指定on/off可以控制是否使用加密模式。open/restricted指定加密模式,取決於不同的無線網卡,大多數無線網卡的open模式不使用加密且允許接收沒有加密的數據包,restricted模式使用加密。可以使用多個key參數,但只有最後一個生效。
WEP密鑰可以是40bit,用10個十六進制數字或者5個ASCII字符表示,也可以是128bit,用26個十六進制數字或者13個ASCII字符表
示。
示例:
#iwconfig eth0 key 0123-4567-89
#iwconfig eth0 key [3] 0123-4567-89
#iwconfig eth0 key s:password [2]
#iwconfig eth0 key [2]
#iwconfig eth0 key open
#iwconfig eth0 key off
#iwconfig eth0 key restricted [3] 0123456789
#iwconfig eth0 key 01-23 key 45-67 [4] key [4]
power:設置無線網卡的電源管理模式。period ‘value’ 指定喚醒的周期,timeout ‘value’指定進入休眠的等待時間,這兩個參數之前可以
加min和max修飾,這些值的單位為秒,可以附加m和u來指定毫秒和微秒。off/on參數指定是否允許電源管理,all/unicast/multicast
指定允許喚醒的數據包類型。
示例:
#iwconfig eth0 power period 2
#iwconfig eth0 power 500m unicast
#iwconfig eth0 power timeout 300u all
#iwconfig eth0 power off
#iwconfig eth0 power min period 2 power max period 4
commit:提交所有的參數修改給無線網卡驅動。有些無線網卡驅動會先緩存無線網卡參數修,使用這個命令來讓無線網卡的參數修改生效。不過一般不需要使用該命令,因為無線網卡驅動最終都會是參數的修改生效,一般在debug時會用到。
-----------
iwlist eth1 scan 搜索無線網絡:
顯示搜到的網絡(此處只顯示一個):
eth1 Scan completed :
Cell 01 - Address: 00:04:E2:E3:04:FC
ESSID:"ap_demo"
Mode:Managed
Frequency:2.437 GHz
Quality:0/0 Signal level=-61 dBm Noise level=-96 dBm
Encryption key:on
Bit Rate:1 Mb/s
Bit Rate:2 Mb/s
Bit Rate:5.5 Mb/s
Bit Rate:11 Mb/s
Bit Rate:6 Mb/s
Bit Rate:9 Mb/s
Bit Rate:12 Mb/s
Bit Rate:18 Mb/s
Bit Rate:24 Mb/s
Bit Rate:36 Mb/s
Bit Rate:48 Mb/s
Bit Rate:54 Mb/s
Cell 02 ……
---------------
設置板子的channel
iwlist eth1 channel 11
--------------
設置模式:
iwconfig eth1 mode managed
通過MAC 設置AP:
iwconfig eth1 ap 00:0A:EB:CA:79:B0
連接到WEP on 的AP:
iwconfig eth1 key s:12345 等效於 iwconfig eth1 enc 3132333435(12345的hex值) (為什麼AP64bit的口令是40bit呢)
iwconfig eth1 key on
iwconfig eth1 essid sychip_demo
斷開WEP:
iwconfig eth1 enc off
查看IP:
ifconfig eth1
設置IP:
ifconfig eth1 10.3.1.74
把IP: 129.158.215.204 , netmask: 255.255.255.0分配給rh0,
# ifconfig rh0 129.158.215.204 netmask 255.255.255.0
獲取IP;
ifconfig eth1 dhcp start (從eth1走,不需要ip即可dhcp)
udhcpc -i eth1
udhcpc --help
路由處理:
若要刪除以 10. 起始的 IP 路由表中的所有路由,請鍵入:
route delete 10.*
route del default
route add -net 10.3.0.0 netmask 255.255.0.0 eth1 (eth1獲得IP之前,使用此命令顯示:No such device)