Está en la página 1de 22

NOTE: NOT ALL CARDS/FIRMWARE SUPPORT ALL OF THE COMMANDS LISTED BELOW.

Note: To connect your Linux machine to a WLAN using WPA, WPA2 or 802.1X you will
need to use WPA Supplicant
Connecting to an OPEN / WEP WLAN (DHCP)
Note: replace [interface] with your interface name as required (e.g. eth1, wlan0
, ath0 etc.)
iwconfig [interface] mode managed key [WEP key] (128 bit WEP use 26 hex characte
rs, 64 bit WEP uses 10)
iwconfig [Interface] essid "[ESSID]" (Specify ESSID for the WLAN)
dhclient [interface] (to receive an IP address, netmask, DNS server and default
gateway from the Access Point)
ping www.bbc.co.uk (if you receive a reply you have access)

Connecting to an OPEN / WEP WLAN (Manual IP Setup)


Note: replace [interface] with your interface name as required (e.g. eth1, wlan0
, ath0 etc.)
It may be necessary to run some packet capture software (e.g. Ethereal) to deter
mine the IP addresses of both the Default Gateway and DNS servers.
iwconfig [interface] mode managed key [WEP key] (128 bit WEP use 26 hex characte
rs, 64 bit WEP uses 10)
iwconfig [interface] essid "[ESSID]"
ifconfig [interface] [IP address] netmask [subnetmask]
route add default gw [IP of default gateway] (Configure your default gateway; us
ually the IP of the Access Point)
echo nameserver [IP address of DNS server] >> /etc/resolve.conf (Configure you
r DNS server)
ping www.bbc.co.uk (if you receive a reply you have access)

iwconfig Commands:
Note: replace [interface] with your interface name as required (e.g. eth1, wlan0

, ath0 etc.)
iwconfig [interface] mode master (set the card to act as an access point mode)
iwconfig [interface] mode managed (set card to client mode on a network with an
access point)
iwconfig [interface] mode ad-hoc (set card to peer to peer networking or no acce
ss point mode)
iwconfig [interface] mode monitor (set card to RFMON mode our favourite)
iwconfig [interface] essid any (with some cards you may disable the ESSID che
cking)
iwconfig [interface] essid

your ssid_here

(configure ESSID for network)

iwconfig [interface] key 1111-1111-1111-1111 (set 128 bit WEP key)


iwconfig [interface] key 11111111 (set 64 bit WEP key)
iwconfig [interface] key s:mykey (set key as an ASCII string)
iwconfig [interface] key off (disable WEP key)
iwconfig [interface] key open (sets open mode, no authentication is used and car
d may accept non-encrypted sessions)
iwconfig [interface] channel [channel no.] (set a channel 1-14)
iwconfig [interface] channel auto (automatic channel selection)
iwconfig [interface] freq 2.422G (channels can also be specified in GHz)
iwconfig [interface] ap 11:11:11:11:11:11 (Force card to register AP address)
iwconfig [interface] rate 11M (card will use the rate specified)
iwconfig [interface] rate auto (select automatic rate)
iwconfig [interface] rate auto 5.5M (card will use the rate specified and any ra
te below as required)

ifconfig Commands:
Note: replace [interface] with your interface name as required (e.g. eth1, wlan0
, ath0 etc.)
ifconfig [interface] up (bring up specified interface)
ifconfig [interface] down (take down specified interface)
ifconfig [interface] [IP address] netmask [subnet-mask] (manually set IP and sub
net-mask details)
ifconfig [interface] hw ether [MAC] (Change the wireless cards MAC address, spec
ify in format 11:11:11:11:11:11)

iwpriv Commands:
Note: replace [interface] with your interface name as required (e.g. eth1, wlan0
, ath0 etc.)
iwpriv [interface] hostapd 1 (used to set card mode to hostapd e.g. for void11)
When the monitor mode patch is installed as per the Wireless Build HOWTO the fol
lowing commands may be used to set the card into monitor mode.
iwpriv [interface] monitor [A] [B]
[A]
0 = disable monitor mode
1 = enable monitor mode with Prism2 header
2 = enable monitor mode with no Prism2
[B]
Channel to monitor (1-14)
iwlist Commands:
Note: replace [interface] with your interface name as required (e.g. eth1, wlan0
, ath0 etc.)
iwlist is used to display some large chunk of information from a wireless networ
k interface that is not displayed by iwconfig.
iwlist [interface] scan (Give the list of Access Points and Ad-Hoc cells in rang
e (ESSID, Quality, Frequency, Mode etc.) Note: In tests only worked with Atheros
cards).

