# RT2770 ALFA AWUS051NH 2/5g wifi detected but wpa_supp error

## jpc22

I am trying to get my new usb wifi card,i have enabled all the relevant drivers(using latest 3.13.8hardened kernel) for this card and the one already integrated in my laptop and it shows in command line but wpa_supplicant is being stubborn 

Under backtrack the card workswith like a charm and i see 3times as much networks around me. my own network is 10-15 db better with the alfa than my integrated card.

(edit) looks like my card has no power tried every(iw iwconfig) command to increase its tx power/ change location . the card came with a taiwan sticker and hologram that looks legit and come from the seller who does the videos about how to spot fakes (rokland) so i guess the problem is a simple matter of config.

rfkill list wifi  

0: phy0: Wireless LAN

	Soft blocked: no

	Hard blocked: no

1: phy1: Wireless LAN

	Soft blocked: no

	Hard blocked: no

iwconfig

wlp0s29u1u2  IEEE 802.11abgn  ESSID:off/any  

          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm   

          Retry  long limit:7   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:off

iwlist scan

wlp......  Interface doesn't support scanning : Network is down

on boot or when manually starting wpa supp i get this

/etc/init.d/wpa_supplicant start

wpa_supplicant   | * Starting WPA Supplicant Daemon ...

wpa_supplicant   |Successfully initialized wpa_supplicant

wpa_supplicant   |Could not set interface wlp0s29u1u2 flags (UP): No such file or directory

wpa_supplicant   |nl80211: Could not set interface 'wlp0s29u1u2' UP

wpa_supplicant   |wlp0s29u1u2: Failed to initialize driver interface

