TP Link TL-WN725N USB WiFi Configuration in Linux

I like using an old fashioned desktop machine at home. It’s always on and acts as a hub machine, or “server”, if you will. Unfortunately, my current home isn’t cabled with Ethernet, and I’ve recently rearranged furniture and needed a wireless card. We had a TP-Link TL-WN725N laying around and decided to use that.

I’m using Arch Linux and do all configuration from the command line. I found some conflicting information online about setting these devices up so I wanted to post my config in case it helps someone else.

larntz neofetch screenshot

The trick to getting these devices working is using the deprecated wext driver in wpa_supplicant.

Device Details

These adapters use a Realtec 8188EUS chipset, and, at least on Arch, the firmware is installed with the base system.

First the output from lsusb | grep 8188. The grep command supresses the output of lsusb that we don’t care to see, i.e., other usb devices.

1
2
3
larntz@z400> lsusb | grep 8188

Bus 001 Device 002: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter

We can do the same thing with lsmod to verify that the driver [r8188eu] has been loaded by the kernel.

1
2
3
4
larntz@z400> lsmod | grep 8188
r8188eu               491520  0
lib80211               16384  1 r8188eu
cfg80211              798720  1 r8188eu

The device should show up as a network adapter using the ip link command.

1
2
3
4
5
6
7
larntz@z400> ip link 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 18:a9:05:b9:30:b2 brd ff:ff:ff:ff:ff:ff
3: wlp0s26f7u6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether 30:b5:c2:05:72:de brd ff:ff:ff:ff:ff:ff

You’ll often see tutorials usingwlan0 as the network device name. I’m not sure which distros might use that naming convention in 2019, but Arch, CentOS, and Ubuntu aren’t among them. You can see above my wireless adapter is named wlp0s26f7u6.

Device Configuration

To configure my wireless network I am using wpa_supplicant. To make this work I needed to create a wpa_supplicant configuration file. Then we can bring up the connection and tell dhcpcd to grab an IP address.

One caveat with this chipset is that we must tell wpa_supplicant to use the deprecated driver wext and not nl80211.

Configuration File wpa_supplicant.conf

Configuration files go in /etc/wpa_supplicant/. If you want to start this card and connect on boot my suggestion is to name your configuration file using this convention wpa_supplicant-wext-interface.conf (wext to specify the driver). On my system this file is called /etc/wpa_supplicant/wpa_supplicant-wext-wlp0s26f7u6.conf. Later I will show how to setup systemd to connect the wireless interface on boot.

My file looks like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# specify thelocation of the controller interface socket. 
ctrl_interface=/run/wpa_supplicant

# allow frontend to be used by all users in 'wheel' group. if you don't
# have this or you aren't part of the wheel group you *must* run wpa_supplicant as root (not sudo).
ctrl_interface_group=wheel

# allow wpa_supplicant to overwrite the config file
update_config=1

# country code for the device
country=US

# defines wireless network specific settings
network={
        # SSID of network
        ssid="SUPER_WIFLY"
        # plantext psk
        # psk="hacktheplanet!"
        # hashed psk
        psk=49a10b06e9031de9dd49895a9cc5bcbe0ee3642119ba7a64ef93d49426c9751e
}

I used wpa_password to generate a hashed password for use in the conf file. However, you can use a plaintext password if you prefer by putting it in quotes after psk=.

Using wpa_password is simple. Run it as wpa_password [SSID] [PASSWORD] replacing SSID and PASSWORD with the appropriate values. It will then output a network configuration block that you can append to your interface config file.

1
2
3
4
5
6
larntz@z400> wpa_passphrase SUPER_WIFLY hacktheplanet!
network={
        ssid="SUPER_WIFLY"
        #psk="hacktheplanet!"
        psk=49a10b06e9031de9dd49895a9cc5bcbe0ee3642119ba7a64ef93d49426c9751e
}

Alrighty then, now that we have a everything squared away we can connect to the network and continue with life. While testing I created a two line bash script to bring up the network

1
2
3
4
5
larntz@z400> cat tp_wifi.sh
#!/bin/bash

sudo wpa_supplicant -B -D wext -i wlp0s26f7u6 -c /etc/wpa_supplicant/wpa_supplicant-wext-wlp0s26f7u6.conf
sudo dhcpcd wlp0s26f7u6

The script starts wpa_supplicant and then tells dhcpcd to try to get an IP.

On the wpa_supplicant -B tells wpa_supplicant to go into the background after initializing, -D wext specifies the driver we need to use for this card, -i wlp0s26f7u6 is the interface we want to use, and -c /etc/wpa_supplicant/wpa_supplicant-wext-wlp0s26f7u6.conf specifies the configuration files.

To verify we have wpa_supplicant setup correctly run those commands and verify that you are connected and have an ip address. You can check that with the ip addr command. If you have an inet line under your wireless adapter you should also have network access.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
larntz@z400> ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 18:a9:05:b9:30:b2 brd ff:ff:ff:ff:ff:ff
3: wlp0s26f7u6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 30:b5:c2:05:72:de brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.88/24 brd 10.0.0.255 scope global noprefixroute wlp0s26f7u6
       valid_lft forever preferred_lft forever

Starting the Interface on Boot

This’s great so far, but I really prefer the network come up on it’s own after a reboot. So, I chose to use systemd.

Systemd is going to start wpa_supplicant for us, BUT our configuration file must be named in a specific way. That way is wpa_supplicant-wext-_interface_.conf. That is the reason I suggested using that naming confection.

There are two ways we can force the interface to start using the wext driver. First, we could edit the standard wpa_supplicant@.service, or we can create a n ew wpa_supplicant-wext@.service unit. One isn’t provided for us, but there is a wpa_supplicant-nl80211@.service file we can copy and edit. So, yay!

That”s what we’re gonna do.

1
2
3
larntz@z400> cd /usr/lib/systemd/system/
larntz@z400> sudo cp wpa_supplicant-nl80211@.service wpa_supplicant-wext@.service
larntz@z400> sudo vi wpa_supplicant-wext@.service

Now we have our wpa_supplicant-wext@.service file open we just need to find and replace all instances of nl80211 with wext. Easy peasy lemon squeezy, my friend.

In vi use :%s/nl80211/wext/g to find and replace all nl80211 with wext.

After the replace our new .service file should look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
larntz@z400> cat /usr/lib/systemd/system/wpa_supplicant-wext@.service
[Unit]
Description=WPA supplicant daemon (interface- and wext driver-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
Before=network.target
Wants=network.target

# NetworkManager users will probably want the dbus version instead.

[Service]
Type=simple
ExecStart=/usr/bin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-wext-%I.conf -Dwext -i%I

[Install]
Alias=multi-user.target.wants/wpa_supplicant-wext@%i.service

Now we can enable the systemd service for our wireless interface by sticking the interface name in between the @ and the .

1
larntz@z400> sudo systemctl enable wpa_supplicant-wext@wlp0s26f7u6.service

Conclusion

On boot the wireless interface should be started and recieve an address via DHCP.

If these instructions aren’t working for you or you see an error please send me an email and let me know.

References

Related Content