iwlist [interface] channel (Give the list of available frequencies in the device
and the number of channels).
iwlist [interface] rate (List the bit-rates supported by the device).
iwlist [interface] key (List the encryption key sizes supported and display all
the encryption keys available in the device).
iwlist [interface] power (List the various Power Management attributes and modes
of the device).
iwlist [interface] txpower (List the various Transmit Power available on the dev
ice).
iwlist [interface] retry (List the transmit retry limits and retry lifetime on t
he device).
iwlist [interface] ap (Give the list of Access Points in range, and optionally t
he quality of link to them. Deprecated in favour of scan)
iwlist [interface] peers (Give the list of Peers associated/registered with this
card).
iwlist [interface] event (List the wireless events supported by this card).
Madwifi-ng Commands:
MADWiFi supports virtual access points (VAPS), which means you can create more t
han one wireless device per wireless card (the host wireless card = wifi0).
By default, a sta mode VAP is created by, which is MadWifi talk for a 'managed m
ode wireless interface'.
Note: replace athx with your interface name as required (e.g. ath0, ath1)
wlanconfig athx destroy (Destroy VAP, athx)
wlanconfig athx create wlandev wifi0 wlanmode sta (Create a managed mode VAP, at
hx)
wlanconfig athx create wlandev wifi0 wlanmode ap (Create an Access Point VAP, at
hx)
wlanconfig athx create wlandev wifi0 wlanmode adhoc (Create an Ad-Hoc VAP, athx)

wlanconfig athx create wlandev wifi0 wlanmode monitor (Create a Monitor mode VAP
, athx)
Changing modes:
ifconfig athx down (Take the VAP down)
wlanconfig athx destroy (Destroy the VAP, athx)
wlanconfig athx create wlandev wifi0 wlanmode [sta|adhoc|ap|monitor] (Create a n
ew sta, adhoc, ap or monitor VAP)
Scan for Access Points (requires both steps):
modprobe wlan_scan_sta (To insert the scanning module)
wlanconfig athx list scan (To list the APs)
lshw
This command lists detailed hardware information.

sudo lshw
We can limit the the output to specific devices by adding options to the comman
d. The following option "-businfo" lists information about any SCSI, IDE, IDE de
vices and their bus addresses along with the class of each device.

sudo lshw -businfo

BusInfo
Device
Class
Description
pci@00:1f.5
multimedia
82801CA/CAM AC'97 Audio Controller
pci@00:1f.6
communication
82801CA/CAM AC'97 Modem Controller

pci@03:00.0
ath0
network
AR5212 802.11abg NIC
You can then use the "-C network" option to limit output so it only shows netwo
rking devices.

sudo lshw -C network

*-network
description: Wireless interface
product: AR5212 802.11abg NIC
vendor: Atheros Communications, Inc.
physical id: 1
bus info: pci@03:00.0
logical name: ath0
version: 01
serial: 00:11:95:50:be:62
width: 32 bits
clock: 33MHz
capabilities: bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=ath_pci driverversion=0.9.6.0 (EXPERI
MENTAL) ip=192.168.1.12 multicast=yes wireless=IEEE 802.11g
resources: iomemory:10800000-1080ffff irq:11
2.1.1. Key Points
The configuration line will tell you if there is a driver loaded for your device
, except devices using orinoco drivers.
If you do not see a driver listed here, then there is not one loaded and assigne
d to the device, and it will not show up in iwconfig output or the nework-admin
gui.
The businfo option can show if devices are recognized and memory is readable but
the device is not physically on the bus. This is rare but it has been seen. It
may seem cryptic but your output will vary greatly and there needs to be some ch
aracters (other then 0) here denoting its place in the pci bus.
The logical name (see example above) is assigned if the driver has been recognis
ed. If there is none, the problem is either the card or the driver. Also, wmaste
r0 is a generic driver used by the kernel, and if this is the logical name assig
ned there is usually a problem with the driver also.
TODO: What does it mean when it shows *-network UNCLAIMED, and no configuration
line is present?
2.2. lspci
This command lists information about devices on the pci bus. Adding the -v optio
n results in more detailed output:

lspci -v
You can limit the output by piping the output with grep

lspci -v | grep Ethernet

0000:03:00.0 Ethernet controller: Atheros Communications, Inc. AR5212 802.11abg


