Настройка usb wifi адаптера linux

SCHILLERNET

I confess, I rarely use Linux and when I do it’s a challenge. Linux is easy when you use it day in and out but on the one off occasions it is certainly challenging to pick up. It has its quirks and it takes a little time to get to grips with them.

I’ve recently built a HP MicroServer to use as NAS. Rather than use an off the shelf NAS distro I went for something different which would give me some flexibility, Ansible-NAS. I’m using Ubuntu server because the G7 MicroServer doesn’t have a lot of grunt and didn’t want to waste clocks on a GUI. It’s going to be on most of the time so less is best as is so often the case.

I intend to cover the Ansible-NAS install later but for now I wanted to document my experience of connecting a USB Wi-Fi adapter to Ubuntu if the driver is not natively supported. Some of this is simple, obvious almost but if you don’t know what to type or what to look for it’s going to take some digging.

Hopefully this little journey will introduce you to some useful tools and how to configure a USB adapter.

Step 1: Don’t disconnect

You’re may have to download some drivers and probably install some software, if you already have an internet connection keep it.

You’ll need the wireless tools to use iwconfig.

$ sudo apt get wireless-tools

Step 2: Identify your Hardware

These steps are covered quite well here. I’ll summarise and focus on a USB device.

The device should be shown in lsusb even if there isn’t a driver:

$ lsusb Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 002: ID 0bda:f179 Realtek Semiconductor Corp.

That’s a good start, this suggests the USB stick is physically detected. Make a not of the “ID” you might need it later.

Step 3: Is there a driver?

There are a few ways that this can be identified, Its quite well documented here.

The first is lshw -C network. You might get a lot of information back depending on your setup.

You can also use the ip link show command to see if the adapter is listed there.

I didn’t have anything listed from lshw but if you get something it might look like this:

*-network:1 description: Wireless interface physical id: 2 bus info: usb@1:2 logical name: wlx00e0262f73ec serial: 00:e0:26:00:00:00 capabilities: ethernet physical wireless configuration: broadcast=yes driver=rtl8188fu multicast=yes wireless=IEEE 802.11bgn

Step 4: Find a driver

The first option is am update, see if anything gets pulled down:

$ sudo apt update

(there are almost always some updates…)

$ sudo apt upgrade

Go back to step 3, have another look. If no joy check the supported hardware sheet. You’ll need the ID from earlier to cross-reference. If your hardware is listed then you might have other issues and at this point I’d suggest you go back to the Ubuntu documentation linked to earlier to see what might be preventing the driver from loading.

Читайте также:  Linux dying light black screen

If your hardware isn’t supported then google the hardware ID from earlier and some relevant keywords.

What you are likely to find are results suggesting you get something from GitHub and install that. Read a few forum posts before you decide to download something. In my case some drivers had better install notes than others and one of the drivers was cited to have better support (dkms?) than another. I checked out the README and decided it was well put together. For my USB adapter I went for https://github.com/kelebek333/rtl8188fu.

The installation instructions are well documented and different for each case. Follow the guidance you find.

Post install re-attempt step 3 and see what you get. I advise a reboot if you don’t see the adapter.

If like me the adapter is not showing up there were a few recommendations, try these…

$ sudo depmod -a is an updated dependency list is generated by depmod -a to make sure that the module we’re installing is aware of all existing modules and dependencies.
$ sudo update-initramfs -u Read about this here.

If you are still not seeing the adapter in lshw you might have to go back to the drawing board.

Step 5: Configuring networking

A learning curve for me was learning to use netplan. We need the interface name. There are many ways to find this:

Lets use the output from iwconfig because its concise. The interface name might look something like this “wlx00e0262f73ec”.

We need to edit 01-netcfg.yaml

$ sudo nano /etc/netplan/01-netcfg.yaml

You want something like this, but there are more examples here. Remember, spacing is super important, it must be consistent and no tabs!

network: version: 2 renderer: networkd wifis: wlx00e0262f73ec: dhcp4: yes dhcp6: yes access-points: "ESSID": password: "y0urpa55phras3"

Save with Ctrl+O , exit with Ctrl+X.

After that run $ sudo netplan apply –debug

Use debug because its good to know what’s expected and what isn’t. My connection works but I do have the following warning:

The unit file, source configuration file or drop-ins of netplan-wpa-wlx00e0262f73ec.service changed on disk. Run 'systemctl daemon-reload' to reload units.

It’s a warning so not the end of the world, if you see other issues it might be work investigating them before continuing.

Run this to prompt getting a DHCP lease (if using DHCP) $ sudo dhclient wlx00e0262f73ec.

At this point you can check to see if you have an IP address $ ip address show dev wlx00e0262f73ec If you have, ALL GOOD.

Читайте также:  Linux kernel sources git

Troubleshooting

I was not seeing what I expected so I did some further troubleshooting. The interface didn’t appear to be coming up.

This command can bring the interface up $ sudo ip link set wlx00e0262f73ec up

Then there were some log files to check $ dmesg | grep -e wlp -e network, which didn’t offer anything.
$ cat /var/log/syslog | grep -i network did and I could see these messages which could be relevant:

netplan-wpa@wlx00e0262f73ec.service: Failed to execute command: No such file or directory netplan-wpa@wlx00e0262f73ec.service: Failed at step EXEC spawning /sbin/wpa_supplicant: No such file or directory