wpa_supplicant   | * start-stop-daemon: failed to start `/usr/sbin/wpa_supplicant'

wpa_supplicant   | * Failed to start wpa_supplicant                                                 [ !! ]

wpa_supplicant   | * ERROR: wpa_supplicant failed to start

when specifiying parameters i get this:

wpa_supplicant -dd -iwlp0s29u1u2 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf

wpa_supplicant v2.1

random: Trying to read entropy from /dev/random

Successfully initialized wpa_supplicant

Initializing interface 'wlp0s29u1u2' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'

Configuration file '/etc/wpa_supplicant/wpa_supplicant.conf' -> '/etc/wpa_supplicant/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'

ctrl_interface='DIR=/var/run/wpa_supplicant GROUP=wheel'

update_config=1

Line: 4 - start of a new network block

ssid - hexdump_ascii(len=9):

     xx xx xx xx xx xx xx xx xx                        xxxxx_xx       

PSK - hexdump(len=32): [REMOVED]

disabled=1 (0x1)

Line: 10 - start of a new network block

ssid - hexdump_ascii(len=10):

     46 58 47 2d 49 6e 76 69 74 65                     FXG-Invite  (school network)    

key_mgmt: 0x4

auth_alg: 0x1     

key_mgmt: 0x4

auth_alg: 0x1

Priority group 0

   id=0 ssid='xxxxxx_xx'

   id=1 ssid='FXG-Invite'

   id=2 ssid='FXG-Invite'

WEXT: cfg80211-based driver detected

wext: interface wlp0s29u1u2 phy: phy1

rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0

rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0

Could not set interface wlp0s29u1u2 flags (UP): No such file or directory

WEXT: Could not set interface 'wlp0s29u1u2' UP

wlp0s29u1u2: Failed to initialize driver interface

Failed to add interface wlp0s29u1u2

wlp0s29u1u2: Cancelling scan request

wlp0s29u1u2: Cancelling authentication timeout

 lsusb

Bus 002 Device 003: ID 148f:2770 Ralink Technology, Corp. RT2770 Wireless Adapter

Device Descriptor:

  bLength                18

  bDescriptorType         1

  bcdUSB               2.00

  bDeviceClass            0 (Defined at Interface level)

  bDeviceSubClass         0 

  bDeviceProtocol         0 

  bMaxPacketSize0        64

  idVendor           0x148f Ralink Technology, Corp.

  idProduct          0x2770 RT2770 Wireless Adapter

  bcdDevice            1.01

  iManufacturer           1 Ralink

  iProduct                2 802.11 n WLAN

  iSerial                 3 1.0

  bNumConfigurations      1

  Configuration Descriptor:

    bLength                 9

    bDescriptorType         2

    wTotalLength           53

    bNumInterfaces          1

    bConfigurationValue     1

    iConfiguration          0 

    bmAttributes         0x80

      (Bus Powered)

    MaxPower              450mA

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        0

      bAlternateSetting       0

      bNumEndpoints           5

      bInterfaceClass       255 Vendor Specific Class

      bInterfaceSubClass    255 Vendor Specific Subclass

      bInterfaceProtocol    255 Vendor Specific Protocol

      iInterface              5 1.0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x81  EP 1 IN

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x01  EP 1 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x02  EP 2 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x03  EP 3 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x04  EP 4 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

Device Qualifier (for other device speed):

  bLength                10

  bDescriptorType         6

  bcdUSB               2.00

  bDeviceClass            0 (Defined at Interface level)

  bDeviceSubClass         0 

  bDeviceProtocol         0 

  bMaxPacketSize0        64

  bNumConfigurations      1

Device Status:     0x0000

  (Bus Powered)

----------

## s4e8

emerge linux-firmware

or find and install rt2870.bin to /lib/firmware.

----------

## jpc22

Card is now almost properly working and does not crash wpa_supp on boot but in wpa_gui i cannot select it as my interface.

It is now permanently renamed wlp4s0u1      wpa_supplicant is unable to use it but is able to scan 2/5g networks.

wpa_supplicant -dd -iwlp4s0u1 -Dwext -c /etc/wpa_supplicant/wpa_supplicant.conf

wpa_supplicant v2.1

random: Trying to read entropy from /dev/random

Successfully initialized wpa_supplicant

Initializing interface 'wlp4s0u1' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'

Configuration file '/etc/wpa_supplicant/wpa_supplicant.conf' -> '/etc/wpa_supplicant/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'

ctrl_interface='DIR=/var/run/wpa_supplicant GROUP=wheel'

update_config=1

Line: 4 - start of a new network block

ssid - hexdump_ascii(len=9):

     xx xx xx xx xx xx xx xx xx                        xxxxxx      

PSK - hexdump(len=32): [REMOVED]

disabled=1 (0x1)

Line: 10 - start of a new network block

ssid - hexdump_ascii(len=10):

     46 58 47 2d 49 6e 76 69 74 65                     FXG-Invite      

key_mgmt: 0x4

auth_alg: 0x1

Line: 16 - start of a new network block

ssid - hexdump_ascii(len=10):

     46 58 47 2d 49 6e 76 69 74 65                     FXG-Invite      

key_mgmt: 0x4

auth_alg: 0x1

Priority group 0

   id=0 ssid='xxxxxxx'

   id=1 ssid='FXG-Invite'

   id=2 ssid='FXG-Invite'

WEXT: cfg80211-based driver detected

wext: interface wlp4s0u1 phy: phy1

rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0

rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0

SIOCGIWRANGE: WE(compiled)=22 WE(source)=21 enc_capa=0xf

  capabilities: key_mgmt 0xf enc 0x1f flags 0x0

netlink: Operstate: ifindex=6 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT)

Add interface wlp4s0u1 to a new radio phy1

wlp4s0u1: Own MAC address: 00:c0:ca:32:c1:a2

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

wlp4s0u1: RSN: flushing PMKID list in the driver

wlp4s0u1: Setting scan request: 0.100000 sec

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

Using existing control interface directory.

ctrl_interface_group=10 (from group name 'wheel')

wlp4s0u1: Added interface wlp4s0u1

wlp4s0u1: State: DISCONNECTED -> DISCONNECTED

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

netlink: Operstate: ifindex=6 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)

random: Got 20/20 bytes from /dev/random

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlp4s0u1' added

WEXT: if_removed already cleared - ignore event

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlp4s0u1' added

WEXT: if_removed already cleared - ignore event

Wireless event: cmd=0x8b06 len=12

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlp4s0u1' added

WEXT: if_removed already cleared - ignore event

Wireless event: cmd=0x8b1a len=16

wlp4s0u1: State: DISCONNECTED -> SCANNING

wlp4s0u1: Starting AP scan for wildcard SSID

wlp4s0u1: Add radio work 'scan'@0x7f69fb5553e0

wlp4s0u1: First radio work item in the queue - schedule start immediately

wlp4s0u1: Starting radio work 'scan'@0x7f69fb5553e0 after 0.000037 second wait

ioctl[SIOCSIWSCAN]: Device or resource busy

Scan requested (ret=-1) - scan timeout 10 seconds

wlp4s0u1: Radio work 'scan'@0x7f69fb5553e0 done in 0.000175 seconds

EAPOL: disable timer tick

RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlp4s0u1' added

WEXT: if_removed already cleared - ignore event

Wireless event: cmd=0x8b19 len=16

wlp4s0u1: Event SCAN_RESULTS (3) received

Received 1951 bytes of scan results (4 BSSes)

wlp4s0u1: BSS: Start scan result update 1

wlp4s0u1: BSS: Add new id 0 BSSID xx:xx:xx:xx:xx:xx SSID 'xxxxxxx_5G'

wlp4s0u1: BSS: Add new id 1 BSSID xx:xx:xx:xx:xx:xx SSID 'xxxxxxx_2G'

wlp4s0u1: BSS: Add new id 2 BSSID nn:nn:nn:nn:nn:nn SSID 'neighbor1'

wlp4s0u1: BSS: Add new id 3 BSSID nn:nn:nn:nn:nn:nn SSID 'neighbor2'

BSS: last_scan_res_used=4/32

wlp4s0u1: New scan results available (own=0 ext=0)

wlp4s0u1: Selecting BSS from priority group 0

wlp4s0u1: 0: xx:xx:xx:xx:xx:xx ssid='xxxxxx_5G' wpa_ie_len=0 rsn_ie_len=20 caps=0x11 level=-20

wlp4s0u1:    skip - disabled

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1: 1: xx:xx:xx:xx:xx:xx ssid='xxxxxx_2G' wpa_ie_len=0 rsn_ie_len=20 caps=0x11 level=-22

wlp4s0u1:    skip - disabled

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1: 2: nn:nn:nn:nn:nn:nn ssid='neighbor1' wpa_ie_len=0 rsn_ie_len=20 caps=0x11 level=-79

wlp4s0u1:    skip - disabled

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1: 3: nn:nn:nn:nn:nn:nn ssid='neighbor2' wpa_ie_len=0 rsn_ie_len=0 caps=0x11 level=-81 wps

wlp4s0u1:    skip - disabled

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1:    skip - SSID mismatch

wlp4s0u1: No suitable network found

wlp4s0u1: Setting scan request: 5.000000 sec

^Cwlp4s0u1: Removing interface wlp4s0u1

wlp4s0u1: Request to deauthenticate - bssid=00:00:00:00:00:00 pending_bssid=00:00:00:00:00:00 reason=3 state=SCANNING

wlp4s0u1: State: SCANNING -> DISCONNECTED

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT)

netlink: Operstate: ifindex=6 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)

EAPOL: External notification - portEnabled=0

EAPOL: External notification - portValid=0

wpa_driver_wext_set_countermeasures

wlp4s0u1: BSS: Remove id 0 BSSID xx:xx:xx:xx:xx:xx  SSID 'xxxxx_5G' due to wpa_bss_flush

wlp4s0u1: BSS: Remove id 1 BSSID xx:xx:xx:xx:xx:xx  SSID 'xxxxx_2G' due to wpa_bss_flush

wlp4s0u1: BSS: Remove id 2 BSSID nn:nn:nn:nn:nn:nn  SSID 'neighbor1' due to wpa_bss_flush

wlp4s0u1: BSS: Remove id 3 BSSID nn:nn:nn:nn:nn:nn  SSID 'neighbor2' due to wpa_bss_flush

wlp4s0u1: Cancelling scan request

wlp4s0u1: Cancelling authentication timeout

Remove interface wlp4s0u1 from radio phy1

Remove radio phy1

netlink: Operstate: ifindex=6 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)

wlp4s0u1: CTRL-EVENT-TERMINATING 

Control interface directory not empty - leaving it behind

----------

## s4e8

It seems you use wrong SSID. The config file says "xxxxxx", the scan result is "xxxxxx_5G" and "xxxxxx_2G".

----------

## jpc22

I am usingthe right ssid but i obscured them manually or privacy sake.

Found out i am not in the right reg domain

 iw reg get

country 00: DFS-UNSET

	(2402 - 2472 @ 40), (6, 20)

	(2457 - 2482 @ 40), (6, 20), NO-IR

	(2474 - 2494 @ 20), (6, 20), NO-OFDM, NO-IR

	(5170 - 5250 @ 160), (6, 20), NO-IR

	(5250 - 5330 @ 160), (6, 20), DFS, NO-IR

	(5490 - 5730 @ 160), (6, 20), DFS, NO-IR

trying to set to US is not working so i voluntarily mistyped us to see what options are available

iw reg set us

not a valid ISO/IEC 3166-1 alpha2

Special non-alpha2 usable entries:

	00	World Regulatory domain

----------

## s4e8

"emerge wireless-regdb" and add "country=US" to wpa_supplicant.conf.

----------

## jpc22

Problem is already tried this this morning with CA since i am in Canada. Also tried enabling/disabling the regdb kernel option to no avail.

When i restart wpa_supp i can use the monitor interface of the card to scan and connect to 5g networks if i was  airodumping on those frequencies prior to restarting wpa_supp. (regdb no-ir specific i guess)

Guess i will try hostapd or onus certification or replace the world reg database with the local one.

----------

## khayyam

 *jpc22 wrote:*   

> trying to set to US is not working so i voluntarily mistyped us to see what options are available
> 
> ```
> iw reg set us
> 
> ...

 