NIC (rev 01)
'''Subsystem: D-Link System Inc D-link DWL-G650 (Rev B5)''' Wireless car
dbus adapter
Flags: bus master, medium devsel, latency 168, IRQ 11
Memory at 10800000 (32-bit, non-prefetchable) [size=64K]
Capabilities: [44] Power Management version 2
Adding the -n option to lspci makes the output include the numerical PCI vendor
and device ID's.

sudo lspci -n

0000:03:00.0 0200: '''168c:0013''' (rev 01)


2.2.1. Key Points
This command shows the revision of the card (in above example the revision of th
e card is B5 not 01).
Using the -n option you can find the PCI ID (168C:0013) of the card and find the
correct driver to use with ndiswrapper. ndiswrapper list.
2.3. lsusb
This command lists information about devices on the USB bus.

sudo lsusb -v

$ lsusb
Bus 005 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
Bus 004 Device 002: ID 2001:3700 D-Link Corp. [hex] DWL-122 802.11b
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
2.4. lsmod
This command lists kernel modules that are loaded and running.

sudo lsmod
When the command lshw was run, you saw the name of the driver allocated to the
device. See example above. You can pipe this command through grep to limit the o

utput.

lsmod | grep ath

ath_pci
78908 0
ath_rate_sample
16776 1 ath_pci
wlan
141532 4 wlan_wep,ath_pci,ath_rate_sample
ath_hal
148432 3 ath_pci,ath_rate_sample
2.5. modprobe
modprobe runs or stops a module from running. Most wireless drivers in Ubuntu 5.
10 (Breezy Badger) are in a module form. The following commands remove or add a
module.
When a recognized device loads, the kernel automatically loads the correct modu
le for the device. This command is only needed to manually run a module
To start a module run this command:
sudo modprobe <module>
To stop and remove a module run this command:
sudo modprobe -r <module>
2.6. rfkill list
This command prints information detailing whether there are software or hardware
blocks on your rf devices. To get a list of devices and their hardware and soft
ware status, try

rfkill list
2.7. iwconfig
This command prints information about a wireless interface and allows you to con
figure the network interface from the command line.

sudo iwconfig

* eth0
* ath0

no wireless extensions.
IEEE 802.11g ESSID:"XXXXX"
Mode- Managed '''Frequency- 2.437 GHz''' '''Access Point- 00:17:16:1

D:FC:DE'''
Bit Rate-36 Mb/s Tx-Power-18 dBm Sensitivity=0/3
Retry- off RTS thr:off Fragment thr- off
Encryption key:xxxx-xxxx-xx Security mode:restricted
Power Management off
Link Quality=50/94 Signal level=-45 dBm Noise level=-95 dBm
Rx invalid nwid:10911 Rx invalid crypt:0 Rx invalid frag:0

Tx excessive retries:0 Invalid misc:0


2.7.1. Key Points

Missed beacon:0

This example shows the interface of ath0. If you do not see anything like this s
ample then you do not have a working driver.
The interface may not be named "ath0". It could say "wlan1". You may need to use
the correct interface name to configure WICD or other wireless manager.
Access Point: If you see all zeros here or nothing then you are not connected/as
sociated to your router. When you are connected it will show the mac address of
the router here.
Frequency more commonly known as channel. If you can not connect to your router
ensure frequency is correct.
You can not set the channel(currently with breezy or earlier) via the network g
ui. Most drivers are set up as auto so it changes to the corresponding channel o
f the ap you're trying to connect to. But if you must make the change then this
is the command to change it.

sudo iwconfig <ath0> channel <X>


or
sudo iwconfig <ath0> freq <x.xxxG>
Channel/Frequency Chart
Ch 1
2.412
Ch 2
2.417
Ch 3
2.422
Ch 4
2.427
Ch 5
2.432
Ch 6
2.437
Ch 7
2.442
Ch 8
2.447

Ch 9
2.452
Ch 10
2.457
Ch 11
2.462
Ch 12
2.467
Non US Channels
Ch 13
2.472
Ch 14
2.484
2.8. ip
This command is similar to iwconfig with the following differences.
It is a more general networking command. It works with any interface whether wir
eless or wired.
Its configuration options and output show different networking references or set
different settings.
ip addr

2: ath0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP ql


en 1000
link/ether 00:11:95:50:be:62 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 scope global ath0
inet6 fe80::211:95ff:fe50:be62/64 scope link
valid_lft forever preferred_lft forever
2.8.1. Key Points
The benefit with iproute2 on a wireless device is it shows if you have an IP add
ress assigned to the device which is noted next to inet addr. iwconfig may show
you're connected to your router but you still have no internet connection withou
t an IP address assigned to the device.
2.9. iwlist
This command will give you more detailed information from the wireless interface
such as a scan of all available routers with in range.

