Getting My Wireless Networking Card to Work Using the Command Line

Posted: July 2, 2011 in Notes
Tags: ,

I’ve kept a Ubuntu Server installed on my laptop for almost a year. Only until recently that I have tried to connect the server through the wireless networking card. Indeed, I’ve been through some hard times, searching and trying desperately to get the wireless card to work. The server doesn’t have a desktop manager, i.e no GUI, so everything has to be done in the terminal. So here I am to explain the whole process to ease others who would also wish to configure their networks using the command line.

  1. The first step is to check that you have the appropriate tools installed. In the command line, type in the following.
    sudo apt-get install wireless-tools

    This will install the Wireless Tool package containing the following tools:

  2. Next find out the chipset of your wireless card. To do this, type in
    lspci | grep Network


    lsusb | grep Network

    depending on whether you use a pci or usb card. The output will be like

    02:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g (rev 01)
  3. Now you know your chipset. Some wireless chipsets work out of the box. In my case, it’s a Broadcom chipset and it’s not supported by default. For this step try google for the appropriate drivers, or you may use ndiswrapper if your Wifi card comes with a Windows driver.
  4. After installing the driver, make sure the card can be detected.

    The command will list your wireless card. For example:

    lo        no wireless extensions.
    eth0      no wireless extensions.
    eth1      unassociated  ESSID:off/any
              Mode:Managed  Channel=0  Access Point: 00:00:00:00:00:00
              Bit Rate=0 kb/s   Tx-Power:off
              Retry:on   RTS thr:off   Fragment thr:off
              Power Management:off
              Link Quality:0  Signal level:0  Noise level:0
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:0  Invalid misc:0   Missed beacon:0
    virbr0    no wireless extensions.
    pan0      no wireless extensions.

    Sometimes, the wireless card is disabled so you get “no wireless extensions” for every device.
    You can activate your card by typing

    sudo ifconfig eth1 up

    Then re-execute iwconfig to make sure it is okay.

  5. Issue the following command to scan for wireless network.
    sudo iwlist eth1 scan

    and the output:

    eth1      Scan completed :
              Cell 01 - Address: 00:22:6B:6A:3E:85
                        Frequency:2.437 GHz (Channel 6)
                        Quality:5/5  Signal level:-50 dBm  Noise level:-90 dBm
                        Encryption key:off
                        Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                                  24 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 9 Mb/s
                                  12 Mb/s; 48 Mb/s
  6. Connect to the access point of your own choice. The ESSID is the identification name given to an access point. Identify the ESSID you wish to connect.
    sudo iwconfig eth1 essid "FKMWifi"
    sudo iwconfig eth1 mode managed
    sudo iwconfig eth1 commit
  7. For WEP or WPA encrypted network, you need to input the key. For WEP encrypted networks, the following two commands applies. Use the first command if you have an ASCII key and it will translate the key to its hexadecimal form.
    sudo iwconfig eth1 key s:password
    sudo iwconfig eth1 key 70617373776f7264

    For WPA encrypted network, you have to generate the WPA-PSK key using the essid and your password.

    wpa_passphrase <your_essid> <your_ascii_key>

    And the output will be something like


    Notice the last line of hex gibberish. Use that as your WPA-PSK key and issue the command

    sudo iwconfig eth1 key b51f838d5e7ea198d2dc141350687f6ea7b1995215c9b40b302dc6ca96c94537
  8. Obtain an IP address from the DHCP server by issuing the command
    sudo dhclient eth1

    The output similar to the below will be printed.

    Listening on LPF/eth1/00:21:00:b7:db:2d
    Sending on   LPF/eth1/00:21:00:b7:db:2d
    Sending on   Socket/fallback
    DHCPREQUEST of on eth1 to port 67
    DHCPACK of from
    bound to -- renewal in 240 seconds.
  9. Ping an publicly known address to check that everything works.
  10. Additionally, you might want to save the hassle by configuring your network to connect automatically once your computer starts. Modify /etc/network/interfaces by adding the following lines.
    sudo vim /etc/network/interfaces

    For WEP encrypted network:

    auto wlan0
    iface wlan0 inet dhcp
    wireless-essid   <your_essid>
    wireless-key     <your_password>

    For WPA encrypted network:

    auto wlan0
    iface wlan0 inet dhcp
    wpa-ssid <your_essid>
    wpa-psk <your_wpa_psk_key>

Other resources:
WifiDocs – Ubuntu Official Documentation
Configuring encrypted wireless network


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s