jpc22 ... this just looks as though the device in question has regulatory restrictions set in EEPROM and the rt2770 driver sets it accordingly. This is the case with other drivers (ath9k, ath5k, and others) and cfg80211 I believe is required to follow "regulatory" practice and so not allow it to be set from userspace.

```
# iw reg set US ; echo $?

0

# iw reg get

country 00: DFS-UNSET

  (2402 - 2472 @ 40), (6, 20)

  (2457 - 2482 @ 40), (6, 20), PASSIVE-SCAN, NO-IBSS

  (2474 - 2494 @ 20), (6, 20), NO-OFDM, PASSIVE-SCAN, NO-IBSS

  (5170 - 5250 @ 80), (6, 20), PASSIVE-SCAN, NO-IBSS

  (5735 - 5835 @ 80), (6, 20), PASSIVE-SCAN, NO-IBSS

  (57240 - 63720 @ 2160), (N/A, 0)
```

Similarly, if I set it via wpa_supplicant, or ieee80211_regdom, the regulatory domain is unchanged.

That aside, are you now able to connect to the AP? I ask as you may still have issues with wpa_supplicant as you have two AP's sharing the same BSSID. You may need something like the following:

/etc/wpa_supplicant/wpa_supplicant.conf

```
network={

    ssid="xxxxx_5G"

    bssid=xx:xx:xx:xx:xx:xx

    scan_freq=2422 # <= or whatever channel freq is used

    scan_ssid=0

    proto=RSN

    auth_alg=OPEN

    key_mgmt=WPA-PSK

    group=CCMP

    pairwise=CCMP

    psk=secret

}
```