sudo iwlist <ath0> scan

ath0

Scan completed :
Cell 01 - Address: 00:13:46:1D:BC;0E
ESSID:"xxx"
Mode: Master
Frequency: 2.437 GHz (Channel 6)
Quality=49/94 Signal level=-46 dBm Noise level=-95 dBm
Encryption key:on
Bit Rate:1 Mb/s
Bit Rate:2 Mb/s
Bit Rate:5 Mb/s
Bit Rate:6 Mb/s
Bit Rate:9 Mb/s
Bit Rate;11 Mb/s
Bit Rate;12 Mb/s
Bit Rate;18 Mb/s
Bit Rate;24 Mb/s
Bit Rate;36 Mb/s
Bit Rate;48 Mb/s
Bit Rate;54 Mb/s
Extra bcn_int=100
2.9.1. Key Points
If you get a completed scan like the example above, your device and driver are p
robably working properly.
Some devices, such as orinoco cards, do not support scanning so this command may
not work for you.
2.10. dhclient
dhclient deals with DHCP if your router is running as a DHCP server.

sudo dhclient <ath0>


If you are associated with your router try running this command to get IP and o
ther information to set up connection.
2.11. ping
ping is a good troubleshooting command to track down where the connection proble
m may be. Ping works like SONAR by sending an echo request to a server, waiting
for it to respond and recording the time taken for the response to arrive.
ping your local loopback device. The -c 4 option means that 4 echo requests will
be sent. 127.0.0.1 is the IP address for the local loopback device; a special a
ddress that is actually your own computer. This is identical to pinging yourself
.

ping -c 4 127.0.0.1
If this doesn't work then there is a problem in the TCP/IP stack somewhere.
If your device is assigned an IP address, ping that. use iproute2 to find the I
P address assigned to the device

ping -c 4 <192.168.1.11>

ping your router


ping -c 4 <192.168.0.1>
ping an external site using its IP address
ping -c 4 216.239.57.99
ping an external website using its common name.
ping -c 4 www.google.com
If you can ping an external site with its IP address but not the common name th
en there is a DNS nameserver problem.
Identifying Your Device
Manufacturers and retailers often rebrand hardware to sell under their own brand
. Because of this, some seemingly different devices can be internally identical
and thence use identical drivers. Even if devices are not identical, there is a
limited number of wireless chips that manufacturers can use. As a result, many d
rivers will work for multiple devices with little or no alteration.
For this section, it will be useful to have
Your device
The packaging and contents for your device
A driver disc - even if it only contains Windows drivers.
An alternate working internet connection for downloading software and drivers.
Initially, note down the following:
Manufacturer
Complete model number
Any version numbers that may be printed on the device or its packaging. These ca
n be crucial, so look carefully.
Anything on the driver disc that identifies either the device itself or the comp
onents it uses. Wireless implementation chips are often operated by firmware, a
type of software written specifically for that chip.
2. Check for Device Recognition
Check that Ubuntu can see and identify your device.
Open a terminal window and type:
lshw -C network
This command lists network hardware.
Check that the results correspond to the information you gathered above.
*-network
description: Wireless interface
product: AR5212 802.11abg NIC
vendor: Atheros Communications, Inc.
physical id: 1
bus info: pci@03:00.0
logical name: ath0
version: 01
serial: 00:11:95:50:be:62

width: 32 bits
clock: 33MHz
capabilities: bus_master cap_list ethernet physical wireless
configuration: broadcast=yes '''driver=ath_pci driverversion=0.9.6.0 (EXP
ERIMENTAL)''' ip=192.168.1.12 multicast=yes wireless=IEEE 802.11g
resources: iomemory:10800000-1080ffff irq:11
If no wireless devices are listed, the next step will depend on the type of inte
rface your device uses.
If a wireless device shows up then continue to the Device Drivers page
3. PCI Devices
PCI devices should be fairly straightforward to identify. When a device is disco
vered, Ubuntu checks the device's PCI ID against the PCI ID Database and determi
nes the manufacturer, model number and version (if applicable).
Open a terminal window and enter the following command:
sudo lspci -nn
The following command is specific to wireless chipsets:
lspci -nn | grep 0280
4. USB Devices
Like PCI devices, USB devices are identified by their USB ID, a unique number as
signed to each device type.
For USB devices, use lsusb.
5. CardBus and PCMCIA Devices
Startup your computer without the wireless adapter plugged in.
Login when/if prompted.
When the desktop loads, open a terminal window and type the following command:
sudo tail -f /var/log/messages
Insert your wireless adapter into an available slot.
Repeat the command above and note the difference between the two.
If the above does not work, see the next section.
5.1. Manual Installation of a PCMCIA/CardBus Card
5.1.1. Non-recognized Card
Some devices are not recognized by the OS upon insertion.
If card doesn't show up (in lshw) try these steps:
Run the following command. Hopefully you'll get some output about the device.
sudo pccardctl ident
Socket 0:
product info: "Atheros Communications, Inc.", "AR5001-0000-0000", "Wireless
LAN Reference Card", "00"
manfid: 0x0271, 0x0012
function: 6 (network)
If you get no output then the memory on the card cannot be read.
Now we need to open a configuration file and add this information to it:
gksudo gedit /etc/pcmcia/config.opts
the information you add should look like this, with your own data substituted.

