HOME
FORUM
LINKS
CHAPTER INDEX
 

    I've tried everything, but my WiFi Connection refuses to work


    The situation is this: You have tried out the GUI menus available to you by your standard distribution (eg, Fedora, Ubuntu, SuSE) and you've also had a look around on the forum here and maybe elsewhere as well but your Wireless Internet connection refuses to work.

    This method is non distribution specific and as long as you can get your drivers to work, the rest of the guide should get you going nicely, note however it's non-standard, and as a result, your distribution may choose to delete or disable this configuration at a later date, especially after an update!
    First things first, make sure that your hardware works. In any Linux PC I have ever used with wireless, I have always done one thing:
    Gone with what I know works.
    This means that a lot of the new fancy 802.11g and 802.11ng and MIMO stuff is probably not your best bet for compatability. If you know 100% that the hardware you have definitely works not only with Linux, but with your distribution, then go ahead, but my advice is go with one of two card types:

      Cisco Aironet 3xx series (340/350)
      Orinoco / Prism 2 / Intersil Chipset-based cards

    These cards are 802.11b cards, they are old (they started coming out around 2002) and are probably only available on places like Ebay. Both PCI and PC Card (PCMCIA) versions should work fine for PCs or Laptops alike.
    Because the cards are 802.11b, this limits their speed to a maximum of 11mbps. Fine for most people's broadband internet needs today (most people have a max of around 8mbps at time of writing), but not great for transferring files on your home network at speed.
    For a more complete look at which wireless adapters work with linux, check out Jean Tourrilhes page on Linux and Wireless LANs.
    If you have been lucky and gotten yourself an old-trusty wireless card then you should be able to pop it into your PC and notice it working. Here is a possible (but not definitive) way to check whether Linux has loaded a driver module for your wireless card or not:

      1. Turn on your PC without wifi card being installed.
      2. At Linux prompt, type lsmod > ~/before.txt
      3. Shutdown the system.
      4. Insert your wireless card.
      5. When the system starts, again at the prompt, type:
          lsmod > ~/after.txt
      6. Now compare the two files:
          cd ~
      diff after.txt before.txt

    The output I got on a laptop with an LG branded Orinoco-based chipset wireless card was as follows:

      35,39c35,36
      < orinoco_cs 8872 1
      < orinoco 39756 1 orinoco_cs
      < hermes 7264 2 orinoco_cs,orinoco
      < pcmcia 26568 5 orinoco_cs
      < yenta_socket 25292 3
      ---
      > pcmcia 26568 4
      > yenta_socket 25292 2
      41c38
      < pcmcia_core 49348 4 orinoco_cs,pcmcia,yenta_socket,rsrc_nonstatic
      ---
      > pcmcia_core 49348 3 pcmcia,yenta_socket,rsrc_nonstatic
      67c64

    Yes, I appreciate that it looks like a load of rubbish, but what it shows is that there was a difference between the two files, and all that should have changed is the fact that the Wireless card was present in the system. In the above example, it shows that the wireless card is being loaded with the driver 'orinoco_cs'. It was all automatic. If you have the same luck, that's half the battle done with - the driver loads, you can get on with the next stage!

    If you didn't fare this well, and generally there was no difference between the files above then no driver was found for your card. All may not be lost, but a bit of good hard googling is in order I'm afraid, and possibly -eek- building a new kernel. To start with, google for the exact version of your card (this is very important), along with the word 'linux' and see how you get on from there!

    If you are running a modern version of Linux, anything from say, 2004 onwards should come pre-installed with the basic set of wifi-tools. These are basic command-line tools which we will use because they are included with every distribution of Linux, whereas GUI apps are often different between distros.
    The main tools we are using are:
      iwconfig
      ifconfig
      dhclient
      route
      a text editor (to edit a few things)
    Please ensure that you have these programs installed before we go forward. How do I check where these programs are? Try typing simply iwconfig at the prompt - you are likely to be presented with a screen of information about your wireless card. If not, try /sbin/iwconfig (redhat/fedora put iw/ifconfig in /sbin). Still no joy - try typing locate iwconfig or which ifconfig. If still no luck, then you will need to install it from your distro's CD or website.

    You should be doing all of the following as the root user from now on. To becomeroot, this depends upon your distro:
      RedHat / Fedora / Suse / Mandriva:
      $su - root
      Password: [root password]
      #

      Ubuntu and some others:
      $sudo bash
      Password [root password]
      #

    Now that you are root, lets see what we get from iwconfig. Here's what my configuration shows:
      eth0 No Wireless Extensions

      eth1 IEEE 802.11-DS ESSID:"oddjob" Nickname:"Prism I"
      Mode:Managed Frequency:2.442 GHz Access Point: 00:0D:0B:4A:9B:5F
      Bit Rate:11 Mb/s Tx-Power=15 dBm Sensitivity:1/3
      Retry min limit:8 RTS thr:off Fragment thr:off
      Power Management:off
      Link Quality=53/92 Signal level=-49 dBm Noise level=-139 dBm
      Rx invalid nwid:0 Rx invalid crypt:3507 Rx invalid frag:0
      Tx excessive retries:2588 Invalid misc:0 Missed beacon:0

    The above output may differ to your setup, but here, it shows that the interface eth1 is my wireless card. It shows that it's currently associated to Wireless Access Point called 'oddjob'. This may or may not be correct, check the name of your wireless point in the configuration for your wireless router/access point to confirm that the card hasn't picked the wrong name.

    If you are happy that the AP selected by the card is good, then let's manually set up the card (just once), so that we know we've got it all right. If you want more information about iwconfig, type iwconfig --help, but here is the basic stuff you want to use to configure your card:

      ifconfig eth1 up
      (sets up the actual interface for use)

      iwconfig eth1 essid oddjob
      (This sets the card to use the AP name oddjob, may not be necessary)

      iwconfig eth1 mode managed
      (This tells the card that you have an Access Point/Wifi router, rather than a peer-to-peer setup, again, may not be necessary)

      iwconfig eth1 enc on
      (If you use WEP then you want to switch WEP on with this command)

      iwconfig eth1 enc FE:ED:DE:AD:BE:EF:A7:DA:CA:FE:FE:ED:00
      (This command sets the wireless encryption code you have set on your router)
      (note that this is a hex based number - rather than ascii text string, because it's easier to use hex numbers, eg 0-F rather than text. If you use text strings on your router, consider using just one hex line instead if you run into bothers with your setup.)

      dhclient eth1
      (This line uses DHCP from your router to give your PC an IP address and a way
      out to the Internet)
      (If your router doesn't provide DHCP, or you use static IP addresses, then
      you will need to do as follows to set your IP etc:)

        ipconfig eth1 [the IP you use] netmask [eg 255.255.255.0]
        route add default gw [IP address of internet router or default gateway]
        echo "nameserver [IP address of DNS server, eg routers IP]" > /etc/resolv.conf

    As you can see, the whole process is a lot easier when you have DHCP enabled on your router/AP, so unless you have a good reason not to, enable DHCP on your router so that all the DNS, Routing and IP information is automatically configured on the card.
    To see whether your configuration worked, try doing ping google.com. If it worked you'll see something like:

      64 bytes from 64.233.167.99: icmp_seq=1 ttl=240 time=244 ms

    Press Ctrl+C to stop the ping.

    If you are happy with the results, then you have correctly configured your card.If you are still having problems, make sure that a few things are set:

    • The Card interface is up (eg ifconfig CARD up)
    • If you don't use DHCP that your /etc/resolv.conf (dns) file is valid
    • Check the output of the route command again if you don't use DHCP, check its right
    • Check the IP address of your card is right by typing simply 'ifconfig' on it's own - most routers use 192.168.x.x

    If things are all good, take your settings and put them into a text file with a text editor like so...

      #!/bin/bash

      echo "Starting wireless network..."
      ifconfig eth1 up
      iwconfig eth1 essid oddjob
      iwconfig eth1 mode managed
      iwconfig eth1 enc on
      iwconfig eth1 enc FE:ED:DE:AD:BE:EF:A7:DA:CA:FE:FE:ED:00
      dhclient eth1

    Save the file in /etc/init.d, call it wifi-start or something like that.
    Give it permission to execute:

      chmod 755 /etc/init.d/wifi-start

    Make a link to the file in your init startup folder:

      ln -s /etc/init.d/wifi-start /etc/rc2.d/S36wifi-start
      ln -s /etc/init.d/wifi-start /etc/rc3.d/S36wifi-start

    S36 is the order it starts up. If you look in your rcX.d folders you'll see other services starting with different numbers. If you have a problem with the order in which the wifi-start script starts, eg, you want pcmcia-cs to start up first (it should do on laptops), then change the S36 to SXX where XX is a number greater than the one for pcmcia-cs etc.

    If you restart your machine then the wireless settings in that script should start up with your machine. If it doesn't, check the runlevel of your machine which you can find from /etc/inittab. My Ubuntu machine shows the following:

      id:2:initdefault:

    Meaning that /etc/rc2.d is the startup directory for Ubuntu. This is different for other distros. Make sure that the script is linked into the folder for whichever default your distro uses.

    If you have problems doing this, the easiest thing to do is place the file in /etc/init.d and give it permission (chmod) to run, and then the KDE System Settings window > System Administration Menu > System Services menu can be put to use. Make sure you click 'Start during boot' for start-wifi.

    If you have any comments, fixes or updates for this Hot Topic then Contact Us!


    This Hot Topic was last tested on: Ubuntu 4.06