Network profiles with Debian Sid

This section explains how to configure networking in a very pleasant way, so that it works automatically wherever you go. This solution has been inspired by a tutorial that can be found in the references section at the bottom of this page. It uses three tools that integrate well with the debian network configuration:

First, some installation :

# aptitude install wpasupplicant ifplugd guessnet resolvconf

The next steps consist mostly in editing a bunch of files. To configure all this, my advice is to turn networking off :

# ifdown eth0
# ifdown eth1
# /etc/init.d/ifplugd stop

Physical layer

/etc/wpa_supplicant.conf :

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0

eapol_version=1
ap_scan=1
fast_reauth=1

network={
    ssid="your_case_sensitive_ssid"
      id_str="home"
    psk="your_passphrase"

    priority=5
}

# Connect to any public open access point
network={
    ssid=""
    key_mgmt=NONE
    priority=0
}

The id_str configuration parameter is used to know which configuration to use in /etc/network/interfaces (see next paragraph). Networks that do not have this parameter use the default configuration.

You may add any number of networks to fit your needs.

Transport, network and application layers

/etc/network/interfaces is the central repository of the network configuration in Debian.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The wireless interface
auto eth1
iface eth1 inet manual
      wpa-driver wext
      wpa-roam /etc/wpa_supplicant.conf

# The Ethernet is mapped depending on the environment
mapping eth0
    script guessnet-ifupdown
    map default: default
    map timeout: 3
    map verbose: true

iface home inet static
    address 192.168.51.6
    netmask 255.255.255.224
    broadcast 192.168.51.31
    gateway 192.168.51.1
    dns-search subdomain.org
    dns-nameservers 192.168.1.2
    test peer address 192.168.51.1 mac 00:01:23:45:67:89
    up /etc/init.d/samba start
    down /etc/init.d/samba stop

# This interface is to catch unidentified Wireless networks
# and is of course the default map for eth0
iface default inet dhcp

The choice of the wext driver depends on your Wireless adapter. Mine is an ipw2200 and uses the Linux Wireless extensions, thus I use wext.

This basically tells eth0 or eth1 to be configured differently whether a host with address 192.168.51.1 and mac 00:01:23:45:67:89 is found or not. If it is there, take a static ip address and start samba. If not, revert to dhcp.

A little tip for the samba example : for samba not to start while booting, just run :

# update-rc.d samba stop 0 1 2 3 4 5 6 .

Ensure your have the desired ip address :

# ifup eth1
# ifconfig

This setup works well for me.

FIXME There should be a priority to the Ethernet interface, et the wireless interface should go down while a network wable is plugged in. A debian bug has been filled on the subject. Here are possible solutions :

For now, before I plug to a wired network, I just use the kill switch feature of my laptop to turn wireless off.

References