card ""Atheros Communications, Inc.", "AR5001-0000-0000", "Wireless LAN"


manfid 0x0271, 0x0012
function: 6 (network)
bind "ath_pci"
After making this change run this command:
sudo kill -HUP `cat /var/run/cardmgr.pid`
Now run lshw to see if the card is recognized and loaded properly.
Most cards requiring this step will be older devices. You should not have to do
this with any cards made in the past few years, but there can be exceptions.
Notice the bind line which states what driver should be allocated to the device
. You will need to find what driver your device uses. More on that in the next s
tep.
5.2. Problem with bridge in PCI bus line
On several, especially new systems the Yenta bridge is not on the
e, but behind a PCI-to-PCI bridge. On some x86 or x86_64 systems,
aren't corrreclty set up by the BIOS, which may cause CardBus and
vices not to show up in lspci or in pccardctl ident correctly. If
at this may be the cause, issue this command:

root PCI bridg


these bridges
even PCMCIA de
you suspect th

lspci -v | grep subordinate


Its result may be like this:
Bus: primary=00, secondary=02, subordinate=04, sec-latency=64
Bus: primary=02, secondary=03, subordinate=06, sec-latency=176
Bus: primary=02, secondary=07, subordinate=0a, sec-latency=176
Let's decode the first line: bus 0 (primary) is bridged to busses 2 (secondary)
to 4 (subordinate) by a bridge. The second and the third line state that bus 2 i
s bridged to busses 3-6, and 7-10. However, the CPU (which itself is connected t
o bus 0 through the root bridge) needs to be able to access all these busses. If
you try to walk the tree to bus 7, for example, you see that the CPU can't get
there, as bus 0 is only bridged to busses 2 to 4.
If this is the case, or you find a message stating "try pci=assign-busses" in th
e dmesg log, append the following to the kernel boot line:
pci=assign-busses
5.2.1. System locks upon card insertion
When a card is first inserted, the system attempts to read the card's memory. Th
is can sometimes cause your system to lock-up. Try this to see if it helps:
Open the file /etc/pcmcia/config.opts
gksudo gedit /etc/pcmcia/config.opts
Find the following section:
include
include
include
Change it
include

memory 0xc0000-0xfffff
memory 0xa0000000-0xa0ffffff
memory 0x60000000-0x60ffffff
to look like this:
memory 0xd0000-0xdffff

include memory 0xc0000-0xcffff