HTH & best ... khay

----------

## jpc22

There is no problem with the ap's bssid they are not the same in real life (replaced by xx or nn because i am a little parano)

Real problem now is i cannot  change the regulatory domain and thus the no initiationg radiation restriction blocks me from selecting my usb card in wpa_gui unless i do some things i should not need to do (mon0 and restart wpa) that require root permissions.

I am open to alternatives to wpa supp if i can get one working (wicd and the rest are not working good on my hardened setup)          A way to pass the reg domain on the kernel command line would please me if there was one.

Wicd works on any ubuntu/backtrack livecd and those backtrack cd can change the reg domain while my gentoo setup cannot.

----------

## khayyam

 *jpc22 wrote:*   

> There is no problem with the ap's bssid they are not the same in real life (replaced by xx or nn because i am a little parano)

 

jpc22 ... I see, I'd assumed they were VAP's.

 *jpc22 wrote:*   

> Real problem now is i cannot  change the regulatory domain and thus the no initiationg radiation restriction blocks me from selecting my usb card in wpa_gui unless i do some things i should not need to do (mon0 and restart wpa) that require root permissions.

 

... wpa_supplicant shouldn't care if the regulatory domain is set to 00, this sounds as though rfkill is blocking, or the ctrl_interface used by wpa_gui is not that of the wpa_supplicant initiated for the USB device (wpa_gui uses the first ctrl_interface it finds, if you need to use two interfaces with wpa_gui then you need a '-g ... global ctrl_interface').

 *jpc22 wrote:*   

> I am open to alternatives to wpa supp if i can get one working (wicd and the rest are not working good on my hardened setup). A way to pass the reg domain on the kernel command line would please me if there was one.

 

There is the 'ieee80211_regdom' param for the 'cfg80211' module, whether this will work or not via the kernel command line I'm not sure ...

/etc/modprobe.d/cfg80211.conf

```
options cfg80211 ieee80211_regdom=BO
```

 *jpc22 wrote:*   

> Wicd works on any ubuntu/backtrack livecd and those backtrack cd can change the reg domain while my gentoo setup cannot.

 

hmmm, well, wcid uses WEXT and doesn't understand NL80211, I'm not sure what this kernel driver uses, I assume NL80211, so is CFG80211_WEXT (the compatability layer for CFG80211) enabled? (silly question really, it'd have to be as you're using '-Dwext' above).

As far as regulatory changes go, what kernel versions are involved, and have you tried w/out a hardened kernel?

best ... khay

----------

## jpc22

i have not tried regular kernel because a lot a lot of my safety features relies on hardened.

managed to get wicd to work and i can manually input the interface and scan with it ,but only in 2ghz not in 5ghz.

Tried to replicate my try with mon0 with no luck

wpa_supplicant   |Could not set interface mon0 flags (UP): Device or resource busy

wpa_supplicant   |nl80211: Could not set interface 'mon0' UP

wpa_supplicant   |mon0: Failed to initialize driver interface

wpa_supplicant   | * start-stop-daemon: failed to start `/usr/sbin/wpa_supplicant'

Maybe i need to fix this (timezone) to get the crda/regdb thing working :

SMP Local time zone must be set--see zic manual page 2005

Also emerged network management/manager since i have bluetooth and it says it supports it but looks like a bad idea to unset everything to get that to work            ( ill drop it if i really need to emerge kde-runtime-meta)

Will have to postpone trying to fix those issues: lot of schoolwork ahead this week.

----------

