From LQWiki
This covers how to get wireless, or Wi-Fi networks to work under Linux, and the various applications that go along with them.
Contents |
Start
You should start by means of your distribution - most probably, it works out of the box. Make sure you enabled WLAN on your laptop (there is mostly a button for it). Put it next to your WLAN router. Install your WLAN card as a network card, it will be called eth1,wlan0 or so. Use iwconfig to find out how it is called. You should be able to scan for wireless networks then, e.g. by
$ iwlist wlan0 scanning
wlan0 Scan completed :
Cell 01 - Address: 00:0F:C9:01:F5:F4
ESSID:"foo"
Mode:Managed
Channel:10
Encryption key:off
Bit Rates:0 kb/s
$
If you get a Command not found error, install the Wireless tools and try again.
If you do not get a list like the above, see the next section Wireless configuration.
If it works, you can continue with the section Connect to an Accesspoint.
Wireless Configuration
The following provides the general steps required to get wireless networking enabled on your Linux machine.
Find out your wifi card's chipset
In order to get your card working you will have to determine its chipset. There is one, generic, way for PCI and PCMCIA cards, and one for USB cards:
- The generic way
- Run "hwinfo --wlan"
- If this command does not succeed, this can mean that you have an old kernel that does not recognize your card as a WLAN card. In this case, you cannot use it. Anyway, to find out its type use
hwinfo --pciorhwinfo --pcmcia.
- Methods for USB cards
- Run
hwinfo --usb.
- Run
- This will give you information about the chipset and tell you a Driver activation command (like "modprobe rt73usb").
Hopefully you now have a chipset name but...
Which driver to load and how?
To find out which driver you have to load, use
hwinfo --wlan|grep -i driver
See below for additional relevant information on given chipsets or drivers.
Open Source
- WiFi Link 5100
- Intel PRO/Wireless 3945ABG
- Intel_Pro_Wireless 2100/2200/2915 -- Note that this requires http://sourceforge.net/projects/ieee80211
- ipw2200 on Suse 10.0, see Suse100ipw2200
- Prism 2/2.5/3: Prism_2_Drivers
- Ralink RT2400/2500, RT61, RT73: Ralink_Wireless_Drivers
- Atheros AR5210/5211/5212: MADWIFI
- Prism GT/Duette/Indigo: Prism54
- Broadcom 4318 Airforce one 54g card
- Texas Instruments ACX100/111: acx100
- Atmel: AT76C5XXx
- Belkin_F5D6020_ver.2
- Net_Gear_WG121_on_Mandrake_10.0_Linux
- Linksys WMP54G Wireless how-to for Ubuntu 8.10 Intrepid Ibex
- Almost every other chipset: NDIS_Wrapper
Proprietary
Note that building a kernel module requires the kernel sources. Download your driver sources in .tar.gz format and compile from source.
Connect to an Accesspoint
This chapter covers how to connect to an unencrypted or WEP encrypted accesspoint. For WPA encryption, have a look here. The example interface will be called wlan0.
To set up the interface, start by:
$ ifconfig wlan0 up
If you want, you could scan for an accesspoint first:
$ iwlist wlan0 scanning
You will then see the available accesspoints, their ESSID's, the frequency, etc. To associate with an accesspoint (for example "test"), run:
$ iwconfig wlan0 essid test
Most drivers will automatically find the right channel in a minute. You should now be able to see something like this when you run iwconfig:
$ iwconfig
lo no wireless extensions
wlan0 IEEE 802.11b ESSID:"test"
Mode:Managed Frequency:2.437 GHz Access Point: 00:00:00:00:00:00
Bit Rate:11 Mb/s Tx-Power=15 dBm
Retry limit:8 RTS thr=1536 B Fragment thr=1536 B
Encryption key: off
Power Management:off
Link Quality=0/0 Signal level=0/255 Noise level=0/0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
This means that everything has been installed properly.
Using WEP encryption
If the accesspoint uses WEP, you set the encryption like so:
$ iwconfig wlan0 key s:"the_ascii_key"
Or you can use a hexadecimal key:
$ iwconfig wlan0 key 00000000000
The bits of encryption is determined by the key length. Note that this command, along with the key, can be seen in "ps aux".
Getting an IP address
If you have associated properly, you should see the accesspoint's mac address in from iwconfig instead of 00:00:00:00:00:00. If the network you have connected to uses dhcp, it is time to obtain an ip address:
$ dhclient wlan0
Or:
$ dhcpcd wlan0
You should see "DHCPOFFER" or similar in a minute if all went well. If it sits there for a while with no DHCPOFFER, then something is wrong. Perhaps the encryption key was incorrect.
However, if you would connect to a AP that doesn't have a dhcp server, you can do the following:
First scan for the AP so you can see the ESSID and the mac address. Do the following
$ iwconfig wlan0 essid "MyAP" (if that's the ESSID) $ iwconfig wlan0 ap 00:40:CA:45:10:9C (if that's the mac) $ ifconfig wlan0 192.168.0.20 up $ route add -net default gw 192.168.0.1
Provided that the AP has the IP 192.168.0.1.
Create an access point
It is fairly simple to setup an AP in linux. This is how I did.
I purchased a D-Link DWL-G520 pci card. You need a card that supports Master mode. Check this (linux-wless.passys.nl) site for compatibility with Linux, I think ndiswrapper doesn't have support for Master mode, not sure though.
Creating the AP
Then if your interface is ath0:
$ iwconfig ath0 mode Master $ iwconfig ath0 essid "LinuxAP" $ ifconfig ath0 192.168.1.1 up
I chose an IP that wasn't in my wired LANs subnet. Now you should be able to see the AP if you scan for APs.
Configure statically your client's card
Then on the client side (if your interface is ath0) you do:
$ iwconfig ath0 mode Managed $ iwconfig essid "LinuxAP" $ iwconfig ap 00:11:22:AA:22:11 $ ifconfig ath0 192.168.1.10 netmask 255.255.255.0 up $ route add -net default gw 192.168.1.1
It's not always necessary to specify the mac address for the ap, but sometimes it's a good thing. As you can see I chose an ip that was in the same subnet as the ap, it's important.
DHCP server, firewall and stuff
Now, that was the static ip way and you probably want a dhcp-server and some firewall-rules for the ap. Guess what... here they come!
iptables
I have some rules with iptables in a script:
#!/bin/sh IPTABLES='/sbin/iptables' EXTIF='eth0' INTIF='eth1' WLAN='ath0' WAN='85.235.31.133' /bin/echo 1 > /proc/sys/net/ipv4/ip_forward $IPTABLES -F $IPTABLES -X $IPTABLES -X -t nat $IPTABLES -F -t nat $IPTABLES -X -t filter $IPTABLES -F -t filter # enable masquerading to allow LAN internet access $IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE # forward LAN traffic from $INTIF1 to Internet interface $EXTIF $IPTABLES -A FORWARD -i $INTIF -o $EXTIF -m state --state NEW,ESTABLISHED -j ACCEPT # allow ping $IPTABLES -A INPUT -p icmp -i $EXTIF -j ACCEPT # Allowing access to the FTP server" $IPTABLES -A INPUT -i $EXTIF -p tcp --dport 21 -j ACCEPT # Allowing access to the ssh server on port 2200 (I've changed it) $IPTABLES -A INPUT -i $EXTIF -p tcp --dport 2200 -j ACCEPT # block out all other Internet access on $EXTIF $IPTABLES -A INPUT -i $EXTIF -m state --state NEW,INVALID -j DROP $IPTABLES -A FORWARD -i $EXTIF -m state --state NEW,INVALID -j DROP
dnsmasq
And my dnsmasq.config looks like this:
resolv-file=/etc/resolv.conf no-poll domain-needed bogus-priv strict-order interface=ath0 dhcp-range=192.168.1.10,192.168.1.50,12h interface=eth1 dhcp-range=192.168.0.10,192.168.0.50,12h # alice and bob are declared in /etc/hosts dhcp-host=00:0A:E4:52:6B:12,alice dhcp-host=00:40:CA:45:10:9C,bob dhcp-authoritative
And that's it! Just run the script, start dnsmasq and connect to the ap described in the top of this wiki.
stuff
By the way, if you want to ping some host in the 192.168.0.0 subnet make sure that you don't have another interface that's not alive with an ip in that subnet. So if you have an ordinary wired card eth0 with an ip in the 192.168.0.0 subnet (but no cable in maybe) make sure that you bring that interface down.
$ ifconfig eth0 down
Now you can ping hosts in that subnet with your wifi card.
External links
Howtos,Guides
- A nice overview (www-106.ibm.com)
- Wireless Tutorial (www.rustyspigot.com)
- Wireless Security - WPA1 WPA2 LEAP AES, etc. (www.ubuntuforums.org)
Chipset list
- list of all possible wlan chipsets (wiki.uni-konstanz.de)
- Supported cards by manufacturer, chipset and interface (PCI, USB, PCMCIA) (linux-wless.passys.nl)
Specific cards
- D-LINK DWL-650 (and/or DRC-650) under RH 8.0, kernel 2.4.18 (www.wmconnolley.org.uk)
- Linksys WMP54G - 802.11G - kernel 2.4 - debian 3.0 (www.netdigix.com)
- Linksys WUSB54GC - kernel 2.6.15 - Ubuntu 6.06 (kennethjor.blogspot.com)
- Kernel module package for Ralink RT73 based USB WLAN adapters, such as Linksys WUSB54GC - Kernel 2.6.15 - Ubuntu 6.06 (www.uni-klu.ac.at)

This page is available under a