Connecting to a wireless network [duplicate]

I have a machine that I just installed Ubuntu Server on. The only problem is that I do not know how to connect it to a wireless network, and I cannot use a network cable to connect it to my router.

When trying to list the network cards, only the loopback interface showed up:

$ ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric 1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

which was unexpected, as both my Ethernet network interface (eth0) and wireless network interface (wlan0) showed up when doing the same in a fresh installation of Ubuntu Desktop 10.10.

So, my two questions are:

  • how can I install the wireless drivers (and packages I could download etc.) and/or set up the wireless network interface to work properly, and
  • how can I connect to a WPA-encrypted wireless network from the command line?

EDIT:

I ended up uninstalling Ubuntu Server and installing Ubuntu Desktop instead, then configuring the wireless network through the GUI and making it boot into command line instead of GNOME.


If you don't have wireless drivers, then you will have to figure out a way to get those first, because you obviously will not be able to use your wireless card to get those ;) you can look them up on another computer and install the binaries. More than likely, though, you do already have drivers, but you need to edit your /etc/network/interfaces (as root), which contains interface declarations. It should register your cards once you add the following lines to it:

auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp

This will should make ubuntu recognize the cards once you hit /etc/init.d/networking restart and ifup -a.

Once you have the wireless card up, you can type iwlist scan to list wireless networks in range. I have only dealt with open and WEP-secured networks, and it works perfectly for those. For those networks, you can use

iwconfig wlan0 essid "network-name" ap any key <wep-key>

I know WPA is possible, but it's a lot more configuration than just using iwconfig.


Take a look at this guide for connecting to the network: http://ubuntuforums.org/showthread.php?t=571188