7

Okay, so I've been needing to increase my wireless adapter's txpower.

I have an internal RTL8188EE, and a TP-Link USB adapter.

I bought the TP-Link after reading how well it worked with linux, and turns out it doesn't run nearly as well as the RTL8188EE I already had. Anyway, I don't think the TP adapter can increase txpower at all, but I know for a fact the internal adapter can. I'm somewhat new to Linux, I first installed Ubuntu (I think 16.04?) alongside Windows back in like 2016 but didn't get real into it until the past year or so, and I've been distro hopping to find the best one for me, so right now I have an internal 256GB Crucial SSD with 6 different root partitions, each one having a corresponding 100GB home partition on my external Hard Drive. I have Manjaro Deepin, Solus Budgie, Ubuntu 18.04, Fedora 30, Zorin 15, and MX Linux, along with KDE Neon on another External HDD.

So, when I began trying to increase my txpower, I tried all the solutions listed on here, itsFOSS, the Arch/Manjaro forums, and anywhere else I could find.

I've tried txpower-unlocker, I've tried wireless-regdb-pentest, I've tried everything. I've hit a ridiculous number of walls with all the attempts, except for with Manjaro. I somehow not only got it to work, but actually have it permanently set to 30 dBm, every boot. But the same (or equivalent) steps given for the other distros I have do not work at all. With Ubuntu, I tried the Ubuntu-specific txpower-unlocker git script. It gives me no errors, it'll reg set to BO, but when I give the commands:

ifconfig wlp2s0 down
iw reg set BO
iwconfig wlp2s0 txpower 30
ifconfig wlp2s0 up

and then

iwconfig wlp2s0

It still shows

[matt@localhost ~]$ sudo iwconfig wlp2s0 txpower 30.00
[matt@localhost ~]$ sudo ifconfig wlp2s0 up
[matt@localhost ~]$ iwconfig
virbr0-nic  no wireless extensions.
wlp2s0    IEEE 802.11  ESSID:"NETGEAR35"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 28:80:88:C4:BF:DB   
          Bit Rate=72.2 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Power Management:off
          Link Quality=70/70  Signal level=-36 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:2   Missed beacon:0

I have tried it with automated scripts, I've tried doing it manually. I've tried everything. Like I said, I know it's got nothing to do with the card, because it works on Manjaro, but even then after I updated to the newest Linux kernel on Manjaro it refuses to change, just like all the rest. I've had to stay at 4.19.14 to keep it at 30. And sure enough, my 10Mb broadband connection stays at 10mbps on every speed test there is when I'm on Manjaro, and I consistently download at 1-1.3 Mbps, whereas it'll wildly fluctuate with most of the other distros. MX Linux and Zorin seem to be pretty consistent, so I haven't had to bother trying to change it since they get between 9.5 and 10Mb without it. But what I don't understand, and would love it if someone could explain it to me, is how I can have 3 different distributions, running on the same computer, using the same Linux kernel (5.0.8), on MX, Zorin, and Ubuntu 18.04.3, and MX and Ubuntu are based on Debian, and Zorin is based on Ubuntu, yet the wireless quality varies so greatly?

I absolutely love Linux so far, to the point where I've realized that I'll never find one perfect distro and I'll probably always have 3 to 4 permanent ones, but that's precisely why this drives me crazy. I've put Linux distros on my Aunt and girlfriend's computers (to their approval, they couldn't believe how much faster their machines run now), but issues like the txpower thing that make NO sense to me cause me to obsess and spend hours and hours glued to the computer getting frustrated as hell, to the point where the other day my girlfriend rolled over and said, "sudo make me a cup of coffee." cause she figured that would work. ...it did. But anyway, sorry for the diatribe, this is my first Linux forum post, I've been insistent on figuring all this out without asking for any help myself.

2 Answers 2

8

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.

4
  • 1
    You cannot assume without testing it yourself that an article written 7 years ago works as it is... I don't see the interest in copying and pasting something without testing it. The first step is wrong, there is no package in Ubuntu called libnl-dev...
    – kcdtv
    Commented Mar 30, 2020 at 13:24
  • as written in the first line i did this in raspbian debian 10 on my raspberry pi. If i remember well i did this in lubuntu 16.04 either. but if you prefer i can delete the whole answer Commented Apr 2, 2020 at 6:45
  • I should have investigated a bit more before my comment... ` libnl-dev.` does not exist anymore but there is libnl-3-dev. I've tryed with this package in modern Ubuntu and everything worked. Instead of deleting the post you could simply change the package in the first command line. Sorry for not doing the homework correctly and thanks for your answer
    – kcdtv
    Commented Apr 16, 2020 at 13:40
  • 1
    This solution, though complicated, works for me. However, what I also found is that after the regulatory database is rebuilt, I can change txpower by switching to different countries. The txpower will be set to the max txpower specified for that country in db.txt. I have cooked up a repo to make this process easier. Commented Mar 22, 2021 at 0:48
1

This is an amazing guide that works well in 2023 with a few tweaks. To install the dependencies in a modern Ubuntu/Debian:

apt install python3-future python3-m2crypto libgcrypt20 libgcrypt20-dev libnl-genl-3-dev

Download the latest versions of crda and wireless-regdb-master from:

https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/snapshot/wireless-regdb-master-2023-09-01.tar.gz 
https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/crda.git/snapshot/crda-4.15.tar.gz

When you run make for crda-4.15, and it complains about syntax errors in key2pub.py, that means you need to tweak that file to be python3-compatible:

sed -i -E 's/ord\(v([0-9]+)\)/v[\1]/g; s/ord\(v\)/v/g; s/ImportError, e/ImportError as e/g; s/print /print(/g; s/keys\(\)\)\)/keys\(\)\)\)\)/g; s/xrange/range/g;' key2pub.py

After that, proceed with the original guide! Thanks OP!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .