# The correct way to manage wireless networking profiles

## optilude

Hello,

I have a feeling this has been asked before, but I couldn't find any relevant posts, so here we go:

I have an internal wireless card in my laptop. To configure this I first have to load a kernel module (e.g. in /etc/modules.autoload.d/kernel-2.6), and then run /etc/init.d/net.eth1 start to get it to pick up an IP address via DHCP. Depending on which hotspot I'm in, I may also have to issue some iwconfig commands to set things like ESSID name and WEP key. Now, doing this all manually as root is not exactly hard, but it's not exactly elegant either.

In Windows, I can define profiles with all these settings and apply them in one fell swoop. Furthermore, it can automagically scan for access points and pick an appropriate profile.

My fingers are itching to start writing some scripts to handle this, but surely it must've been done already? How do other people handle their wireless configuration at boot?

Martin

----------

## Gorth

Right now, I have several options in /etc/conf.d/net for wepkey, essid, and the like.  Some mods (not pretty, but they work) to /etc/init.d/net.eth1, and it reads the settings and does the iwconfig for me.

I still have to do the commenting and uncommenting of the lines I wish to use, but oh well....

----------

## hulk2nd

have a look at /etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. you can also emerge quickswitch. i've heard it is really powerful but never tried it out.

greets,

hulk

----------

## optilude

 *hulk2nd wrote:*   

> have a look at /etc/pcmcia/network.opts and /etc/pcmcia/wireless.opts. 
> 
> 

 

My wireless card is not PCMCIA; does it matter?

 *Quote:*   

> 
> 
> you can also emerge quickswitch. i've heard it is really powerful but never tried it out.
> 
> 

 

I seem to remember looking at this and thinking it was less powerful than my hprofile system (search forums), but I'll have another look.

----------

## hulk2nd

at least in my case it does not matter. i have minipci.

----------

## optilude

 *hulk2nd wrote:*   

> at least in my case it does not matter. i have minipci.

 

Me too. Could you tell me how you have it all configured? I think your config should be pretty similar to mine (I've got the Intel Centrino wifi chip, running through linuxant's driverloader), but at any rate, I'm quite confused by all of /etc/pcmcia and how to use it.

Also - I've just discovered something: /etc/init.d/net.eth1 is auto-started whenever I load the module for my wifi card (modprobe driverloader). I think this is because I have "alias eth1 driverloader" in modules.conf (via /etc/modules.d/driverloader). Can I prevent this from happening? It's causing trouble because the silly driverloader module needs about 3 seconds of time to itself before it will accept any configuration; if the configuration happens before this window is up, any configuration is applied in theory but not in practice, so iwconfig refuses to set the WEP key again, but my router still won't let me connect. Annoying!

Martin

----------

## dopey

This is happening due to hotplug support.  The 2.4 and greater kernels all support hotplugging.  When a device is registered, /sbin/hotplug is run.

i havea Mini-PCI card (Xterasys XG-600, prism54.org drivers) and the problem I have is with hotplugging.  The initial module load is launching /etc/init/d/net.eth0 start before the device is fully configured.  Unfortunately, what happens then is that my dhcpcd session will eventually time out because it starts querying before the device is fully ready.  If I manually run net.eth0 start after the fact it seems to work.  I'm going to toy with disabling hotplug to see what happens.

I also modified net.eth0 to grab wepkey_eth0 from /etc/conf.d/net and use iwconfig to set it.

 *optilude wrote:*   

> 
> 
> Also - I've just discovered something: /etc/init.d/net.eth1 is auto-started whenever I load the module for my wifi card (modprobe driverloader). I think this is because I have "alias eth1 driverloader" in modules.conf (via /etc/modules.d/driverloader). Can I prevent this from happening? It's causing trouble because the silly driverloader module needs about 3 seconds of time to itself before it will accept any configuration; if the configuration happens before this window is up, any configuration is applied in theory but not in practice, so iwconfig refuses to set the WEP key again, but my router still won't let me connect. Annoying!
> 
> Martin

 

----------

## optilude

 *dopey wrote:*   

> This is happening due to hotplug support.  The 2.4 and greater kernels all support hotplugging.  When a device is registered, /sbin/hotplug is run.

 

Perhaps there is some way to tell hotplug to lay off ethX?

 *Quote:*   

> 
> 
> i havea Mini-PCI card (Xterasys XG-600, prism54.org drivers) and the problem I have is with hotplugging.  The initial module load is launching /etc/init/d/net.eth0 start before the device is fully configured.  Unfortunately, what happens then is that my dhcpcd session will eventually time out because it starts querying before the device is fully ready.  If I manually run net.eth0 start after the fact it seems to work.  I'm going to toy with disabling hotplug to see what happens.
> 
> 

 

Exactly what I have, although with Driverloader 1.54, the device configures itself fast enough.

 *Quote:*   

> 
> 
> I also modified net.eth0 to grab wepkey_eth0 from /etc/conf.d/net and use iwconfig to set it.
> 
> 

 

I had done something similar, too.. I wish a standard mechanism would make it into baselayout.

In the meantime, I upgraded my hprofile script to handle this sort of thing. Hprofile is now on http://hprofile.sourceforge.net. The tarball there comes with a sample "net" profile which covers a setup that sounds quite similar to yours. I'd suggest you have a look at it. I've submitted an ebuild for hprofile to bugzilla, so hopefully we'll see it in portage before too long. In the meantime, the bug is here

----------

## dopey

 *optilude wrote:*   

> 
> 
> Perhaps there is some way to tell hotplug to lay off ethX?
> 
> 

 

I haven't figured out a way short of disabling it for all networking, or modifying the hotplug scripts to not call net.ethX start for this specific case.  

Unfortunately, I figured out that I can't disable hotplugging.  Apparently the prism54 drivers rely on hotplug to load the firmware.  Now why it would run the network agent first, before the firmware agent bugs me.  If it was the other way around this should work fine.

I'm taking a look at hprofile.  Looks promising.

----------

## optilude

I had a look last night... I think /etc/init.d/net.ethX is being started from /etc/hotplug/net.agent. I'm going to investigate hotplug more over the next few days (can think of a few cool things to do with it), and then we'll see.

Martin

----------

## dopey

check out https://forums.gentoo.org/viewtopic.php?t=120462

I found Faye Pearson's madwifi net.ath0 script, modified it for the prism54 stuff a bit.

She used iwlist to detect the SSid.  It works well for me and puts in delays so that it waits for the wireless card to associate with an AP before continuing.  Things work perfectly on boot up.  At least at home.  It'll be interesting to see how it works at work.

----------

## timfreeman

Seen this thread?  It's another modification of her script.

https://forums.gentoo.org/viewtopic.php?t=122435

----------