include memory 0xc8000-0xcffff
include memory 0xd8000-0xdffff
Files
/etc/network/interfaces
This file stores networking interface settings.
Network Manager cannot manage any interfaces that are named in this file. Networ
k Manager has been the default way of managing network connections since Ubuntu
8.10 (Intrepid Ibex)
If you are not currently using Network Manager and would like to, delete or comm
ent out (with a # at the start of each line) your interfaces except for the two
lines referring to lo (this is an internal loopback). Since Ubuntu 8.10, this fi
le will look similar to this:
# The loopback network interface
auto lo
iface lo inet loopback
Do not use an auto stanza if you are using a PCMCIA deivce that you want to star
t automatically at boot-time. Add map <ath0> to the /etc/interfaces file. Your f
ile should contain something similar to:
#echo connects ath0 when device is hotplugged. using echo instead of grep allo
ws any device to be brought up when hotplugged. Note this could cause a problem
if a device is active and another one that is mapped is plugged in.
mapping hotplug
script echo
map ath0
Check your routers settings to ensure it can accept another connection.
If you are running Ubuntu 8.04 (Hardy Heron) or earlier, you should have somethi
ng similar to this:
# The loopback network interface
auto lo
iface lo inet loopback
# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
# With lines # out these don't work. If they were removed this would hotplug o
nly eth0 when cable is plugged in with active network
#mapping hotplug
#
script grep
#
map eth0
#echo connects ath0 when device is hotplugged. using echo instead of grep allo
ws any device to be brought up when hotplugged. Note this could cause a problem
if a device is active and another one that is mapped is plugged in.
mapping hotplug
script echo
map ath0
#interface of ath0 device with wep setting (not all these lines are required b
ut show you options that may be needed)
iface <ath0> inet dhcp
wireless-essid xxxx
wireless-key xxxxx
wireless-key xxxx-xxxx-xx (in certain situations a - is needed after every 4 c

haracters to work)
wireless-key1 xxxx (add a number after key to specify key number to use.)
wireless-defaultkey 1 (specifies which key is default)
wireless-key s:xxx (add s: in front of key if ascii form)
wireless-key XXXXXXXXXX open|restricted (if using shared/restricted setting ad
d this line)
auto <ath0>
Other Resources
An /etc/network/interfaces sample - Part of LinuxPlanet's Connecting to a Wirele
ss LAN with Linux, a tutorial by Carla Schroder.
This file has a manual page. Type man interfaces in a terminal to view it.
/usr/share/doc/ifupdown/examples/network-interfaces.gz. You can read through it
with the cat command and then adding | less to the end of the command.
/etc/resolv.conf
This file stores Domain Name Server (DNS) settings including nameserver addresse
s, local domain names/search server addresses and some other advanced settings.
This file has a manual page. Type man resolv.conf in a terminal to view it.
/etc/modules
This file lists some of the modules that will be loaded into the kernel at boottime. If a driver won't load at boot, you can add it to this list so that it doe
s.
/etc/modprobe/
To enable specific configuration options for a driver create an appropriate conf
ig file in this folder eg. config.conf or [drivername].conf and add the options
you want to set in this file.
notes
With the release of Ubuntu 11.10 and kernel 3.x.x some wireless drivers now no l
onger need 11n_disable and 11n_disable50 options. Theses options may actually ca
use the driver to fail to load. Check the /etc/modprobe.d/ folder for config fil
es that contain option reference to your driver, for example
options iwlagn 11n_disable=1 11n_disable50=1
These options can be found in config.conf or [drivername].conf file eg. intel_11
n_disable.conf or awlagn.conf.
/etc/modprobe.d/blacklist
If you don't want a driver to load at boot you add it to this list. Usually this
is used if you have a driver conflict and/or you want to make sure a specific d
river is used. Note: this method will not work unless the diver is a LKM (loadab
le kernel module) If driver/module was compiled into the base kernel, it will st
ill load if blacklisted.
About iw
iw is a new nl80211 based CLI configuration utility for wireless devices. It sup
ports almost all new drivers that have been added to the kernel recently.
iw is still under development. Features are added 'as we go'. The only documenta
tion that exists for iw is this page. Please help expand it.

There is a page listing use cases with iwconfig and iw: replacing iwconfig.
Getting iw
Release tarballs of iw are available from http://linuxwireless.org/download/iw/.
Alternatively, you can download iw from git: http://git.sipsolutions.net/iw.git,
the web interface can also create tarballs for arbitrary revisions.
Build requirements
libnl >= libnl1
libnl-dev >= libnl-dev-1
pkg-config
Using iw requires you to have libnl, the first working version is 1.0
is release introduced genl, Generic Netlink, which nl80211 relies on.
ibutions are shipping 1.1 these days. If your distribution's libnl is
rsion then you'll have to download and compile libnl yourself for now
t.kernel.org/?p=libs/netlink/libnl.git;a=summary).

