WLAN mainly uses the same mechanism as Ethernet, so check also the Ethernet chapter in this book. For Gentoo Linux set the wifi use flag.
A Wi-Fi device is a WLAN device but a WLAN device might not fulfill all requirements to be called a Wi-Fi device
Communicate over WLAN is a bit the same as communicate in a bar. If no customers are there then it works fine over large distances, but if the bar gets full and crowded communication over short distances might get difficult. WLAN routers might pick a channel that looks good for their location, but a far distance device might find itself in an other situation where a third party device uses the same frequency as the router.
For 2.4GHz WLAN Bandwith 20MHz is more stable and has a wider range, it is therefore recommended when having a lot of neighbors. 40MHz gives higher bandwidth.
A WLAN device takes a channel, the Center Channel. The Center Channel is used to connect and control the connection. However it also uses neighbor channels to communicate.
A channel has a center frequency, and 2.5Mhz on both sides distance to the neighbor channels. Usually it tries to take 2 channels on the left and 2 on the right to get a bandwidth of 20MHz.
The best is if there are no neighbors, but if there are neighbors then it is better that they use the same channel. If so they share the bandwidth in a software controlled manner. If they use a overlapping channel, no coordination is possible and they are considered as noise and disturbance having more negative effects. Recommended channels are 1,6 & 11
Also the extreme channels 1 and 13 use bandwidth 10Mhz on both sides. Watch out for the country regulation, some as the US restrict channel 12 & 13
Linux is full of options, so there are primary two options to have a device driver for the wireless card:
Using Linux device drivers (delivered with or without the kernel source)
Using Microsoft device drivers and the ndiswrapper
Many drivers have to download a firmware or ucode first into the Wlan interface to work. Therefore check dmesg if you have some error about a missing firmware. To have such a firmware or ucode available you have to emerge a special ebuild as:
emerge linux-firmware
emerge iwl5000-ucode
emerge rt73-firmware
Last but not least make sure your Wlan switch is on.
Please note that udev comes in place and assigns a device to a /dev name
in a persistent manner. This could cause problems when testing different drivers and configurations. When
you have a empty /etc/conf.d/net file but still drivers are loaded
or you observe other strange behavior, then check /etc/udev/rules.d/70-persistent-net.rules
/etc/udev/rules.d/70-persistent-net.rules and delete there the configurations
that you do not want anymore. Also run update-modules to re-do the module dependency files. Also check dmesg
to see if some conflicts and errors occur. Once the device drivers are loaded iwconfig should show wlan0
additional to eth0.
The ndiswrapper makes use of the Microsoft device driver. mdiswrapper can be be started using
/etc/modules.autoload.d. It requires the two Microsoft
device driver files *.inf and *.sys . The command ndiswrapper -i<Path to Microsoft drivers>.< Driver name>.inf tells the ndiswrapper where the files are.
This USB Wlan interface from Linksys WUSB54GC is probably more tricky to install, but having USB allows to be plugged into almost every hardware.
and is now included in the newer kernels 2.6.25, so there is no need anymore to emerge it separately.
As an alternative there are also driver packages from ralinktech, the manufacturer of the chip set.
Note: WUSB54GC has there the name: RT2501USB.
When the USB adapter is plugged in then a firmware has to be downloaded to the WLAN USB device
first.
The name of the file is rt73.bin and has to be be put into /lib/firmware. This can be done manually or by unmasking and emerge rt73-firmware. Verify that dmesg will
not show the firmware error.
Create kernel where IEEE802.11 support is selected and then select also rt2x00. Select in the kernel rt73usb. Load the kernel module:
modprobe rt73usb
and/or add
rt73usb
to /etc/modules.autoload.d/kernel-2.6
to have it loaded automatically during next boot.
usbview shows the card (a useful /dev/file can not be seen, neither for eth0, udevadm monitor --env sees the card when plugged in/out.). Check to see if it got accepted by the system.
This driver comes with the kernel source. Build a kernel with it preferably as module. Load the
module ath5k by putting it into /etc/modules.autoload.d/kernel-2.6 or do a modprobe ath5k.
Madwifi has been developed by the same people as ath5k and will be replaced one day with ath5k. Set therefore the madwifi useflag.
Since ath5k comes with the kernel source, there is no need to emerge madwifi-ng to get the driver. However emerge madwifi-ng-tools to get the associated tools.
There might be a conflict between the kernel module ath5k and the madwifi module ath_pci when both are loaded together.
lsusb will show what is there as:
Bus 001 Device 003: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter
or
Bus 001 Device 007: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
The linux-firmware package should have installed the required firmware /lib/firmware/rt2870.bin
The kernel must have the device selected as
CONFIG_RT2800USB=m
lsmod | grep -i rt2800 should show rt2800usb if not modprobe rt2800usb and dmesg | grep -i rt2800
ip link should show the interface as with a udev created predictable name wlp115s0u1, wl wire less, PCI bus 115, slot 0, u1 USB port number
To bring it alive a modern approach is Networkmanager as high-level network configuration daemon and low-level service daemons as the new iwd or the mature wpa_supplicant. In Gentoo the useflag iwd can be set to get iwd instead wpa_suplicant
systemctl enable --now NetworkManager
For Network manager there are some gui but also text based user interfaces as nmcli and nmtui
The following security methods exist:
WEP (Wired Equivalent Privacy) requiring a 64 or 128bit key
WPA (WiFi Protected Access) offering TKIP or the symmetric AES Encryption. Additionally there is the option PSK" (Pre-Shared Key 2)
There are two ways:
iwconfig that supports many devices, is easy to install supports WEP, but does not support WPA. iwconfig is part of wireless-tools
wpa_supplicant does not support many devices, but supports ndiswrapper and therefore it supports
everything that has a Microsoft driver. It has its own configuration file
/etc/wpa_supplicant/wpa_supplicant.conf
WPA (Wi-Fi Protected Access) should be the favorite since it is more safe and therefore more used than WEP. WEP can be cracked using instructions found on the WEB as: https://www.smallnetbuilder.com/wireless/wireless-howto/24242-howtocrackweppt2?start=1
Install iw (wireless-tools and its programs as iwconfig seem to be outdated and do not show modern WLAN devices as USB devices).
Make sure you have loaded the kernel module for your hardware. When not included in the kernel lsmod
should show it. If it is not there, modprobe ath5k to load an Atheros wireless PCI Express Adapter or modprobe rt73usb for the Linksys WUSB54GC. Since the first tests are done manually
/etc/conf.d/net should contain nothing about wlan.
Type iwconfig to see your interfaces and its names, ifconfig will not show anything.
However just in case do a: ifconfig wlan0 down
Set to managed mode this means somewhere is an access point and you are a client. If not already set to managed: iwconfig wlan0 mode managed
You have to give your network a name, the ESSID this has to be the same name on all devices that want to communicate with each other (your wireless router and your PC):
iwconfig wlan0 essid <my net>
Verify that your interface and the AP use the same channel, if not do:
iwconfig wlan0 channel 11
And if you have set WEP with a static key in our AP, let your PC know about it:
iwconfig wlan0 key e7dddcee7d
Bring up the client interface: ifconfig wlan0 up. After a few seconds iwconfig should also have the Access Point field with a number, so it is associated.
You might use iwlist wlan0 scan to see the ESSID of your AP (Access Point). (Encryption key currently turned off during these tests):
iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 00:AF:C5:DD:85:32
ESSID:"ZyXEL"
Mode:Master
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=54/100 Signal level=-34 dBm
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s
6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
36 Mb/s; 48 Mb/s; 54 Mb/s
Extra:tsf=000000001ff9d46e
Give yourself an IP address ifconfig wlan0 up 192.168.1.7
And now you should be able to do a ping -c 3 192.168.1.1 assuming this is the address of your AP.
To see what is set use iwlist. Example to see the keys: iwlist wlan0 keys
To have the interface automatically up, follow the Gentoo handbook and use wlan0 instead of eth0.
I did not use the /etc/conf.d/wireless file at all
(it seems not a good idea to create this file from /etc/conf.d/wireless.example) I just used /etc/conf.d/net and followed the Gentoo handbook.
Set replace in the following <essid> with your essid and add it to
/etc/conf.d/net:
modules=(“iwconfig”)
config_<essid>=(“dhcp”)
key_<essid>=”e7dddcee7d”
preferred_aps=(“<essid>”)
Create the useful link to start the wlan connection:
ln -s /etc/init.d/net.lo /etc/init.d/net.wlan0
Type emerge -pv wpa_supplicant to if useflags like madwifi are enabled. Madwifi enables atheros chipset to be supported by wpa_suplicant. After that emerge wpa_supplicant
To see what drivers wap_supplicant supports, type:
wpa_supplicant -h don't expect too much the list of supported drivers will be short.
However it supports ndiswrapper. When enabling the madwifi useflag then madwifi pops up there. Since
the first tests are done manually /etc/conf.d/net should contain
nothing about wlan.
Make sure the driver is loaded and no other has taken the chip.
To encrypt the key type wpa_passphrase <essid> <mykey> and then edit
/etc/wpa_supplicant/wpa_supplicant.conf
to hold something as
network={
ssid=<my ssid>
key_mgmt=WPA-PSK
proto=WPA2
pairwise=CCMP
group=CCMP
psk=”<my key encrypted>”
}
To start wpa_supplicant type
wpa_supplicant -i wlan0 -D madwifi -c /etc/wpa_supplicant/wpa_supplicant.conf
To /etc/conf.d/net add:
modules=(“wpa_supplicant”)
wpa_supplicant_wlan0=”-Dmadwifi”
Wireless means, you probably have a laptop an move it around, so you will face different
KWiFiManager is a GUI tools that work well after the setup is done.
Or use NetworkManager and its KDE GUI front-end Knetworkmanager to handle all your links and encryption methods, keys and passwords.
kismet is a WLAN sniffer.
Checkout /usr/share/doc for the kismet documentation.
/etc/kismet.conf
suiduser=<add you name>piddir=<some directory where you have access>source=<rt2500,wlan0,your_username>
The wlan driver must not occupied by the regular LAN connection.
ifconfig wlan0 down to make it available
iwconfig wlan0 mode monitor to go into monitor mode
iwconfig to verify
kismet
rfkill list shows if wifi is blocked (hard or soft) rfkill unblock wifi removes soft block
Radio transmitters use different regulations around the world (as allowable channels and signal strength).
As default it assumes COUNTRY=00 meaning world and being most restricted (not all frequencies usable and signal strength restricted).
To handle this issue the wireless-regdb packet installs the regulatory database /lib/firmware/regulatory.db and more important its binary version /usr/lib/crda/regulatory.bin The binary version can be read with regdbdump /usr/lib/crda/regulatory.bin
The kernel must be prepared for this and the Central Regulatory Domain Agent (CRDA) needs to be installed (crda packet).
The packet linux-firmware might be required to be installed to get the correct firmware for the wlan chips.
The WLAN dirver knows the card's certification and where it is and try to do the best to follow the countries regulation.
To have all this running the COUNTRY environmental variable must be set correctly (for Switzerland CH).
This can be done via iw reg set CH and verified with iw reg get (packet iw). It can just more restrict but not remove restrictions.
Persistent setting is done depending the linux distribution wpa_supplicant configuration file crda configuration file Network manager.
To debug crda to kernel: udevadm monitor --environment kernel
The IEEE-Standard for WLAN-Mesh 802.11s (Wi-Fi Mesh Mode) made its way into the Linux-WLAN-driver (mac80211).
First see if mesh is supported by the hardware and its driver (Atheros ath9k, ath10k or MediaTek have support):
iw list and look for mesh (Supported RX/TX frame types, just means that it knows those frame, but does not mean that it can do something with them)
Or simply try it: iw dev wlan0 interface add mesh0 type mp to set the WLAN interface in mesh mode. If no error comes remove it: iw dev mesh0 del
All devices use the same frequency and are in their own subnet.
One mesh device might operate as gateway and have sysctl -w net.ipv4.ip_forward=1 to allow communication with the regular subnets.a static route the router for the mesh subnet as 192.168.80.0 (Netmask 255.255.255.0 or /24) pointing to this gateway as: 192.168.1.100
iw dev wlp115s0u1 link
Connected to 48:8d:36:23:e5:38 (on wlp115s0u1)
SSID: LaborAntenne
freq: 2412.0
RX: 11861109 bytes (73815 packets)
TX: 141640 bytes (1562 packets)
signal: -51 dBm
rx bitrate: 52.0 MBit/s MCS 5
tx bitrate: 65.0 MBit/s MCS 7
bss flags: short-slot-time
dtim period: 3
beacon int: 100
signal RSSI) the higher the absolute dBm number the better
Also ping the router via WLAN: (ping -I wlp115s0u1 -c3 192.168.1.1
Use wavemon