Managing Network Connections in Debian

*PLEASE READ THIS WHOLE PAGE BEFORE PROCEEDING*

Debian comes with a ton of device support for wired network connections and 99% of the time, your wired networking hardware will be automatically configured and ready to use. To connect manually via the ethernet connection type:

ifconfig eth0 up && dhclient eth0

Assuming eth0 is the name assigned to your ethernet hardware by Debian. This is the case in 99% of installs, but sometimes if you have wifi hardware on board you may find that the wifi connection is called 'eth0' and the wired adaptor becomes 'eth1'.

Setting up Wireless from the Command Line 

Debian 5.0 comes with a LOT of built in support for wireless devices, no longer comes with network-manager-gnome by default and it needs a bit of config to connect to a repo depending on your hardware and wireless network configuration.

First you may need to copy the firmware for your device (in my case rt73usb wlan stick) into /lib/firmware, then modprobe [module name] in my case it is:

cp rt73.bin /lib/firmware && modprobe rt73usb

This however is only the case with certain types of wifi hardware. The atheros 9000 series merely requires the use to type 'modprobe ath9k' as root user and it will work. You will need to do some research into what type of hardware you have as to what you need to do to get it working.

WEP

You must install the wireless_tools package. Then type

ifconfig wlan0 up

iwconfig wlan0 essid "your essid" key [restricted (- optional)] [WEP key]

dhclient wlan0

The display will spit out some info about the hardware and connection attempt intervals.

When the connection is successfulyou'll get a message telling you your local IP address and how many seconds before the network refreshes

WPA & WPA2

You must have the wireless_tools & wpasupplicant packages installed to access WPA & WPA2 protected networks. Also you need to give the computer your password to allow it to access your networks security key.

Type wpa_passphrase [ssid] [passphrase] into the command line and look at the output, then hit the up-arrow to duplicate your input and add the following to the line: > /etc/wpa_supplicant.conf so it looks something like this

wpa_passphrase myssid mypassphrase > /etc/wpa_supplicant.conf

This line puts the output of the first part into a text file located at /etc/wpa_supplicant.conf. Next type this horrendous concoction

ifconfig wlan0 up

iwconfig wlan0 essid  "your_essid"

wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf

dhclient wlan0

and you should get a message saying you are connected and your computers local IP as with the example using WEP.

At this point I recommend you install network-manager-gnome if you can as it handles all wireless connections with a very nice graphic interface. Otherwise you can put the second bunch of commands in a script and connect to your WLAN via the command line. I have found this technique useful to stop unwanted internet connections.

Another way to connect to your network automatically on startup is to edit the /etc/network/interfaces file to include the following lines:

auto wlan0

iface wlan0 inet dhcp

wpa-ssid [your network name]

wpa-psk [your network password/key]

The ifup and ifdown commands can be used to manually manipulate connections from the command line if your device fails to connect on startup. This can sometimes occur with some of the cheaper USB wifi devices.
 For e.g. type "ifup wlan0" to get your wifi device to connect and "ifdown wlan0" to disconnect. If you get "device already configured" message, just type "ifdown wlan0 && ifup wlan0" (the && carries out the two commands consecutively)

This method can also be used to manage a wired connection as well, and is very useful if you have more than one active network device as is often the case with a server.

Managing your network connection from the desktop.

As well as the network-manager-gnome package for managing network connections, the wicd package is available for Lenny users from http://www.backports.org. Check the previous page on backports, add backports to your repository and type the following to get wicd:

apt-get install -t lenny-backports wicd wicd-curses

Then make sure that wicd-client is set to run when starting your desktop environment. This will depend on what DE you have but it is a simple matter to find the startup settings in GNOME, KDE and XFCE. In fact, wicd-client may start *automatically* in some DE's, but don't quote me on that, just try and see. If you are using a window-manager like openbox or fluxbox, add the line

wicd-client&

to the relevant startup file.
Wicd has a fairly simple GUI as it is basically a graphical front-end for the command-line wifi tools that were mentioned earlier.

the wicd-curses package allows you to manage your network connection via CLI. Type wicd-curses into a terminal window and you will see what I mean. All the configuration options are shown so if you like your omputing on the spartan side, there is no need to enter a desktop-environment or window manager at all. This has several advantages that are apparent to the more advanced user ;o)

network-manager-gnome is another package that is available in updated form from backports.org, as the default version in Lenny is a bit out of date (and frankly bug-ridden!)