pre8 as th
Most distr
a wrong ve
(http://gi

Help
Just enter
iw help
on your command line and it will print out the commands it supports.
Getting device capabilities
Use the following to get device capabilities for all devices, such as band infor
mation (2.4 GHz, and 5 GHz), and 802.11n information:
iw list
Scanning
iw dev wlan0 scan
Listening to events
Just use
iw event
When debugging, it can be useful to see the auth/assoc/deauth/disassoc frames, u
se
iw event -f
and sometimes timing information is also useful:
iw event -t
Getting link status
To determine if you are connected to an AP or not and if you are the last TX rat
e used you can use the command below.
Example output when associated to a legacy (non-802.11n) AP:
iw dev wlan0 link
Connected to 04:21:b0:e8:c8:8b (on wlan0)

SSID: attwifi
freq: 2437
RX: 2272 bytes (18 packets)
TX: 232 bytes (3 packets)
signal: -57 dBm
tx bitrate: 36.0 MBit/s
Example output when associated to an 802.11n AP:
iw dev wlan0 link
Connected to 68:7f:74:3b:b0:01 (on wlan0)
SSID: tesla-5g-bcm
freq: 5745
RX: 30206 bytes (201 packets)
TX: 4084 bytes (23 packets)
signal: -31 dBm
tx bitrate: 300.0 MBit/s MCS 15 40Mhz short GI
Example output when not connected to an AP:
iw dev wlan0 link
Not connected.
This would happen if you are not connected to an AP. To connect to an AP you can
use iw connect if the connection requires:
No encryption
Uses WEP for encryption
If you need to connect to an AP with WPA or WPA2 encryption requirements then yo
u must use wpa_supplicant.
Establishing a basic connection
You can use iw to connect to an AP directly if and only if the AP has:
No encryption
Uses WEP for encryption
It however should be noted that if you disconnect from the AP, which can happen
quite frequently on a busy environment, you will need to reissue the command. If
you do not want to do this you can just use wpa_supplicant which will automatic
ally try to reconnect you when you get disconnected.
If you do choose to deal with disconnects yourself you can use iw connect as fol
lows.
To connect to an AP that has encryption disabled, where its SSID is foo:
iw wlan0 connect foo
Suppose you have two APs with the SSID foo, and you know the one you want to con
nect to is on the frequency 2432, you can specify the frequency to use:
iw wlan0 connect foo 2432
To connect to an AP that uses WEP, you can use:
iw wlan0 connect foo keys 0:abcde d:1:0011223344
Getting station statistics
To get station statistic information such as the amount of tx/rx bytes, the last

TX bitrate (including MCS rate) you can do:


$ iw dev wlan1 station dump
Station 12:34:56:78:9a:bc (on wlan0)
inactive time: 304 ms
rx bytes:
18816
rx packets:
75
tx bytes:
5386
tx packets:
21
signal:
-29 dBm
tx bitrate:
54.0 MBit/s
Getting station statistics against a peer
If you want to get specific statistics against a peer you station is communicati
ng with you can use the following:
sudo iw dev wlan1 station get <peer-MAC-address>
In the case of a STA the above <peer-MAC-address> would be the MAC address of yo
ur AP.
Modifying transmit bitrates
You can set preference for transmitting using only certain legacy bitrates. For
example:
iw wlan0 set bitrates legacy-2.4 12 18 24
Setting preference for transmitting using MCS rates is not yet supported.
Setting TX power
You can set the txpower by using either the device interface name of the respect
ive phy.
iw dev <devname> set txpower <auto|fixed|limit> [<tx power in mBm>]
iw phy <phyname> set txpower <auto|fixed|limit> [<tx power in mBm>]
Power save
To enable power save by default you can use:
sudo iw dev wlan0 set power_save on
For mac80211 drivers this means Dynamic Power Save gets enabled.
To query the current power save settings you can use:
iw dev wlan0 get power_save
Adding interfaces with iw
There are several modes supported. The modes supported are:
monitor
managed [also station]
wds
mesh [also mp]
ibss [also adhoc]

To see a description of these please read our modes documentation.


For example to add a monitor interface:
iw phy phy0 interface add moni0 type monitor
where you can replace monitor by anything else and moni0 by the interface name,
and need to replace phy0 by the PHY name for your hardware (usually phy0 will be
correct unless you hotplugged or reloaded any modules.) If your udev is configu
red incorrectly, the newly created virtual interface may be renamed by it right
away, use ip link to list all interfaces.
Note that in case you want to monitor 802.11n you will need to specify channel w
idth (20 or 20/40MHz) and in case of 20/40MHz if the upper or lower channel is b
eing used. To do so you would use:
iw dev <devname> set freq <freq> [HT20|HT40+|HT40-]
or
iw phy <phyname> set freq <freq> [HT20|HT40+|HT40-]
You can also specify channel instead of frequency:
iw phy <phyname> set channel <channel> [HT20|HT40+|HT40-]
iw dev <devname> set channel <channel> [HT20|HT40+|HT40-]
To create a new managed mode interface you would use:
iw phy phy0 interface add wlan10 type managed
Note that the interface is automatically put into AP mode when using hostapd.
Modifying monitor interface flags
You can customize the type of monitor interface you create. This can be very use
ful for debugging purposes on end user systems. For example suppose you want to
help a user you can take advantage of the fact that a monitor interface in mac80
211 uses radiotap to pass up to userspace additional data. Say we want to help a
user fish out data without affecting the device's performance by setting it it
to a full monitor interface an monitor interface with no additional monitor flag
s can be created as follows:
iw dev wlan0 interface add fish0 type monitor flags none
You can then request the user to use tcpdump on a session:
tcpdump -i fish0 -s 65000 -p -U -w /tmp/fishing.dump
The nice thing about these type of alternative monitor interfaces is you can fur
ther extend radiotap even with vendor extensions to add more data to radiotap to
help debug device specific features.
Keep in mind this requires drivers to honor mac80211's flag requests strictly, s
o drivers like ath5k and ath9k which still enable flags based on operation mode
need to be fixed to take advantage of this.
Monitor flags possible
The following are flags you can specify:

none
fcsfail
plcpfail
control
otherbss
cook
Deleting interfaces with iw
The command line is:
iw dev moni0 del
Where "moni0" was the virtual interface interface that was created with the firs
t command
Virtual vif support
There is a dedicated section for virtual vif support, see the iw vif page.
Setting frequency with iw
The command line is:
iw dev wlan0 set freq 2412 [HT20|HT40+|HT40-]
Setting channel with iw
The command line is:
iw dev wlan0 set channel 1 [HT20|HT40+|HT40-]
Updating your regulatory domain
The command line is:
iw reg set alpha2
Where "alpha2" is the ISO/IEC 3166 alpha2 country code. The information used and
set comes from our regulatory infrastructure.
You can also use the latest wpa_supplicant (as of 0.6.7) now to change your regu
latory domain, to do so just add a "COUNTRY=US" entry into your configuration fo
r example.
Creating and inspecting Mesh Point interfaces with iw
You may add a mesh interface to drivers that support Mesh Point operation. Mesh
Point interfaces have a mesh_id parameter which may be up to 32 bytes long. For
example, to add an interface "mesh0" to device phy0 with mesh_id "mymesh",
iw phy phy0 interface add mesh0 type mp mesh_id mymesh
Mesh Point interfaces, by default, are configured on Channel 1. Mesh Point opera
tion begins when the interface is brought up. In the default configuration, Mesh
Point interfaces will automatically detect and attempt to create Peer Links wit
h other Mesh Points (peers) having the same mesh ID. Use the station list and st
ation statistics to see the peer list and Peer Link status.
After sending traffic (ex: pinging another mesh node), you may wish to see a lis
t of Mesh Paths:
iw dev mesh0 mpath dump

Please see the open80211s.org HOWTO for further details on Mesh Point related co
mmands and their output, as well as more examples. iw also provides commands for
advanced Mesh Point configuration. These are documented in the Advanced Tinkeri
ng section of the open80211s HOWTO.
Setting up a WDS peer
To create a WDS peer you will first need to create an interface of WDS type, and
then set the peer:
iw phy phy0 interface add wds0 type wds
iw dev wds0 set peer <MAC address>
In order for this to work the driver must implement the cfg80211 callback set_wd
s_peer(). mac80211 implements this callback, so the respective mac80211 driver w
ould just need to support WDS type interfaces. What WDS will do is replace the f
irst address on the 802.11 header with the peer address when TXing frames. Inste
ad of using WDS though you may want to consider using 4-address mode described b
elow if you have control over the software running on the AP and respective clie
nts/peers connected.
Using 4-address for AP and client mode
In some situations it might be useful to run a network with an Access Point and
multiple clients, but with each client bridged to a network behind it. For this
to work, both the client and the AP need to transmit 4-address frames, containin
g both source and destination MAC addresses.
Linux wireless has support for 4-address mode for AP and STAs but each driver ne
eds to define this capability explicitly. All mac80211 drivers support 4-address
mode if AP or STA modes of operation are supported respectively.
On the AP side you can enable 4-address frames for individual clients by isolati
ng them in separate AP VLANs which are configured in 4-address mode. Such an AP
VLAN will be limited to one client only, and this client will be used as the des
tination for all traffic on its interface, regardless of the destination MAC add
ress in the packet headers. The advantage of this mode compared to regular WDS m
ode is that it's easier to configure and does not require a static list of peer
MAC addresses on any side.
To enable 4-address mode when creating an interface you should add 4addr on, for
example:
iw phy phy0 interface add moni0 type managed 4addr on
When the client side interface is included in a bridge, add -b <bridge_interface
> when running wpa_supplicant.
In hostapd you can enable this with the flag on hostapd.conf:
wds_sta=1