Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Background:

I use Debian Lenny and have two WiFi interfaces. I use a generic configurations on /etc/network/interfaces

iface wlan0 inet static
        address 10.0.0.1
        network 10.0.0.0
        netmask 255.255.255.0
        broadcast 10.0.0.255

auto wlan1
iface wlan1 inet static
        address 192.168.5.1
        network 192.168.5.1
        netmask 255.255.255.0
        broadcast 192.168.0.25

So it has no sign about the wpa_supplicant.

I use wpa_supplicant (v2.0) manually to connect them to a WLAN via /etc/wpa_supplicant.conf (for wlan0) and /etc/wpa_supplicant2.conf (for wlan1).

Problem:

While the wifi interfaces are connected to WLANs, I do

ip link set wlan0 down
ip link set wlan1 up
rm /var/run/wpa_supplicant/wlan0
rm /var/run/wpa_supplicant/wlan1

Then I do ip link set wlan0 (and 1) up. In that case, the iwconfig shows that the wifi interfaces are not connected to any network.

After that, I run /etc/init.d/networking restart. When the process is completed, iwconfig shows that the wifi interfaces are connected to the WLANs that they were previously connected.

Question:

How come /etc/init.d/networking restart cause wpa_supplicant to be run by using the .config file for the interface that were used before (wpa_suppliant.conf for wlan0 and wpa_supplicant2.conf for wlan1)? I repeated this procedure many times and each time the wifi interfaces are connected to the same network that are defined on the .config files.

What I have done:

1) I suspected that /etc/init.d/networking script uses wpa_supplicant somehow. Therefore, I took a look at the script:

     #!/bin/sh -e
    ### BEGIN INIT INFO
    # Provides:          networking
    # Required-Start:    mountkernfs ifupdown $local_fs
    # Required-Stop:     ifupdown $local_fs
    # Default-Start:     S
    # Default-Stop:      0 6
    # Short-Description: Raise network interfaces.
    ### END INIT INFO
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"

[ -x /sbin/ifup ] || exit 0

. /lib/lsb/init-functions

process_options() {
    [ -e /etc/network/options ] || return 0
    log_warning_msg "/etc/network/options still exists and it will be IGNORED! R
ead README.Debian of netbase."
}

check_network_file_systems() {
    [ -e /proc/mounts ] || return 0

    exec 9<&0 < /proc/mounts
    while read DEV MTPT FSTYPE REST; do
        case $DEV in
        /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
            log_warning_msg "not deconfiguring network interfaces: network devic
es still mounted."
            exit 0
            ;;
        esac
        case $FSTYPE in
        nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse
.curlftpfs)
            log_warning_msg "not deconfiguring network interfaces: network file 
systems still mounted."
            exit 0
            ;;
        esac
    done
    exec 0<&9 9<&-
}

case "$1" in
start)

        process_options

        log_action_begin_msg "Configuring network interfaces"
        if ifup -a; then
            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;

stop)
        check_network_file_systems

        log_action_begin_msg "Deconfiguring network interfaces"
        if ifdown -a --exclude=lo; then
            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;

force-reload|restart)
        process_options

        log_action_begin_msg "Reconfiguring network interfaces"
        ifdown -a --exclude=lo || true
        if ifup -a --exclude=lo; then
            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;

*)
        echo "Usage: /etc/init.d/networking {start|stop|restart|force-reload}"
        exit 1
        ;;
esac

exit 0

ifupdown is a script that kills the wpa_supplicant before ifdown is executed (as that script explains so). I don't know shell or bash programming, but as I understood, restart only does ifdown and ifup the interfaces.

2) Read the ifup's man page which says:

The ifup and ifdown commands may be used to configure (or,respectively, deconfigure) network interfaces based on interface definitions in the file /etc/network/interfaces.

my /etc/network/interfaces does not include any configuration about the wpa_supplicant.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.