wpasupplicant didn’t appear to be installed so $ sudo apt install wpasupplicant.

The errors had cleared but I still wasn’t connecting to my network.

At this point I started using $ networkctl and could see that everything looked ok.

IDX LINK TYPE OPERATIONAL SETUP 4 wlx00e0262f73ec wlan no-carrier configuring

I used $ sudo iwlist wlx00e0262f73ec scan to give me a list of all the networks the adapter could see. It could see networks just fine. All the 2.4GHz networks… that’s right, I’d specified a 5GHz network in the netplan config and this is a 2.4GHz adapter!

After correcting that mishap everything was ALL GOOD.

Other issues

Some people has reported that the driver was not loading after reboots. This was suggested to load the driver at boot (rtl8188fu was the driver name):

$ echo rtl8188fu | sudo tee -a /etc/modules (adds to the list of kernel modules that should be loaded at boot time.

Источник

Install USB Wifi dongle on Ubuntu 18.04

Imgur

To my benefit or downfall, whichever way you look at it, I bought the Comfast CF-915AC USB Wifi Adapter from Amazon. This proved to be super difficult to install. Me being a noob in Wifi networking in Linux. After 3 part time days of fiddling with it, it is now work. Here’s my steps and how I got it working.

Firstly, the USB Wifi Adapter came with a CD Rom to install the driver. I don’t have a CD Rom drive, so I hit Google, and started looking for what driver to use and how to install.

Under the COMFAST Wiki it’s listed as using the RTL8811AU Realtek chipset.

I tried looking for RTL8811AU drivers via Google, since the product only came with a disk for installation and couldn’t find any drivers that matched. The Comfast official driver download links returned 404 page not found errors in Chinese!

I then found this Ubuntu formus blog and it said that the RTL8812AU driver could be used.

I then followed this StackExchange answer to get the USB driver RTL8812AU correctly installed:

Using ifconfig , the interface was present, but it didn’t have an IP address.

I am using netplan and my /etc/netplan/01-netcfg.yml currently looks like this:

network: version: 2 renderer: networkd ethernets: enp6s0: dhcp4: true nameservers: addresses: [8.8.8.8,8.8.4.4] wifis: wlx40a5ef40734c: dhcp4: true nameservers: addresses: [192.168.0.1, 8.8.8.8] access-points: "my-wifi-router-name": password: "my-password" 

This is becasue I have WPA security enabled, so the netplan yaml wasn’t work.

Читайте также:  Openvpn запуск при старте linux

I then followed this StackExchange answer:

Using the wpasupplicant package, I generated a wpa.conf file as suggested, and using these commands could connect to the Wifi Router

# install package sudo apt install wpa_supplicant # generates a file wpa_passphrase SSID PASSWORD > wpa.conf # command uses the file to connect, and runs as a daemon sudo wpa_supplicant -i wlx40a5ef40734c -c wpa.conf -D wext -B 

Everything is now working. After a reboot, the Wifi still connects. I am smiling!

Steps only

Here are the commands / steps only extracted from the above blogs.

Install driver

First remove any old drivers in /usr/src

sudo apt purge rtl8812au-dkms sudo apt install git git clone https://github.com/abperiasamy/rtl8812AU_8821AU_linux.git cd rtl8812AU_8821AU_linux sudo make -f Makefile.dkms install sudo modprobe rtl8812au 

Can view that driver is covered:

modinfo rtl8812au | grep A811 

Run ifconfig -a and the Wifi interface should be up.

Configure netplan

Configure netplan yaml file, /etc/netplan/01-netcfg.yml as shown above

Run sudo netplan apply to apply changes.

wpasupplicant

Install this package for WPA security support

sudo apt install wpasupplicant 

Reboot and check

Reboot computer and check

reboot # should show the wifi interface now with an IP address if working ifconfig -a 

Logging in remotely

There are 3 steps to do this

1. Assign a static IP address to your home network

This can be done from logging into your Wifi router. The URL to login will be on the bottom of your Wifi router.

I have a Netgear router, so I

2. The DL machine should be DHCP registered to an IP address

For me, this was already done in the previous step using netplan

3. Add port forwarding

This is configurable when logged in to the Router config. For me, this Netgear guide helped me setup port forwarding.

4. Test

I tested by connecting to my phone Wifi hotspot with my laptop then tested that I could ssh to the DL machine

ssh -i ~/.ssh/my.pem username@hostname 

Some interesting points

ifconfig

ifconfig will show internet interfaces that are up

ifconfig -a will show all internet interfaces whether they are up or down

ifconfig was showing the Wifi interface as up, but with no IP. This meant that the USB Wifi adapter driver (driver) installation worked and it was registered as an interface in netplan but couldn’t connect to the network. It was the WPA security blocking it at this point.

lshw

lshw -C network will show hardware. -C network to only show “network” class of hardware.

After successfully installing the driver, I could see the wifi network as DISABLED. Then running netplan apply this show the network as enabled.

Commands used

# list usb ports and connected devices lsusb # configure network interfaces ifconfig # configure wifi network interfaces iwconfig # get detailed wifi info iwlist s # dynamic kernal support module dkms # ip show an manipulate routing, network devices, interfaces ip link set up/down # list hardware lshw -C network netplan apply netplan --debug generate # check if there's internet ping -c3 www.ubuntu.com 

Источник

Оцените статью
Adblock
detector