# Can't set country code can't connect to AP  [SOLVED]

## Tony0945

The kernel is 4.4.115 32bit AMD k6-3 kernel config:  https://paste.pound-python.org/show/1SxDe2mLXpGsQlXQJRTy/

wpa_supplicant is here (passkey truncated):  https://paste.pound-python.org/show/pXmW720PcNNJUMBeAzdk/

/etc/conf.d/net is here:  https://paste.pound-python.org/show/L9IKydC1J9UbDgcIpEI5/

ifconfig -a is here:  https://paste.pound-python.org/show/358qtys74LA6bDtkckW9/

lsmod is here:  https://paste.pound-python.org/show/Ym8PDMsM5iKYRwAycQMw/

There are three cards

1) Realtek wired 100Mhz PCI using module 8139too and renamed wan0 by eudev rule

2) Intel wired 1000Mhz PCI using module e1000 and renamed lan0 by eudev rule

3) TP-LINK wireless PCI card using module ath9k (Atheros 9227) and named wlan0 by the kernel

The intended use is as a router, but right now both wired interfaces are connected to a DLINK router to which I'm trying to get the wireless card to speak to.

Wired internet works fine.  dmesg is filled with:

```
[ 4352.899627] cfg80211: World regulatory domain updated:

[ 4352.899650] cfg80211:  DFS Master region: unset

[ 4352.899666] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)

[ 4352.899697] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)

[ 4352.899725] cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz, 92000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[ 4352.899749] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)

[ 4352.899776] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[ 4352.899806] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)

[ 4352.899831] cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)

[ 4352.899854] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)

[ 4352.899877] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
```

Endlessly repeated. The wiki suggests putting the country code in wpa_supplicant right in the {} block, but I always get a syntax error there.

I need to set the country to US, disable 5Ghz band and connect to the DLINK router. The DLINK's log shows NOTHING, no attempts to connect, no rejections, nothing. The DLINK's AP is working because I have a few TV's, an HP printer, a ROKU and two amazon firestick's connected to it and the other computers on the network (all wired). I know the wireless card is good because it used to work on another Gentoo computer, now wired. That's where the wpa_supplicant.conf came from.

Can someone teach me to fish?Last edited by Tony0945 on Sat Mar 10, 2018 9:27 pm; edited 1 time in total

----------

## blopsalot

what about running wpa_cli, can you configure it that way?

https://wiki.gentoo.org/wiki/Wpa_supplicant#Using_wpa_cli

----------

## Fitzcarraldo

Not sure if it's of any help to you, but...

Do you have CONFIG_CFG80211=y or CONFIG_CFG80211=m?

Here's what I have on my main laptop:

```
clevow230ss /home/fitzcarraldo # cat /usr/src/linux/.config | grep CFG80211

CONFIG_CFG80211=y

# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set

CONFIG_CFG80211_DEFAULT_PS=y

# CONFIG_CFG80211_DEBUGFS is not set

# CONFIG_CFG80211_INTERNAL_REGDB is not set

CONFIG_CFG80211_CRDA_SUPPORT=y

# CONFIG_CFG80211_WEXT is not set
```

