What you want to achieve is not that easy, but it can be done.
First of all, increasing the txpower might violate the law. Thats one reason why you cannot increase that power beyond a certain value, without manipulating / circumventing these built in restrictions.
The following instructions worked like charm using my Raspberry Pi 3b+ with debian buster and debian stretch. It should work with minor modifications on other distributions also.
If you open a terminal and type iw reg get
you should see the limitations for your country:
iw reg get
global
country 98: DFS-UNSET
(2402 - 2472 @ 40), (N/A, 20), (N/A)
(2457 - 2482 @ 25), (N/A, 20), (N/A), NO-IR
(2474 - 2482 @ 8), (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 - 5710 @ 160), (N/A, 20), (0 ms), DFS, NO-IR
(57240 - 63720 @ 2160), (N/A, 0), (N/A)
phy#1
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)
phy#0
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)
If it is unset you get the generic "world" country code.
To set your country you could type iw reg set <country-code>
This post here describes pretty good, what you have to do, to circumvent the restriction.
Step 1 - Install Packages
apt install python-future python-m2crypto libgcrypt20 libgcrypt20-dev libnl-dev
Step 2 - Download CRDA and the regulatory database files
wget https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/snapshot/wireless-regdb-master-2019-06-03.tar.gz
wget https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/crda.git/snapshot/crda-4.14.tar.gz
Step 3 - Unpack the files
tar xfv crda-4.14.tar.gz
tar xfv wireless-regdb-master-2019-06-03.tar.gz
Step 4 - Manipulate the restrictions
Open the db.txt file in terminal nano wireless-regdb-master-2019-06-03/db.txt
Scroll down to your countrycode. Mine is DE for Deutschland / Germany:
country DE: DFS-ETSI
(2400 - 2483.5 @ 40), (100 mW)
(5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW, wmmrule=ETSI
(5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW, wmmrule=ETSI
(5470 - 5725 @ 160), (500 mW), DFS, wmmrule=ETSI
# short range devices (ETSI EN 300 440-1)
(5725 - 5875 @ 80), (25 mW)
# 60 GHz band channels 1-4 (ETSI EN 302 567)
(57000 - 66000 @ 2160), (40)
I modify the first line, that corresponds to the 2.4 GHZ frequency band to my needs and leave the rest as it was because i am not interested in the 5 or 60 GHZ bands:
country DE: DFS-ETSI
(2400 - 2483.5 @ 40), (2000 mW)
(5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW, wmmrule=ETSI
(5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW, wmmrule=ETSI
(5470 - 5725 @ 160), (500 mW), DFS, wmmrule=ETSI
# short range devices (ETSI EN 300 440-1)
(5725 - 5875 @ 80), (25 mW)
# 60 GHz band channels 1-4 (ETSI EN 302 567)
(57000 - 66000 @ 2160), (40)
Apart from that it seems that my wireless cards AWUS036NHA seem to be stuck in a country set by the manufacturer. In my particular case it is GB. So i have to change that one:
So i modify
country GB: DFS-ETSI
(2402 - 2482 @ 40), (20)
(5170 - 5250 @ 80), (20), AUTO-BW, wmmrule=ETSI
(5250 - 5330 @ 80), (20), DFS, AUTO-BW, wmmrule=ETSI
(5490 - 5710 @ 160), (27), DFS, wmmrule=ETSI
# 60 GHz band channels 1-4, ref: Etsi En 302 567
(57000 - 66000 @ 2160), (40)
to
country GB: DFS-ETSI
(2402 - 2482 @ 40), (30)
(5170 - 5250 @ 80), (20), AUTO-BW, wmmrule=ETSI
(5250 - 5330 @ 80), (20), DFS, AUTO-BW, wmmrule=ETSI
(5490 - 5710 @ 160), (27), DFS, wmmrule=ETSI
# 60 GHz band channels 1-4, ref: Etsi En 302 567
(57000 - 66000 @ 2160), (40)
Step 5 - Make regulatory.bin
cd
into your wireless-regdb-master-2019-06-03
folder and type make
cd wireless-regdb-master-2019-06-03/
make
This will create a few new files.
wireless-regdb-master-2019-06-03# ls
CONTRIBUTING dbparse.pyc LICENSE regulatory.bin.5 root.key.pub.pem sha1sum.txt
db2bin.py db.txt Makefile regulatory.db root.x509.pem web
db2fw.py debian-example README regulatory.db.5 sforshee.key.pub.pem wireless-regdb.spec
dbparse.py gen-pubcert.sh regulatory.bin regulatory.db.p7s sforshee.x509.pem
Step 6 - Backup your files
Before overwriting our original regulatory files i suggest you do a backup.
Do a backup of
cp /lib/firmware/regulatory.db /lib/firmware/regulatory.db-backup
cp /lib/firmware/regulatory.db.p7s /lib/firmware/regulatory.db.p7s-backup
cp /lib/crda/regulatory.bin /lib/crda/regulatory.bin-backup
Step 7 - Apply modifications
From inside your wireless-regdb-master-2019-06-03
folder do copy the new created files from Step 5 to their appropriate locations:
cp regulatory.db regulatory.db.p7s /lib/firmware/
cp regulatory.bin /lib/crda/
Step 8 - Sign / Validate
From inside your wireless-regdb-master-2019-06-03
folder do copy the *.pub.pem
files to the unpacked crda folder:
cp *.pub.pem ../crda-4.14/pubkeys
Do also copy the *@*.pub.pem
file from inside your /lib/crda/pubkey
to your unpacked crda/pubkeys folder
cp /lib/crda/pubkeys/*@*pub.pem ../crda-4.14/pubkeys/
Then cd
into that folder.
cd ../crda-4.14/
and type make && make install
Step 8.1 - The Error-Case
In case you receive the following error:
ERROR: The file: /usr/lib/crda/regulatory.bin is missing. You need this in place in order
to verify CRDA. You can get it from:
git://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git
Once cloned (no need to build) cp regulatory.bin to /usr/lib/crda/regulatory.bin
Use "make noverify" to disable verification
Makefile:100: recipe for target '/usr/lib/crda/regulatory.bin' failed
make: *** [/usr/lib/crda/regulatory.bin] Error 1
open the Makefile nano Makefile
and change line
REG_BIN?=/usr/lib/crda/regulatory.bin
to
REG_BIN?=/lib/crda/regulatory.bin
and type make clean && make && make install
Step 9 - Check if your hack was applied
Reboot your system and type iw reg get
The numbers now should have been modified to your needs:
iw reg get
global
country 98: DFS-UNSET
(2402 - 2472 @ 40), (N/A, 20), (N/A)
(2457 - 2482 @ 25), (N/A, 20), (N/A), NO-IR
(2474 - 2482 @ 8), (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 - 5710 @ 160), (N/A, 20), (0 ms), DFS, NO-IR
(57240 - 63720 @ 2160), (N/A, 0), (N/A)
phy#1
country GB: DFS-ETSI
(2402 - 2482 @ 40), (N/A, 30), (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)
phy#0
country GB: DFS-ETSI
(2402 - 2482 @ 40), (N/A, 30), (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)
Step 10 - Adjust the txpower
Now you should be able to adjust the txpower.
Therefor turn of your wifiadapter. Adjust its txpower and turn is back on.
ifconfig wlan1 down
iw dev wlan1 set txpower fixed 2500
ifconfig wlan1 up
With iwconfig
you can check if changes took effect. For some reason i only see changes when i am connected to an AP:
root@raspberrypi:~# iwconfig
wlan2 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=30 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
lo no wireless extensions.
wlan1 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=30 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
eth0 no wireless extensions.
wpa_supplicant -c StationE03.conf -i wlan1 &
[1] 792
root@raspberrypi:~# Successfully initialized wpa_supplicant
wlan1: SME: Trying to authenticate with e8:df:70:38:db:5a (SSID='StationE03' freq=2427 MHz)
wlan1: Trying to associate with e8:df:70:38:db:5a (SSID='StationE03' freq=2427 MHz)
wlan1: Associated with e8:df:70:38:db:5a
wlan1: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan1: WPA: Key negotiation completed with e8:df:70:38:db:5a [PTK=CCMP GTK=CCMP]
wlan1: CTRL-EVENT-CONNECTED - Connection to e8:df:70:38:db:5a completed [id=0 id_str=]
wlan1: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=DE
root@raspberrypi:~# iwconfig
wlan2 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=30 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
lo no wireless extensions.
wlan1 IEEE 802.11 ESSID:"StationE03"
Mode:Managed Frequency:2.427 GHz Access Point: E8:DF:70:38:DB:5A
Bit Rate=52 Mb/s Tx-Power=25 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=70/70 Signal level=-27 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:47 Missed beacon:0
eth0 no wireless extensions.
root@raspberrypi:~# iw reg get
global
country DE: DFS-ETSI
(2400 - 2483 @ 40), (N/A, 33), (N/A)
(5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
(5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
(5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
(5725 - 5875 @ 80), (N/A, 13), (N/A)
(57000 - 66000 @ 2160), (N/A, 40), (N/A)
phy#1
country GB: DFS-ETSI
(2402 - 2482 @ 40), (N/A, 30), (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)
phy#0
country GB: DFS-ETSI
(2402 - 2482 @ 40), (N/A, 30), (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)
Higher dBm values do not automatically mean better connection. You have to follow your adapter specifications and setup these values accordingly. For Example my AWUS036NHA supports up to 28 dBm while my AWUS036NH supports up to 33 dBm which is 2000mw.
Also do not forget that you migh violate the law of the country that you are. You might disturb radars (especially on the 5ghz band).
Using to high values is, as far as i know, not healthy.
Better solutions are: Directional Antennas, or Parabolic Antennas or Wireless Repeater.