
It all started when I replaced the motherboard in my home computer. The old motherboard had a built-in USB Wi-Fi adapter on a regular Realtek 8187, which for two years worked properly as an access point under Windows. The new Wi-Fi board didn’t have a module, but I had a whole server on the wonderful Intel Atom 525 with one small drawback - it had very few PCI slots.
After a bit of thinking, I decided to do an innocent thing, as I first thought it was to launch a software Wi-Fi access point on a regular USB adapter. If I had been warned that I was waiting, I would have abandoned the idea from the very beginning! I got an inexpensive adapter and, only in the process of messing with it, I became aware that using the “wrong” USB on the “wrong” chipset is real violence for Linux! Linux gurus refused help!
')
Nevertheless, I managed to make friends Debian 6.0 with the
Ralink 2870/3070 and
Atheros 9170 chipsets, and I am ready to reveal this terrible secret to the whole world!
Foreword
In recent years, the Wi-Fi system in the Linux kernel has undergone a major refinement. The idea was very simple - to break the subsystem into modules, put the repeating MAC level procedures into separate kernel modules and separate daemons, and rewrite the drivers of physical devices. So there was a pack of components, about which you can read on the website of developers:
wireless.kernel.org/en/users/DocumentationAs it often happens, beautiful theories were exposed to the harsh prose of life. In our case, it looks like this: for each Ralink 2870/3070 and Atheros 9170 chipset, two versions of the drivers are included in the kernel - “old school”, which work out of the box, but cannot be run in Master mode (mode to start the Access Point) and New "net-link style" that everyone can but do not work out of the box. By default, mutually exclusive drivers try to run at the same time as the sad result. But rather complaints, rather for the cause!
Run the driver. Wi-Fi, just Wi-Fi
If you are a regular user and just want to connect to existing Wi-Fi networks, then on Debian 6 (and other similar ubuntarians) you need to do the following:
For the RT2870 / 3070 chipset, the popular Dlink DWA-140, TL-WN727N are recommended to leave the old-style rt2870sta driver, to which we don’t forget to download the firmware.
apt-get install firmware-ralink wireless-tools
Next, go to /etc/modprobe.d/blacklist.conf and block the launch of new style drivers:
blacklist rt2x00usb blacklist rt2x00lib blacklist rt2800usb
Then you can connect a USB whistle and carefully look at the dmesg. If they write about driver conflicts in it, then you are mistaken or have not banned all conflicting drivers. If it is written about the lack of firmware, then you have no firmware (damn unexpected?). Type
ls -l /lib/firmare
should be something like this:
-rw-r--r-- 1 root root 8192 6 22:34 rt2561.bin
-rw-r--r-- 1 root root 8192 6 22:34 rt2561s.bin
-rw-r--r-- 1 root root 8192 6 22:34 rt2661.bin
-rw-r--r-- 1 root root 8192 6 22:34 rt2860.bin
-rw-r--r-- 1 root root 8192 19 11:46 rt2870.bin
-rw-r--r-- 1 root root 4096 4 05:40 rt2870.bin.old
-rw-r--r-- 1 root root 8192 28 2009 rt2870.bin.ralink
-rw-r--r-- 1 root root 4096 6 22:34 rt3070.bin
-rw-r--r-- 1 root root 4096 6 22:34 rt3071.bin
-rw-r--r-- 1 root root 8192 6 22:34 rt3090.bin
-rw-r--r-- 1 root root 2048 6 22:34 rt73.bin
An inquisitive reader probably noticed a trick, we still think about it.
For Ar9170 similar procedure. It contains Dlink DWA-130, 160 as well as TL-WN821N v2, which is very popular in narrow circles. Netgear WNA1000 got into my hands.
apt-get install firmware-atheros wireless-tools
Blacklist carl9170 and go!
Then we go to / etc / network / interfaces and write something like this:
iface wlan0 inet static address 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255
Run
ifup wlan0
. Then some kind of graphical utility can connect to the network. For final configuration, for example, “Network manager” is suitable.
If yours, dear habrayuzer already blinked Wi-Fi and nothing more is required, then boldly close the topic.
Run the driver. Strong-willed
So, persistent habrayuzer, despite the skepticism of recognized gurus, we still want to run USB Wi-Fi in the access point mode.
First, two simple tips for choosing an adapter:
Now cross out all the recommendations from the section "just Wi-Fi"! 90% of blogs on the Internet are filled with this nonsense. We will disable old-style drivers and run new ones that don’t work out of the box even in the newest kernel versions, which means it’s time to compile. While you are reading this habrastiyu, the developers probably fixed 1-2 bug fixes in the drivers and added a new one, which means downloading the latest version of compat-wireless:
www.orbit-lab.org/kernel/compat-wireless-2.6It is compatible with drivers starting from 2.6.14.
Then follow the instructions:
wireless.kernel.org/en/users/Download/stableEverything is compiled for a very long time ignoring the multithreading flag:
declare -x CONCURRENCY_LEVEL="4"
After compilation and installation, do not forget to disable the old style in /etc/modprobe.d/blacklist.conf
blacklist rt2870sta blacklist ar9170usb
And of course, do not forget to unload previously loaded drivers:
rmmod rt2870sta rmmod ar9170usb
New style drivers can be properly unloaded (useful for debugging):
rmmod rt2800usb rmmod rt2800lib rmmod rt2x00usb rmmod rt2x00lib rmmod mac80211 rmmod cfg80211
or so:
rmmod carl9170 rmmod ath rmmod mac80211 rmmod cfg80211
A terrible secret firmware!
It seems everything. We are
modprobe
... and a complete disappointment! In the logs again swears on the firmware. The fact is that the new drivers have other firmware. For Ralinka, go here:
www.ralinktech.com/support.php?s=2 and download something like RT2870_Firmware_V22.
Unpacking and writing to / lib / firmware, wondering how this file with the same name can be exactly twice as large in size! The attentive reader has already noted this fact before. The fact is that a few months ago, the developers merged the drivers for the
rt2870 and
rt3070 chipsets into one. Without further ado, they called the driver and the firmware on behalf of 2870. Have you seen on the Ralinka page of the firmware 3070? And I did not see, but it is there! The DWA-140 adapter is made on the 3070 chipset and is recognized by the rt2800usb drivers.
With Ateros a little easier, go to the developers page and download the latest version:
wireless.kernel.org/en/users/Drivers/carl9170#FirmwareTo accurately understand the firmware, we look at what the driver module wants, for example:
modinfo carl9170 | grep firm
And then we check that the necessary firmware is:
ls /lib/firmware/
Further, already familiar manipulations with rmmod, modprobe and lsmod and hurray! We raised the right drivers, so it's time to dial the coveted team
iwconfig wlan0 mode Master
Bah! Mistake!
SET failed on device wlan0 ; Invalid argument.
Was it all done in vain? Of course not. It’s just that the new subsystem has its own way, and as it often happens with the new and the good, it categorically denies the old and the good. The forums discuss this issue like this:
- Why?
- RTFM!
- You RTFW! The sky, the sky did not see such a kyu!
The manual tells us that from now on, all settings for the access point are made through the hostapd program:
wireless.kernel.org/en/users/Documentation/hostapdWe connect the sid repository to Debian (in all the rest hopelessly old versions) and install new utilities for working with fw radio and the hostapd demon
apt-getinstall iw hostapd
Then we write
iw list
and see the cherished Supported interface modes: AP, and along with the list of frequencies.
Dancing with a tambourine. Hostapd
Before you begin configuring the config, you need to know three important things.
1. Inside this demon sits a small and harmful bastard who unpredictably changes the state of the interface during startup / restart. Sometimes wlan0 disappears, sometimes its IP disappears, sometimes ifdown ifup helps, sometimes it doesn't help. Ralink in such conditions is very bad, Ateros is a bit more stable. Therefore, before any launch of hostapd, we check that the radio interface is up and its IP address is alive. If you can’t raise the interface, then we use violence - we rebuild Linux! (Yes, yes, this is not a joke!)
2. All settings are first checked without encryption! And do not forget to check dhcpd, who also likes to die when restarting interfaces. That's why Linux + USB = hate! It is better to set up hostapd without dhcp, with a fixed IP address on the client, and only at the end go to setting up dhcpd.
3. To check, always first run
hostapd -d /etc/hostapd/hostapd.conf
with diagnostics in the console.
Now the config hostapd with explanation. (Update: corrected comments, # does not work at the end of the line)
After launch, first of all, type in
ifconfig
and see that a special interface has appeared.
mon.wlan0 Link encap:UNSPEC HWaddr 30-46-9A-00-6D-04-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42603 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3887500 (3.7 MiB) TX bytes:0 (0.0 B)
Now in the console (if you run hostapd -d), we see what happens during the authentication process. If WPA is configured and the connection does not go beyond phase 2/4, the password is mistakenly typed. There you can still see a lot of incomprehensible messages.
Lyrical digression
It so happened that while picking on hostapd I lost all hope of launching my
Dlink DWA-140 on the
Ralink 3070 chipset. I definitely managed to launch it without encryption, but when encryption was turned on, either I made a mistake, or indeed this module badly interacts with nuclear encryption modules (I saw the problem description on the forums and one of the versions of the solution pointed to the ecb and arc4 encryption modules .
I already implemented the final chord with encryption enabled on the
Netgear WNA1000 on the
Atheros 9170 chipset, which really works better and correctly loads all the encryption modules.
Now I think that it was possible to launch Ralink with encryption and urge to put a bold end to the question of the happy owners of DWA-140. Write about your successes or problems in the comments, try to understand together.
Instead of epilogue
Now we have a small server with a USB Wi-Fi adapter buzzing quietly in the closet or on the closet, you can enjoy the work done. But it was not there! In a modern high-rise building with access points packed with access points from all sides, there are noises. To select a channel, I advise you to explore the broadcast program
InSSIDerThis is what the channel selection looked like in my evening at the window:
