Slackware 上的无线

Slackware 上的无线

好的,我终于在 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

答案1

首先,如果你想使用初始化脚本,你必须将无线配置放入/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手册页有一些更复杂的设置的示例(通常在公司网络中有用)。

答案2

wpa_supplicant对于此无线配置是必需的。

如果您的无线网络在启动时没有启动,并且您认为 中的所有信息都是正确的rc.inet1.conf,那么您可能忘记取消文件wpa_supplicant中该行的注释rc.inet1.conf。一旦我这样做了,无线网络就会在启动过程中启动,而无需手动输入任何线路。

我也按照 BatchyX 的建议-Dwext进行了更改。-Dnl80211

答案3

当我第一次安装 slackware 时,我还注意到我必须是 root 才能使用wpa_supplicant.只要尝试一下echo $PATH,并确保/sbinand /usr/sbin(forshutdown等)包含在环境变量中,如果没有添加

export PATH=/sbin:/usr/sbin:$PATH

到你的.profile或文件中,或者在文件.bashrc中导出/etc/rc.local

由于我的 slackware 机器不需要太安全,我选择将命令添加wpa_supplicant/etc/rc.d/rc.local,只需添加

wpa_supplicant -B -Dwext -ieth1 -c/etc/wpa_supplicant.conf

并且,对于我连接的每个网络,执行以下操作:

wpa_passphrase somenetwork somekey >> /etc/wpa_supplicant.conf

工作正常

相关内容