Linux

Slackware 上的無線

  • July 9, 2013

好的,所以我終於讓我的無線在 Slackware 上工作了。麻煩的是,我真的不明白我在做什麼。我目前是 root,為了獲得無線,我首先必須:

wpa_supplicant -c/etc/wpa_supplicant.conf -Dwext -iwlan0

然後:

/etc/rc.d/rc.inet1 wlan0_start

如果我先做第二行,我會超時,沒有連接。

所以我的問題是:

  1. 有沒有更好的方法來做到這一點(配置文件之間是否存在某種衝突)?
  2. 我可以在啟動時自動執行此操作嗎?
  3. 我可以為除 root 之外的另一個帳戶自動執行此操作嗎?
bash-4.1# wpa_supplicant -c/etc/wpa_supplicant.conf -d -Dwext -iwlan0 &
[1] 2935
bash-4.1# Initializing interface 'wlan0' conf '/etc/wpa_supplicant.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant.conf'
ctrl_interface='/var/run/wpa_supplicant'
ctrl_interface_group='0'
eapol_version=1
ap_scan=1
fast_reauth=1
Priority group 10
  id=0 ssid=(##hidden##)
Priority group 0
  id=1 ssid=''
WEXT: cfg80211-based driver detected
SIOCGIWRANGE: WE(compiled)=22 WE(source)=21 enc_capa=0xf
 capabilities: key_mgmt 0xf enc 0xf flags 0x0
netlink: Operstate: linkmode=1, operstate=5
Own MAC address: (##HIDDEN##)
wpa_driver_wext_set_key: alg=0 key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=3 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_countermeasures
RSN: flushing PMKID list in the driver
Setting scan request: 0 sec 100000 usec
WPS: UUID based on MAC address - (##HIDDEN##)
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
EAPOL: Supplicant port status: Unauthorized
EAPOL: Supplicant port status: Unauthorized
ctrl_interface_group=0
Added interface wlan0
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b06 len=12
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b1a len=16
State: DISCONNECTED -> SCANNING
Starting AP scan for wildcard SSID
Scan requested (ret=0) - scan timeout 5 seconds
EAPOL: disable timer tick
EAPOL: Supplicant port status: Unauthorized
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b19 len=16
Scan results did not fit - trying larger buffer (8192 bytes)
Received 7670 bytes of scan results (15 BSSes)
BSS: Start scan result update 1
(##BUNCH OF SSID's for my local removed##)
New scan results available
WPS: Unsupported attribute type 0x1049 len=6
WPS: Unsupported attribute type 0x1049 len=6
Selecting BSS from priority group 10
Try to find WPA-enabled AP
(##HIDDEN##)
Trying to associate with (##HIDDEN##)
Cancelling scan request
WPA: clearing own WPA/RSN IE
Automatic auth_alg selection: 0x1
RSN: using IEEE 802.11i/D9.0
WPA: Selected cipher suites: group 8 pairwise 24 key_mgmt 2 proto 2
WPA: clearing AP WPA IE
WPA: set AP RSN IE - (##HIDDEN##)
WPA: using GTK TKIP
WPA: using PTK CCMP
WPA: using KEY_MGMT WPA-PSK
WPA: Set own WPA IE default - hexdump (##HIDDEN##)
No keys have been configured - skip key clearing
State: SCANNING -> ASSOCIATING
wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)
netlink: Operstate: linkmode=-1, operstate=5
wpa_driver_wext_associate
wpa_driver_wext_set_drop_unencrypted
wpa_driver_wext_set_psk
Setting authentication timeout: 10 sec 0 usec
EAPOL: External notification - EAP success=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - EAP fail=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portControl=Auto
EAPOL: Supplicant port status: Unauthorized
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b1a len=16
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b06 len=12
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b04 len=16
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b1a len=24
RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8c08 len=198
AssocResp IE wireless event - hexdump (##HIDDEN##)
RTM_NEWLINK: operstate=0 ifi_flags=0x11003 ([UP][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b15 len=24
Wireless event: new AP: (##HIDDEN##)
Association info event
resp_ies - hexdump(len=182): (##HIDDEN##)
State: ASSOCIATING -> ASSOCIATED
wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)
netlink: Operstate: linkmode=-1, operstate=5
Associated to a new BSS: BSSID=(##HIDDEN##)
No keys have been configured - skip key clearing
Associated with (##HIDDEN##)
WPA: Association event - clear replay counter
WPA: Clear old PTK
EAPOL: External notification - portEnabled=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portValid=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - EAP success=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portEnabled=1
EAPOL: SUPP_PAE entering state CONNECTING
EAPOL: enable timer tick
EAPOL: SUPP_BE entering state IDLE
Setting authentication timeout: 10 sec 0 usec
Cancelling scan request
RX EAPOL (##HIDDEN##)
Setting authentication timeout: 10 sec 0 usec
IEEE 802.1X RX: version=1 type=3 length=95
 EAPOL-Key type=2
 key_info 0x8a (ver=2 keyidx=0 rsvd=0 Pairwise Ack)
 key_length=16 key_data_length=0
 replay_counter - hexdump(len=8): (##HIDDEN##)
 key_nonce - hexdump(len=32): (##HIDDEN##)
 key_iv - hexdump(len=16): (##HIDDEN##)
 key_rsc - hexdump(len=8): (##HIDDEN##)
 key_id (reserved) - hexdump(len=8): (##HIDDEN##)
 key_mic - hexdump(len=16): (##HIDDEN##)
State: ASSOCIATED -> 4WAY_HANDSHAKE
WPA: RX message 1 of 4-Way Handshake from (##HIDDEN##)
RSN: msg 1/4 key data - hexdump(len=0):
WPA: Renewed SNonce - hexdump(len=32): (##HIDDEN##)
WPA: PTK derivation - A1=(##HIDDEN##)
WPA: PMK - hexdump(len=32): [REMOVED]
WPA: PTK - hexdump(len=48): [REMOVED]
WPA: WPA IE for msg 2/4 - hexdump(len=22): (##HIDDEN##)
WPA: Sending EAPOL-Key 2/4
RX EAPOL from (##HIDDEN##)
IEEE 802.1X RX: version=1 type=3 length=175
 EAPOL-Key type=2
 key_info 0x13ca (ver=2 keyidx=0 rsvd=0 Pairwise Install Ack MIC Secure Encr)
 key_length=16 key_data_length=80
 replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 02
 key_nonce - hexdump(len=32): (##HIDDEN##)
 key_iv - hexdump(len=16): (##HIDDEN##)
 key_rsc - hexdump(len=8): (##HIDDEN##)
 key_id (reserved) - hexdump(len=8): (##HIDDEN##)
 key_mic - hexdump(len=16): (##HIDDEN##)
RSN: encrypted key data - hexdump(len=80): (##HIDDEN##)
WPA: decrypted EAPOL-Key key data - hexdump(len=72): [REMOVED]
State: 4WAY_HANDSHAKE -> 4WAY_HANDSHAKE
WPA: RX message 3 of 4-Way Handshake from (##HIDDEN##)(ver=2)
WPA: IE KeyData - hexdump(len=72): (##HIDDEN##)
WPA: RSN IE in EAPOL-Key - hexdump(len=26): (##HIDDEN##)
WPA: GTK in EAPOL-Key - hexdump(len=40): [REMOVED]
WPA: Sending EAPOL-Key 4/4
WPA: Installing PTK to the driver.
wpa_driver_wext_set_key: alg=3 key_idx=0 set_tx=1 seq_len=6 key_len=16
EAPOL: External notification - portValid=1
State: 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
RSN: received GTK in pairwise handshake - hexdump(len=34): [REMOVED]
WPA: Group Key - hexdump(len=32): [REMOVED]
WPA: Installing GTK to the driver (keyidx=2 tx=0 len=32).
WPA: RSC - hexdump(len=6): 00 01 00 00 00 00
wpa_driver_wext_set_key: alg=2 key_idx=2 set_tx=0 seq_len=6 key_len=32
WPA: Key negotiation completed with  [PTK=CCMP GTK=TKIP]
Cancelling authentication timeout
State: GROUP_HANDSHAKE -> COMPLETED
CTRL-EVENT-CONNECTED - Connection to (##HIDDEN##) completed (auth) [id=0 id_str=]
wpa_driver_wext_set_operstate: operstate 0->1 (UP)
netlink: Operstate: linkmode=-1, operstate=6
EAPOL: External notification - portValid=1
EAPOL: External notification - EAP success=1
EAPOL: SUPP_PAE entering state AUTHENTICATING
EAPOL: SUPP_BE entering state SUCCESS
EAP: EAP entering state DISABLED
EAPOL: SUPP_PAE entering state AUTHENTICATED
EAPOL: Supplicant port status: Authorized
EAPOL: SUPP_BE entering state IDLE
EAPOL authentication completed successfully
RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
EAPOL: startWhen --> 0
EAPOL: disable timer tick
bash-4.1# /etc/rc.d/rc.inet1 wlan0_start
bash-4.1# BSS: Expire BSS 0 due to age
BSS: Remove id (##HIDDEN##)
BSS: Remove id (##HIDDEN##)
BSS: Remove id (##HIDDEN##)
(etc)

這是 lspci 的輸出:

ubsystem: Intel Corporation Device 1121
       Flags: bus master, fast devsel, latency 0, IRQ 41
       Memory at f8000000 (64-bit, non-prefetchable) [size=8K]
       Capabilities: [c8] Power Management version 3
       Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
       Capabilities: [e0] Express Endpoint, MSI 00
       Capabilities: [100] Advanced Error Reporting
       Capabilities: [140] Device Serial Number (##HIDDEN##)
       Kernel driver in use: iwlagn
       Kernel modules: iwlagn

wpa_supplicant此無線配置是必需的。

如果您的無線在啟動時沒有啟動,並且您認為您的所有資訊在 中都是正確的rc.inet1.conf,那麼您可能忘記取消註釋文件中的wpa_supplicantrc.inet1.conf。一旦我這樣做了,無線就會在啟動過程中啟動,而無需手動輸入任何一條線路。

我也按照 BatchyX 的建議-Dwext進行了更改。-Dnl80211

首先,如果你想使用初始化腳本,你必須把無線配置放進去/etc/rc.d/rc.inet1.conf(記住讓它只能被root訪問,否則你會洩露網路密碼)。但是,除非這台機器由於某種原因一直使用相同的無線網路,否則您可能需要更好的可配置性。

根據我自己的經驗,我可以說wicd效果很好。它可能無法擷取所有可能的身份驗證可能性,但應該可以很好地處理大多數情況。

在預設設置中,您只需要確保/etc/rc.d/rc.wicd可執行(預設情況下)。這樣可以確保生成守護程序(具有足夠的權限),然後您需要使用客戶端部分訪問它wicd-client,這實際上只是 Wicd 各種前端(命令行、curses、GTK 以及可能還有 QT)的包裝器。如果您使用的是圖形環境,客戶端將在系統托盤中保留一個圖示。

另一種選擇是 NetworkManager,我個人發現它過於重量級並且一遍又一遍地非常不靈活。

如果你想自己處理網路,你可以從我的舊腳本中獲得靈感(沒有錯誤檢查,一切都應該順利進行,否則會慘遭失敗):

#!/bin/bash
MODULENAME=your_driver
IFWIRED=eth0
IFWIFI=wlan0

case "$1" in
   start)
       # check that the driver module is loaded
       if ! lsmod | grep $MODULENAME &>/dev/null ; then
           echo "loading $MODULENAME"
           modprobe -v $MODULENAME
           sleep 5
       fi
       echo "running wpa_supplicant"
       wpa_supplicant -D wext -i $IFWIFI \
           -c /etc/wpa_supplicant.conf >& /dev/null &
       echo "shutting down $IFWIRED"
       /sbin/ifconfig $IFWIRED down
       # wait for things to settle down
       sleep 10
       echo "running dhcpcd"
       dhcpcd -n -p -d $IFWIFI
       ;;
   stop)
       echo "shutting down dhcpcd on wlan0"
       dhcpcd -k $IFWIRED
       echo "shutting down wpa_supplicant"
       wpa_cli terminate
       echo "unloading $MODULENAME"
       modprobe -rv $MODULENAME
       ;;
   *)
       echo "$0 <start|stop>"
esac

簡單家庭網路的基本 wpa_supplicant.conf 條目可能如下所示:

network={
   ssid="YOURNETSSID"
   psk="password"
   proto=WPA2
   key_mgmt=WPA-PSK
   pairwise=TKIP CCMP
   group=TKIP CCMP
}

wpa_supplicant.conf手冊頁有一些更複雜設置的範例(通常在公司網路中有用)。

引用自:https://unix.stackexchange.com/questions/78600