Fixing WiFi regulatory rule in Unix

Wifi routers usually specify the regulatory rules for all devices connected to their network. In rare cases a router may go rouge and specify the wrong regulatory domain, which might effect the quality of the connection and at times may make the network unreachable even if the network says that its connected.

Below are the debug messages from the command “dmesg” in one such case:

[ 8036.527533] cfg80211: 2402000 KHz – 2482000 KHz @ KHz), (N/A mBi, 2000 mBm)
[ 8036.527538] cfg80211: Updating information on frequency 2472 MHz for a 20 MHz width channel with regulatory rule:
[ 8036.527544] cfg80211: 2402000 KHz – 2482000 KHz @ KHz), (N/A mBi, 2000 mBm)
[ 8036.527549] cfg80211: Disabling freq 2484 MHz
[ 8036.527558] cfg80211: Regulatory domain changed to country: GB
[ 8036.527561] cfg80211: (start_freq – end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[ 8036.527567] cfg80211: (2402000 KHz – 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm)
[ 8036.527573] cfg80211: (5170000 KHz – 5250000 KHz @ 40000 KHz), (N/A, 2000 mBm)
[ 8036.527578] cfg80211: (5250000 KHz – 5330000 KHz @ 40000 KHz), (N/A, 2000 mBm)
[ 8036.527583] cfg80211: (5490000 KHz – 5710000 KHz @ 40000 KHz), (N/A, 2700 mBm)
[ 8310.345982] cfg80211: Calling CRDA to update world regulatory domain

{adinserter 2}
To fix the above error we need to force the correct domain onto the wireless device. This can be done with the “iw” command in unix.

You can install “iw” on ubuntu using the following command

sudo apt-get install iw

Once installed you can view your current setting using the following command:

sudo iw reg get

It should return you an output similar to this (provided you are in the US)

country US:
(2402000 KHz – 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm)
(5170000 KHz – 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm)
(5250000 KHz – 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
(5490000 KHz – 5710000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
(5735000 KHz – 5835000 KHz @ 40000 KHz), (300 mBi, 3000 mBm)

The country code can be decoded as follows:
if USA then country code = US
if china then country code = CN
if Australia then country code = AU
if Great Britain then country code = GB
if India then country code = IN
ect.

To set the correct country code, use the following command (change the country code to the one your router supports)

sudo iw reg set US

PS: If you have problems with ‘sudo apt-get install iw’ command. Make sure in your Software Sources that you have a tick next to “Community-maintained Open Source software (Universe)”

  • Steve Newall

    Note: this is not a full “fix”.  The domain set by the “iw reg set” command overlays the original setting with the new set of restrictions for the new domain.  For example, If the original domain is GB, then channels 1-13 are available and the max transmit power is 20dBm. By setting the domain to US, this restricts the channels to the US allowed channels, 1-11, but it DOES NOT increase the maximum transmit power to 27dBm which is the value allowed in the US.   Conversely, if a US device is set into GB mode, only channels 1-11 will be available (the max allowed by the original setting) and not 1-13.  The only real solution that I’ve been able to find is to reprogram the EEPROM in the radio to change it’s original CRDA setting.  This allows the radio to operate correctly.  I’ve had to reprogram a few thousand devices that were shipped to me with the incorrect setting direct from the manufacturer.  We asked for US settings but they came with GB settings.

    • Marcel Partap

      “reprogram a few thousand devices”
      lol omfg ^^
      ..can well remember that temp job at a warehouse where our mission was to put a WPA2-capable firmware on a never-ending stream of dsl-routers.. unpackage unwrap connect wait flash wait disconnect rewrap repackage stick button on box NEXT what a bliss haha

  • Pingback: Did Ubuntu 12.04 support wireless 5G ?()