And there should be a udev rule (I'm using eudev, in fact):

```
clevow230ss /home/fitzcarraldo # cat /lib64/udev/rules.d/85-regulatory.rules

# Runs CRDA for kernel wireless regulatory events.

# For more information see:

# http://wireless.kernel.org/en/developers/Regulatory/CRDA

KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/usr/sbin/crda"
```

If I had not built cfg80211 into the kernel, I would check the module is loaded:

```
# lsmod | grep cfg80211
```

To check the current regulatory setting:

```
clevow230ss /home/fitzcarraldo # iw reg get

global

country 00: DFS-UNSET

        (2402 - 2472 @ 40), (N/A, 20), (N/A)

        (2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, NO-IR

        (2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, NO-IR

        (5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, NO-IR

        (5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, NO-IR

        (5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, NO-IR

        (5735 - 5835 @ 80), (N/A, 20), (N/A), NO-IR

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

To set it to the UK in my case:

```
clevow230ss /home/fitzcarraldo # iw reg set GB

clevow230ss /home/fitzcarraldo # iw reg get

global

country GB: DFS-ETSI

        (2402 - 2482 @ 40), (N/A, 20), (N/A)

        (5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW

        (5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW

        (5490 - 5710 @ 160), (N/A, 27), (0 ms), DFS

        (57000 - 66000 @ 2160), (N/A, 40), (N/A)
```

crda is installed:

```
clevow230ss /home/fitzcarraldo # eix crda

[I] net-wireless/crda

     Available versions:  1.1.3-r1 3.18-r1 {gcrypt libressl}

     Installed versions:  3.18-r1(19:02:57 01/12/17)(-gcrypt -libressl)

     Homepage:            https://wireless.wiki.kernel.org/en/developers/regulatory/crda

     Description:         Central Regulatory Domain Agent for wireless networks
```

----------

## Tony0945

 *Fitzcarraldo wrote:*   

> Not sure if it's of any help to you, but...
> 
> Do you have CONFIG_CFG80211=y or CONFIG_CFG80211=m?
> 
> Here's what I have on my main laptop:
> ...

 

I had at y but changed it to m yesterday.

```
 zgrep CFG80211 /proc/config.gz

CONFIG_CFG80211=m

# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set

# CONFIG_CFG80211_REG_DEBUG is not set

CONFIG_CFG80211_DEFAULT_PS=y

# CONFIG_CFG80211_DEBUGFS is not set

# CONFIG_CFG80211_INTERNAL_REGDB is not set

CONFIG_CFG80211_CRDA_SUPPORT=y

# CONFIG_CFG80211_WEXT is not set

```

Yes, it's loaded

```
6 ~ # lsmod |grep cfg80211

cfg80211              296948  4 ath,ath9k_common,ath9k,mac80211

```

I have crda but not iw

```
k6 ~ # iw

-bash: iw: command not found

k6 ~ # which crda

/usr/sbin/crda

```

----------

## Tony0945

 *Fitzcarraldo wrote:*   

> 
> 
> And there should be a udev rule (I'm using eudev, in fact):
> 
> ```
> ...

 

I have the rule but under /lib not /lib64 because this is a 32 bit only system (32 bit CPU).

I'll emerge iw but it will take some time (took four hours to rebuild the kernel0.

----------

## Tony0945

Some interesting results from wpa_cli

```
wlan0: WPA: Clear old PMK and PTK

wlan0: BSS: Remove id 0 BSSID 00:24:01:70:8a:cf SSID 'Road2hell' due to wpa_bss_flush

wlan0: BSS: Remove id 1 BSSID 02:fc:8b:af:10:b2 SSID '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' due to wpa_bss_flush

wlan0: BSS: Remove id 2 BSSID b2:10:41:bf:ff:85 SSID 'DIRECT-VG-BRAVIA' due to wpa_bss_flush

wlan0: BSS: Remove id 3 BSSID 70:3a:cb:25:42:7d SSID 'Bentley' due to wpa_bss_flush

wlan0: BSS: Remove id 4 BSSID 08:05:81:8d:e8:77 SSID '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' due to wpa_bss_flush

wlan0: BSS: Remove id 5 BSSID 70:3a:cb:25:43:01 SSID 'Bentley' due to wpa_bss_flush

wlan0: BSS: Remove id 8 BSSID f8:18:97:7c:0e:a2 SSID 'ATT3fwv8u4' due to wpa_bss_flush

wlan0: BSS: Remove id 6 BSSID fa:8f:ca:3c:e0:4e SSID '' due to wpa_bss_flush

wlan0: BSS: Remove id 7 BSSID 00:14:bf:ad:16:72 SSID 'linksys' due to wpa_bss_flush

```

 Road2hell is my AP. Bentley ATT3fwv8u4  DIRECT-VG-BRAVIA and linksys  all appear in the wifi scan on my Samsung Galaxy S5. I don't maintain phone service on it. I just keep it as a handy camera (better than the one on my flip phone). It looks like it can be a wifi debugging tool also. I didn't know it would work without a valid SIM card.

BTW, linksys is unsecured. I wish I knew which of my neighbors it belongs to so I can warn them. It would blow their mind if I ssh'd in and left a file with a message.  Better not. I'll jut ask the neighbors I like.

----------

## Tony0945

```
k6 ~ # iw reg set GB

k6 ~ # iw reg get

global

country 00: DFS-UNSET

        (2402 - 2472 @ 40), (N/A, 20), (N/A)

        (2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, NO-IR

        (2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, NO-IR

        (5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, NO-IR

        (5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, NO-IR

        (5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, NO-IR

        (5735 - 5835 @ 80), (N/A, 20), (N/A), NO-IR

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

```

Trying again with US

```
k6 ~ # iw reg set US

k6 ~ # iw reg get

global

country 00: DFS-UNSET

        (2402 - 2472 @ 40), (N/A, 20), (N/A)

        (2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, NO-IR

        (2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, NO-IR

        (5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, NO-IR

        (5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, NO-IR

        (5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, NO-IR

        (5735 - 5835 @ 80), (N/A, 20), (N/A), NO-IR

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

```

 No joy.

EDIT:

```
k6 ~ # iw wlan0  info

Interface wlan0

        ifindex 4

        wdev 0x1

        addr a0:f3:c1:77:21:fa

        type managed

        wiphy 0

        txpower 13.00 dBm

```

Last edited by Tony0945 on Sat Mar 10, 2018 1:06 am; edited 1 time in total

----------

## Tony0945

Found my card model. I bought it in March 2013 so the 'n' might just be draft, but the 'g' should work.

"TP-LINK TL-WN751ND"

https://www.newegg.com/Product/Product.aspx?Item=N82E16833704079

----------

## khayyam

Tony0945 ...

I suspect the ASSOC issue is not related to your regulatory domain. Often you can't change the domain with Atheros cards (and from the above that seems be true in your case), they are locked in EEPROM (see here). However, you shouldn't need to, it should be set with a regdomain suitable for the domain in which you bought the device (I assume US).

The output of wpa_cli above is perfectly fine, but it doesn't provide any information as to what the issue might be, for that you need to enable 'debug', so:

```
wpa_supplicant_wlan0="-Dnl80211 -dd -f /var/log/wpa_supplicant.log"
```

... then pastebin the log and I'll see if I can identify the issue.

BTW, you might also take a look at the output of dmesg when the ath9k module is loaded (I believe the ath9k driver requires firmware, but don't quote me on that), and 'iw event -f' when the card is active and associating/associated.

HTH & best ... khay

----------

## Tony0945

 *khayyam wrote:*   

> 
> 
> The output of wpa_cli above is perfectly fine, but it doesn't provide any information as to what the issue might be, for that you need to enable 'debug', so:
> 
> ```
> ...

 

Aha! First problem, I'm looking for "road2hell" and the DLINK router is advertising "Road2hell", as always with good intentions.

EDIT:From the router log

```
[INFO]   Sat Mar 10 13:50:20 2018   Road2hell: Wireless system with MAC address A0F3C17721FA secured and linked

[INFO]   Sat Mar 10 13:50:20 2018   Road2hell: Wireless system with MAC address A0F3C17721FA associated

[INFO]   Sat Mar 10 13:50:20 2018   Above message repeated 1 times
```

I can now ping the address in /etc/conf.d/net (192.168.0.2), but not the address assigned by the router (192.168.0.109)

EDIT2: Changed /etc/conf.d/net config line

```
#config_wlan0="192.168.0.2  netmask 255.255.0.0"

config_wlan0="dhcp"

```

 Now I can ping 192.168.0.109 bit ifconfig says "inactive". Still I can ssh in. And ifconfig stopped saying "inactive"

I have to say it's working unless someone can suggest additional tests?

Next stop, trying to use the card as an AP.

Once again, Khayyam's knowledge of linux and gentoo have saved me. And I have learned something. Than you very very much, my friend.

----------

## Tony0945

HELP!!!!!

cfg80211 is continually logging to dmesg and also filliing up /var/log/messages

How to shut it off?

```
[13049.080287] cfg80211: World regulatory domain updated:

[13049.080311] cfg80211:  DFS Master region: unset

[13049.080326] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)

[13049.080357] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)

[13049.080385] cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz, 92000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13049.080408] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)

