How To Troubleshoot Wireless Network Connection in Ubuntu

Sponsored Link
In setting up their wireless connection for the first time, Im discovering many individuals having problems connecting through Network Manager or other GUI wireless connection tools. In fact my Network Manager is intermittently buggy, connecting sometimes and not others. This guide benefits all users in case the GUI tools are not working, and is useful for testing a wireless connection during initial installation of wireless drivers since it provides for good debugging output.

Unencrypted/ WEP / WPA connections will be covered in this guide

Pre-requisites

1. Properly installed network driver --- This guide can be used to troubleshoot driver installation to see if it is properly functioning

2. The ESSID of your router must be broadcasted and not hidden

3. Knowlege of your wireless cards driver (please see Prerequisite #4 to determine driver). Those using the r8187/r818x driver please see the end of the guide

4. Knowledge of your wireless card's Interface Name -- The user must know the proper interface of the wireless connection (wlan0, eth1, rausb1, etc). To discover this information, at command line type

lshw -C network

There may be multiple interfaces listed, however look under the section appropriate to your wireless device for the line labeled logical name. Here is an example

*-network
description: Wireless interface
product: BCM4306 802.11b/g Wireless LAN Controller
vendor: Broadcom Corporation
physical id: 0
bus info: pci@06:00.0
logical name: wlan0
version: 03
serial: 00:12:17:35:17:10
width: 32 bits
clock: 33MHz
capabilities: bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=ndiswrapper+lsbcmnds driverversion=1.48rc1+Cisco-Linksys ,LLC.,02/1 ip=192.168.1.101 latency=64 multicast=yes wireless=IEEE 802.11g
resources: iomemory:3c000000-3c001fff irq:11

In the example above the interface name is wlan0. I will refer to the interface name throughout the rest of this guide as [interface].

For people first setting up their connection, please note that the above also lists the driver used for the network card. In the example above, the driver used is ndiswrapper. If your network device comes back UNCLAIMED or there is no driver listed, then you have not correctly installed the driver for your device. You must review the procedures for installation of your wireless driver.

For those wanting to use static IP addresses, please see section at bottom of guide regarding configuration for static IP addresses

Unencrypted Connection

All commands typed at the command line:

sudo ifconfig [interface] down
sudo dhclient -r [interface]
sudo ifconfig [interface] up
sudo iwconfig [interface] essid "ESSID_IN_QUOTES"
sudo iwconfig [interface] mode Managed
sudo dhclient [interface]

WEP Connection

You must have either your 64bit or 128 bit HEX Key or the ASCII Equivalent of your HEX Key.

sudo ifconfig [interface] down
sudo dhclient -r [interface]
sudo ifconfig [interface] up
sudo iwconfig [interface] essid "ESSID_IN_QUOTES"
sudo iwconfig [interface] key HEX_KEY <<<-------- If using ASCII Equivalent, this is s:ASCII_KEY (please make note of the prefix s:) ****Additional Comand that may be needed -- sudo iwconfig [interface] key open <<<----See note below sudo iwconfig [interface] mode Managed sudo dhclient [interface] ***The security mode may be open or restricted, and its meaning depends on the card used. With most cards, in open mode no authentication is used and the card may also accept non-encrypted sessions, whereas in restricted mode only encrypted sessions are accepted and the card will use authentication if available. WEP Key and special characters

If your WEP key has some special characters in it. You might receive the error message

$ sudo iwconfig eth0 key s:KG"hSRaS{G!#[
sudo iwconfig eth0 key s:KG"hSRaS{Gsudo iwconfig eth0 key s:KG"hSRaS{G[

.....

$sudo dhclient eth0
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 10
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 14
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
No DHCPOFFERS received.
No working leases in persistent database -- sleeping.

You need to escape the special characters with a \ and it works

$sudo iwconfig eth0 key s:KG\"hSRaS\{G\!\#\[

WPA Connection -- WPA-PSK or WPA2-PSK

For uses of Ra-based chipsets: rt61, rt73, rt2500 please skip directly to the WPA Section entitled WPA with Ra based chipsets

Requirements: In most cases the wpa_supplicant package is required in order to connect via WPA. If you have a working ethernet or unencrypted/WEP wireless connection, this package may be installed via:

sudo aptitude install wpasupplicant

If only wireless is available, I would recommend that an unencrypted connection first by established and tested first before directly proceeding to make a WPA connection. WPA adds another layer of complexity.

Creation of /etc/wpa_supplicant.conf file

At command line:

gksu gedit /etc/wpa_supplicant.confInside the file add the following for WPA(1):

ap_scan=1
ctrl_interface=/var/run/wpa_supplicant

network={
ssid="ESSID_IN_QUOTES"
scan_ssid=0
proto=WPA
key_mgmt=WPA-PSK
psk="ASCII PSK Password in Quotes"
pairwise=TKIP
group=TKIP
}

For WPA(2)

ctrl_interface=/var/run/wpa_supplicant

network={
ssid="ESSID_IN_QUOTES"
psk="ASCII PSK Password in Quotes"
key_mgmt=WPA-PSK
proto=RSN
pairwise=CCMP
}

***Word of caution --- In some cases I have found WPA(2) to have different settings than the above. Some Broadcom cards use the pairwise/group TKIP cipher for WPA2 rather than CCMP. I would suggest all initially use WPA(1) and then later convert to WPA2 since some variations to the above may be needed

Connect via command line

sudo ifconfig [interface] down
sudo dhclient -r [interface]
sudo wpa_supplicant -w -D[****see footer below***] -i[interface] -c/etc/wpa_supplicant.conf -dd
sudo ifconfig [interface] up
sudo iwconfig [interface] mode Managed
sudo dhclient [interface]

***footer
The value listed here is dependent on the driver you have installed. Typing man wpa_supplicant at command line will give you the full gamut of choices however a quick reference
ndiswrapper=wext (use wext and not ndiswrapper despite what documentation might suggest)
ath_pci = madwifi
ipw2100/2200=ipw

WPA with Ra Based Chipsets

Ra cards do not require the wpa_supplicant package to use WPA. Here is how to connect from the command line with these cards

WPA(1)

sudo ifconfig [interface] down
sudo dhclient -r [interface]
sudo ifconfig [interface] up
sudo iwconfig [inteface] essid "ESSID_IN_QUOTES"
sudo iwpriv [interface] set AuthMode=WPAPSK
sudo iwpriv [interface] set EncrypType=TKIP
sudo iwpriv [interface] set WPAPSK="YOUR_WPA_PSK_KEY"
sudo dhclient [interface]

A successful connection in all cases will results in this

user@computer:~$ sudo dhclient wlan0
There is already a pid file /var/run/dhclient.pid with pid 134993416
Internet Systems Consortium DHCP Client V3.0.4
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/wlan0/00:12:17:35:17:10
Sending on LPF/wlan0/00:12:17:35:17:10
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPOFFER from 192.168.1.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.101 --- renewal in 299133 seconds.

The computer in this example has received an IP address of 192.168.1.101

Users of RTL 8180, RTL8185, RTL 8187 using the built in native r8187 / r818x drivers

By default the r8187 and r818x drivers are blacklisted due to a know bug. These drivers are usuable however with a twist to the above methods

If you want to try using these drivers, please load the kernel modules:

sudo modprobe r818x
sudo modprobe r8187

These drivers require a bogus or extra letter be suffixed to the essid name in order for these drivers to work

For example if your are trying to connect to a router with essid=Router, at he command line you would type essid=Routerx. Notice the extra x or bogus character. I have provided an example using the unencrypted connection procedure below, however this extra character needs to be used if attempting to connect to all network types (unencrypted/ WEP / WPA)

sudo ifconfig [interface] down
sudo dhclient -r [interface]
sudo ifconfig [interface] up
sudo iwconfig [interface] essid "Routerx"
sudo iwconfig [interface] mode Managed
sudo dhclient [interface]

If these drivers work for you, and you would like these drivers to load automatically at startup for you, avoiding to have to type sudo modprobe everytime, please edit your blacklist file

gksu gedit /etc/modprobe.d/blacklist

And comment out (or prefix the following lines with a # sign). You want the following lines to appear as below:

#blacklist r8187
#blacklist r818x

Static IP Addresses

Im going to give an example of how to configure your interface using a static IP address using an unencrypted wireless connection. The two lines highlighted below however can be used with WEP and WPA connections. Values in italics must be customized to meet your particular situation

sudo ifconfig [interface] down
sudo dhclient -r [interface]
sudo ifconfig [interface] 192.168.1.100 netmask 255.255.255.0 up
sudo route add default gw 192.168.1.1
sudo iwconfig [interface] essid "ESSID_IN_QUOTES"
sudo iwconfig [interface] mode Managed
sudo dhclient [interface]

If when using static IP addresses you are getting a problem with name resolution, you will have to specifiy specific dns (domain name servers) in order to translate URLs to IP addresses. Unfortunately there is not an easy way to configure this from the command line. This requires that you edit the /etc/resolv.conf file and manually enter the domain name server(s) you want to use. In many cases users can specifiy their router, their internet service providers dns servers, or use opendns (or use all three). Please note that changes made to the /etc/resolv.conf file will not be retained between reboots. To make the nameservers permanent, the /etc/dhcp3/dhclient.conf file needs to be edited

sudo gedit /etc/resolv.confand add the nameservers you want to use, one to a line, in the following format.

nameserver [nameserver]

You can add as many as you want but most isps normally provide two (primary and secondary).

Useful Wireless connection Commands

ifconfig -- lists IP address (similar to ipconfig in Windows)

iwlist scan -- shows wireless networks that are available in the area along with basic encryption information

lshw -C network -- Shows interface and driver associated with each networking device

lspci -nn -- Shows hardware connected to the pci bus

lsusb -- Shows USB connected hardware

lshw -C usb -- Additional info on USB related hardware (good for USB dongles)

cat /etc/modprobe.d/blacklist -- List modules that will not be loaded by the Operating System at boot time

lsmod -- lists currently loaded kernel modules. (Example usage -- lsmod | grep ndiswrapper)

route -n -- Lists kernel IP routing table --- Good for troubleshooting problems with the gateway (netstat -rn = equivalent command)

sudo route add default gw 192.168.1.1 -- Example of how to set the default gateway to 192.168.1.1

sudo route del default gw 192.168.1.1 -- Example of how to delete the default gateway setting

sudo modprobe ***** -- Loads the kernel module **** . (Example usage -- sudo modprobe ndiswrapper, sudo modprobe r818x, sudo modprobe ath_pci)

sudo modprobe -r **** -- Unloades the kernel module ****. (Example usage -- sudo modprobe -r ndiswrapper)

sudo ifup/ifdown -- Brings up/down the interface and clears the routing table for the specified interface

sudo ifconfig up/down -- Brings up/down the interface for the specified interface

sudo dhclient -- Request IP address from DNS server for specified interface

sudo dhclient -r -- Release IP address associated with specified interface

sudo iptables -L -- Lists firewall rules

dmesg | more -- Lists boot log --- good for troubleshooting problems with modules/drivers not being loaded

uname -r -- Displays kernel version

/etc/iftab (Feisty and pre-releases (Edgy, etc)) -- /etc/udev/rules.d/70-persistent-net.rules (Gutsy) -- File which assigns logical names (eth0, wlan0, etc) to MAC addresses

cat /etc/resolv.conf -- Lists DNS servers associated with network connections (Network Manager)

/etc/dhcp3/dhclient.conf -- File which sets or modifies dns (domain name servers) settings

Credit goes kevdog

Sponsored Link

You may also like...

46 Responses

  1. VeselaHouba says:

    I’m not sure, whether essid must be visible. My actual WPA connection is working fine on hidden essid.

  2. Cuppa-Chino says:

    I am using Hardy and built in rt8187 driver (kernel 2.6.24-12 generic) and most of the time I have absolutley no problem connecting to my wireless network at all, there seem to be problems with the driver after some large data transfers and a restart is required.
    I have never had to use the dummy letter in the essid

  3. mikmik says:

    “Static IP Addresses

    The two lines highlighted below however can be used with WEP and WPA connections. Values in italics must be customized to meet your particular situation”

    Excellent article! Two questions, though:
    What two lines were supposed to be “highlighted” and what values were supposed to be “in italics”?

  4. Marcos says:

    Real good troubleshooting.

    In my case, in a Dell D510 with a iw2200 (Feisty/Gutsy/Hardy Beta), my card won’t work with network config GUI @ home. I use WEP with restricted auth and fixed IP’s. I just can’t connect before I enter manually in the terminal the key via iwconfig and forcing restricted auth mode. All other networks run just fine with roaming mode.

  5. Mikmik says:

    Never mind “highlighted” and “italics”… I found the requested information in kevdogs original article: http://ubuntuforums.org/showthread.php?t=571188

  6. Michele says:

    I am using a Netgear with WEP and an ASII 10 digit key and I can’t get the key to work correctly. I followed your directions above and when I use the key s:1234567890, for example, and then run iwconfig it shows the key as 3132:3334:3536:3738:3930 and it doesn’t connect to my router. Is there another way for me to enter this ASCII key value?

  7. steveD says:

    I’m running Hardy and can successfully connect to my Netgear wireless router via a WG111v3, as long as router security is off.
    With WEP enabled, I keep getting the “Passphrase required…” dialog. Entering Passphrase or hex key gives me a bargraph signal indication for about 30s, then I’m asked for the passkey once more.
    The WG111 works fine on [spit] Windows.
    Using dhclient command gives me “No working leases…” message.
    Any ideas gratefully received!

  8. n.michele says:

    the unencrypted info was a lifesaver! tried everything I knew and various packages with no luck -finally googled my request and found this page and wham after opening terminal and typing in your unencrypted instructions
    sudo ifconfig [interface] down
    sudo dhclient -r [interface]
    sudo ifconfig [interface] up
    sudo iwconfig [interface] essid “ESSID_IN_QUOTES”
    sudo iwconfig [interface] mode Managed
    sudo dhclient [interface]

    and i ignored 2 replies that looked like errors (with my limited knowledge) and just kept typing it and rebooted and voila! was connected to the internet – :bows down: ty!

  9. Helen says:

    Hello:

    I am unable to connect to the internet. I have tried various commands and they all tell me that they are able to see my wireless card.

    I typed the following command per your instructions: lshw -C network.
    This was my result:
    *-network
    description: Wireless interface
    product: PRO/Wireless 3945ABG Network Connection
    vendor: Intel Corporation
    physical id: 0
    bus info: pci@0000:0b:00.0
    logical name: wmaster0
    version: 02
    serial: 00:1f:3c:9b:7a:a7
    width: 32 bits
    clock: 33MHz
    capabilities: bus_master cap_list ethernet physical wireless
    configuration: broadcast=yes driver=iwl3945 ip=192.168.1.100 latency=0 module=iwl3945 multicast=yes wireless=IEEE 802.11g

    I’m not sure what is causing the problem. Can you help?

    Thanks.

  10. Barbelo says:

    Hi,
    I used the guide and gives me the reply it should and network manager shouws I am connected. I tried the network tools and it all seems to be working fine the only problem is it does not open anything on firefox it says that the network has been reset and i can log in on yaho messenger but more often than not my messages dont arrive and no way of connecting with msn. any idea y?? I am out of clues since the computer keeps telling me there is no problem with the network and the other computers using the network have no problem whatsoever.
    thanks.

  11. Tommyt says:

    I have been an Ubuntu fan for about two years now. The big turnoff for me was never being able to get wireless to work on my LT.
    USB wireless would work for a time, then quit (5-20 minutes).

    Having downloaded Ubuntu 8.10RC and trying it out once again, my PCMCIA based Zyxel NWD-170N works like a charm! First time ever!
    Strange however that no light are present on the card, but DHCP’d within 10 seconds. I also set it to static and it connected even quicker.

    This is a first for me. I always wanted to love Ubuntu but could never get the wireless to work. Without that, I had to stay with XP. An LP w/o wireless? Why bother. But now, do very much hav a serious alternative.

    If you have played with Ubuntu and had similar (no wireless without headaches) results, your PCMCIA card refusing to be recognized, give 8.10 a shot!

    Thank you Ubuntu developers for putting time into this distro’s wireless. Now, I will be dual booting and really getting to use 8.10 and get to know it on my terms. This makes it useable for me now, before, it was a waste of time on the LT.

    THANKS for a real alternative now. You Mac guys can keep your Mac’s. I love them too but don’t have thousands to spend on a new machines & new software. Now, I’ll just get comfortable with Wine & Crossover and I will extol the virtues of Ubuntu to everyone I know!!!!!!!!!!!!!!!!

    tt

  12. supernova says:

    I am running a DELL B 130 with a Dell Wireless 1370 WLAN Mini-PCI Card Rev 4.2 I have Ubundu 8.10 and I am trying to establish and Internet Connection any suggestions. I am using a Dual Operating System with Windows XP Home Edition.

  13. HeadInTheClouds says:

    Excellent – many thanks this got me up and running
    Although I added a little from man iwconfig-
    sudo iwconfig [interface] key [3]
    Using the [2] to tell wireless to use wep key id 3 instead of 1 (default)
    I use this as a tiny enhancement to the minimal security of WEP (for those who don’t know there are 4 WEP keys available on most wireless routers)
    My print server has an old wireless card that only supports WEP, not WPA so stuck with WEP for now.
    Why doesn’t Gnome network manager support WEP key indexes?
    I managed to get
    /etc/network/interfaces to accept the above line on save, but every time I closed the network manager it changed back to the same line without the [3]

  14. Dominique says:

    Hi kevdog,

    great guide! Finally i’m connected *phew*! Thank you!

    greetings
    Dominique

  15. Devil says:

    Thanks For the Guide saved me looking a fool thought it was my router …..

  16. twowheeler says:

    Hey, great guide. I have a friendly suggestion for you. How about making a printer style sheet for your web pages, so that when we hit Print, it gets formatted nicely on paper? At the moment, all of the ads and menus make for rather a mess on paper. Thanks a keep up the good work.

  17. don says:

    new guy on the block
    i have just installed ubuntu on my hp which i ran it side by side an still kept my x p program . my question is. is there anybody out there that know how to get my verizon novatell usb 727 modem to work on this system 9.4 ubuntu

  18. Vlada says:

    i dont do it very often but i just cant resist this time and have to say THANKS! Awesome guide answers everything in a clear and concise way. You saved hours of my life.. TNX. V.

  19. Proximity says:

    Solution

    If You have any problem to connect to AP, try to add this command in the above commands after iwconfig [interface] essid “ESSID_IN_QUOTES”:

    iwconfig [interface] ap AP_MAC_address

    To get AP_MAC_address:

    iwlist [interface] scan

    In the list find your AP and enter to iwconfig its MAC address in the following format: xx:xx:xx:xx:xx:xx

    It helped me and it works!!!
    Greetings from Poland 😉

  20. larrythelabrat says:

    Thanks for putting up this guide, but it didn’t work for me. I upgraded from 9.04 to 9.10 and lost my functioning wireless connection (IBM thinkpad R51), I then did a clean install of 9.10 and the wireless still wouldn’t work.

    I went through your steps to try to diagnose the problem, and everything froze after
    sudo iwconfig [interface] key HEX_KEY
    I’ve been trying deal with this issue for days (have tried lots of people’s suggestions in the forums). At this point I’m going to try to go back to 9.04. Just a heads ups that you’re probably going to see a lot more traffic on this until 9.10 is smoother, seems to be a problem for lots of folks.

  21. Frank says:

    I am new to Linux, I am running UBUNTU 9.10 with
    a BELKIN N Wireless Router (FD8633ea4A P75554ea-A)
    I have tried everything you have published, but I
    have failed to make a WIRELESS connection..
    Everything works fine with a WIRED connection.
    I want to move my router to a better position,
    but not being able to connect wirelessly it cant
    be done.. Any help you can give me will be much
    appreciated.
    My wireless connector is a NETGEAR WG111v3 USB 2.0
    wireless-G
    Thankyou
    Frank Jones

  22. Werdermouth says:

    I had been contemplating switching to Linux for a quite a while and finally made the leap a three days ago. Unfortunately, like many others i’ve been trying to get the wireless with WEP to work and have spent many hours scouting forums and following suggestions but absolutely no success.

    It’s clear to me as I’m not alone there is a serious problem with Ubuntu 9.10 as it simply doesn’t work. I’ve had enough of wasting my time and going round in circles – everything works fine with XP and it’s also so much more user-friendly compared to the hoops you have to jump through to get Ubuntu working properly – it also has problems restarting after hibernating and always needs to be powered off and on.

    Perhaps I’ll try again sometime in the future when Linux has got it’s act together as there is little point in using it if you can’t have basic wireless access at home. Linux is a nice concept but it’s not for people who don’t have hours and hours to devote to its cause.

    Also, I’m quite computer literate but how many months of study do you need to understand the jargon just to get your laptop functioning using linux – is it always this obtuse and complicated? I think I’ll be sticking to Microsoft for a while longer as at least things work more or less smoothly.

  23. jon says:

    I am new to linux also, however I found that Ubuntu 9.10 has been the easiest linux OS to get to work with a wired and wireless network. Other features are also quite good. Sometimes it takes a little research to get things working the way you want. I would not give up too quickly.

  24. sandyman says:

    I using UBUNTU 9.10 with a GM-M61PME-S2 (64bit) motherboard with a NVIDIA GeForce 6100/nForce chipset..
    I downloaded NVIDIA driver Version 173 using (Hardware Drivers icon) put in the necessary password etc and my wireless connection works with
    no trouble what so ever.. The wired connection worked straight away without downloading any drivers..
    I hope this helps somebody, if the above do not make
    sense I am sorry but I am a newby to linux..

  25. Sister Sue says:

    I have UBuntu 8.04 on acer emachines. How do I configure for wireless e-mail?

  26. Ruudspark says:

    Every now and then I have a dabble with Ubuntu, in the hope that it has evolved into a user-friendly, workable system.

    I installed it from within Windows XP with no problems, and like the look and feel of the GUI. Trouble is, can’t get the wireless to work on my HP6735s laptop.

    I been building and configuring pc’s since MS-DOS 5 era and consider myself quite competant. However after some time trawling the web looking for solutions, decided (much like ‘Werdermouth’ in the above post) just cant be bothered.

    If this is to be a serious alternative, basic requirements like internet connectivity must be made much simpler. A good deal of people find MS Windows family operating systems daunting, so they don’t have a prayer with Ubuntu.

    That said keep up the good work, as it is a nice interface and once made more user friendly, I would gladly use it.

    See you in a few months!

  27. swetha says:

    my wired network worked straight away but wireless is not detected.it is showing no network connection

  28. bill says:

    No DHCPOFFERS received.
    No working leases in persistent database – sleeping.
    what can i do now?

  29. Zed Zee says:

    I’m getting the same problem as “bill”:

    “No DHCPOFFERS received.
    No working leases in persistent database – sleeping.”

    This is after carrying out the instructions in the Unencrypted Connection section.

    I have a Dell Inspiron 6000 with Ubuntu 9.10 with the latest updates, through Update Manager.

    I just bought a brand new NetGear WNR2000 wireless router and I’ve not really made many changes to the config – my Windows XP ThinkPad picked it up like a shiny coin on the ground that you can’t miss – Ubuntu didn’t.

    I’m also at the point of giving up on Linux and going back to Windows XP.

  30. EC White says:

    I just installed lucid lynks on our spare Compaq Presario V5102NR laptop. How can I get it to recognize the wireless card? This is ridiculous having to boot up in Windows then restart, boot into Ubuntu to get the wireless card turned on. Any ideas or locations where I can find how to do this. Help

Leave a Reply

Your email address will not be published. Required fields are marked *