Issue with which interface my computer connects at boot.
In my office there are three available interfaces. Plus, I go to a coffee shop when on the road.
1. wired 2. My wpa encrypted wireless. 3. The neighbors unencrypted network in the office next door. 4. The coffee shop. The problem .... When I boot my notebook at my office desk, sometimes it connects with the wired connection, or sometimes with my encrypted wireless, and sometimes my neighbor's network. I commented out the part of wpa_supplicant that enables you to connect to insecure networks to prevent connecting to the neighbor's network. However, that also disables connections at the coffee shop. My question.... I want to be able to connect according to order of priority. First wired (fastest), second my encrypted wireless when I am away from the desk. And third is the coffee shop. And of course, I do not want to connect to the other office. How do I configure for that order of priority? Here is my current setup: Madwifi, atheros chipset. netgear wg511t rc.inet1.conf Code:
# Config information for eth0: # WPA protected network, supply your own ESSID and WPAPSK here: network={ proto=WPA key_mgmt=WPA-PSK ssid="*****" psk=******************************************************* } # Plaintext connection (no WPA, no IEEE 802.1X), # nice for hotel/airport types of WiFi network. #network={ # key_mgmt=NONE # priority=0 #} |
I can't comment on how to manage the wired network (I use Debian's 'ifplugd' tool). Of course you can take the source code and hack it to suit you - check wired, then start up wireless.
For the wireless, all you have to do to set the priority is to put networks into the order you want to check in your wpa_supplicant.conf file (or whatever file is used by your installation of wpa_supplicant); to distinguish between open networks that you know and generic open networks, just add stanzas for each open network you know - the ESSID (and the order in the conf file) will be used to distinguish them. The stanza for a generic open network does not specify the ESSID to match. |
When watching the words scroll at boot, I noticed that the eth0 interface is read first probably according to rc.inet1.conf. Then the ath0 interface. I hope there is a way that after the first interface is connected there would be no further searching for a connection.
In addition, as I previously stated, when I uncommented the stanza that gives the ability to connect to any open network, at times I would be connected to my encrypted network and sometimes to the neighbors. As you stated, you are probably correct that the wpa_supplicant.conf is also read in order from top to bottom. However, though there is a connection with my encrypted network which is first in line, at times I still get connected to the neighbors unencrypted. Is there a way that once dhcp obtains an ip address the search for additional connections stops? |
Quote:
For example, let the network script start with a test to see if you're already connected - you can do this by checking /etc/resolv.conf and also checking the default routing - if you're connected, then exit. For your wired bit, you have to set that up so that a failed dhcp negotiation shuts down that interface. I don't know wpa_supplicant that well; I have never read through the source code. One possible method (which does not use a wpa_supplicant.conf at all) is to write a script which goes through and attempts to connect to your known networks or to generic open networks. To do this you can first call 'iwlist ath0 scan' , process the output to recover a list of nets, delete known open nets which you don't want to connect to (such as the office next door), check the list of nets in the order of ESSIDs you're interested in (if I have "home_net", connect to that, if not check for "work_net", etc) and finally, decide what you want to do with your list of generic open nets. |
There is the /etc/rc.d/rc.inet1 script but I have not learned how to write bash scripts yet. Does anyone know how to edit the script so that once a dhcp address is obtained, do nothing more.
Code:
####################### |
rc.inet1 is apparently meant to be included in another file (via . /etc/rc.d/rc.inet1)
The functions in there would actually be called from another script. However, if you look at the if_up() function, you can ensure that the interface is brought down if the dhcp negotiation fails (often a timeout because there's no wire; sometimes there just isn't a dhcp server). If you can find the script which includes rc.inet1 you may be able to make some modifications (just keep another copy of your mods somewhere because an upgrade can replace the script). I don't know how to tell if a wire is plugged into an ethernet port though; maybe I should get the Debian 'ifplugd' source and have a peek. One extremely annoying thing is the long wait for the DHCP request timeout when there isn't even a cable plugged in. |
The above code is from part of the /etc/rc.d/rc.inet1 script.
I posted what I thought was important and left the rest out for brevity. At this point I have no clue how to edit the file to meet my needs. I am sure that I am not the only one with this issue. I thought maybe someone else has already solved the issue. Therefore, I was hoping some already has the know how on correctly editing the script. okos |
All times are GMT -5. The time now is 09:42 PM. |