[13049.080436] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13049.080465] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)

[13049.080490] cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)

[13049.080513] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)

[13049.080536] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)

[13052.274832] cfg80211: World regulatory domain updated:

[13052.274852] cfg80211:  DFS Master region: unset

[13052.274862] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)

[13052.274882] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)

[13052.274898] cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz, 92000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13052.274911] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)

[13052.274927] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13052.274944] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)

[13052.274959] cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)

[13052.274972] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)

[13052.274985] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)

[13055.481240] cfg80211: World regulatory domain updated:

[13055.481263] cfg80211:  DFS Master region: unset

[13055.481279] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)

[13055.481311] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)

[13055.481339] cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz, 92000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13055.481362] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)

[13055.481389] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13055.481419] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)

[13055.481443] cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)

[13055.481466] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)

[13055.481489] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)

[13058.689928] cfg80211: World regulatory domain updated:

[13058.689952] cfg80211:  DFS Master region: unset

[13058.689968] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)

[13058.689999] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)

[13058.690142] cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz, 92000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13058.690167] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)

[13058.690195] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)

[13058.690224] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)

[13058.690249] cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)

[13058.690272] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)

[13058.690295] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)

```

EDIT:

It's working good. But the log is filling up and i can't even see what errors are in dmesg because cfg80211 is flooding it. 

I enabled AP mode with hostapd per the wiki and I can see the SSID on my Galaxy 5 and authenticate. It hangs on trying to get an ip address but the wireless stuff seems to working but I need to get this endless repitition out of dmesg and /var/log/messages. I

ve shut down the computer to conserve disk space (it's an old IDE drive).

----------

## khayyam

 *Tony0945 wrote:*   

> cfg80211 is continually logging to dmesg and also filliing up /var/log/messages How to shut it off?

 

Tony0945 ... I think you may have CONFIG_CFG80211_REG_DEBUG enabled.

thanks for the kind words & best ... khay

----------

## Tony0945

 *khayyam wrote:*   

>  *Tony0945 wrote:*   cfg80211 is continually logging to dmesg and also filling up /var/log/messages How to shut it off? 
> 
> Tony0945 ... I think you may have CONFIG_CFG80211_REG_DEBUG enabled.
> 
> thanks for the kind words & best ... khay

  You're Welcome.  I turned that one off and another under MAC80211 and changed CONFIG_CFG80211 back to "y" from "m".  Now, it only posts once at boot in dmesg and not at all in /var/log/messages. Sorry, I panicked.

Continued working on AP and got it up. Scanned with my phone, found the network and logged in. It was stuck at getting an ip address but that was just Dnsmasq DHCP configuration. Now the phone, connects, logs in and attempts to access the internet.  It fails but that's either DNS resolution or routing. I think it's routing because the phone is connecting to a bogus network consisting of the one machine. The cable modem is on another network.  

I'm putting it aside until I work up a nice web interface. I already knew that the wired router part of this project worked and with the cell phone connecting, i have every expectation that the wireless will too if I connect the WAN cable to the modem.

I did learn a lot more about networking and wireless from this experiment.

----------

## bunder

Hi Tony, I seem to be having the same issue on a new build, can I possibly see your working kernel config?

Thanks

----------

## Tony0945

Here's a pastebin http://dpaste.com/3PBPJ06

----------

## bunder

Cool, thanks...  It looks like you're using 4.4?  I must be having a different issue.  I'll throw up another thread then.

Thanks again

----------

