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:

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.