# Wireless Networking @ Startup ( Yes I've read others )

## SniperSlap

I have a Linksys 802.11g card.  Working perfectly.  Ndiswrapper finds it, uses it,  modprobes it and dhcpcd can even fetch the card an IP address.

No hassles there.  I have the module loading nice & clean at bootup, so the hardware has been slick & smoothe.

Okay, so now how do I get gentoo to do that automatically at boot?

o - Yes I've emerged the latest baselayout.

o - Yes I've consulted /etc/conf.d/wireless and placed what I feel to be relevant values, I'll troubleshoot that myself.

o - Yes I've checked out the Wiki, the wireless setup document there is useless for non-supplicant setups.

o - Yes I've desperatley searched for other posts on this subject.  To no avail.

Obviously something must exist in /etc/init.d/ akin to "net.wlan0".  The most I've found so far in this direction is to "ln -s net.lo"??  I fail to understand how this will obtain my desired result, and thus am not able to configure it correctly.  

o - How do I invoke the settings in /etc/conf.d/wireless, and better still, BEFORE the system attempts to fetch an IP address for the interface?

o - How do I instruct the interface to obtain a static IP address?

----------

## GeorgeM

 *SniperSlap wrote:*   

> 
> 
> Obviously something must exist in /etc/init.d/ akin to "net.wlan0".  The most I've found so far in this direction is to "ln -s net.lo"??  I fail to understand how this will obtain my desired result, and thus am not able to configure it correctly.  
> 
> o - How do I invoke the settings in /etc/conf.d/wireless, and better still, BEFORE the system attempts to fetch an IP address for the interface?
> ...

 

On mine, I copied /etc/init.d/net.eth0 to /etc/init.d/net.atml0 Atml0 is the name of the interface assigned by the Atmel driver installation. 

Then in /etc/conf.d/net I added the Belkin card:

```
# /etc/conf.d/net:

# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $

# Global config file for net.* rc-scripts

# This is basically the ifconfig argument without the ifconfig $iface

#

#iface_eth0="172.26.181.46 broadcast 192.26.255.255 netmask 255.255.0.0"

#iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"

# For DHCP set iface_eth? to "dhcp"

# For passing options to dhcpcd use dhcpcd_eth?

#

iface_eth0="dhcp"

dhcpcd_eth0="-N"

# The Belkin Wireless Card

iface_atml0="dhcp"

dhcpcd_atml0="-N"

# For setting the default gateway

#

#gateway="eth0/172.26.181.126" 
```

Then I did rc-update add net.atml0 default

I hope this helps

----------

## SniperSlap

This doesn't seem to take into account the fact that I have WEP security in place though.  How do I get /etc/conf.d/net to make use of iwconfig specific commands?

 *GeorgeM wrote:*   

>  *SniperSlap wrote:*   
> 
> Obviously something must exist in /etc/init.d/ akin to "net.wlan0".  The most I've found so far in this direction is to "ln -s net.lo"??  I fail to understand how this will obtain my desired result, and thus am not able to configure it correctly.  
> 
> o - How do I invoke the settings in /etc/conf.d/wireless, and better still, BEFORE the system attempts to fetch an IP address for the interface?
> ...

 

----------

## GeorgeM

/etc/pcmcia/wireless.opts has the command lines you want

From the Atmel README:

 *Quote:*   

> 
> 
> ii) /etc/pcmcia/wireless.opts , /root/.vnetrc and /sbin/iwconfig
> 
> The files wireless.opts (for PCMCIA) and .vnetrc (for USB) are the startup
> ...

 

I don't use WEP so I'd be of no help there.

----------

## warravenfk2001

when i set up my wireless card, WPC54G, i copied my /etc/conf.d/wireless.example to /etc/conf.d/wireless then made the appropriate uncommentations and changes and restarted /etc/init.d/net.wlan0 (the script for my wireless card) everything worked fine. I added in my WEP key and everything. Though i had to use the ASCII version of the key, not the regular text version.

here are the major things i had to edit in /etc/conf.d/wireless

```

# However, using ad-hoc (without scanning for APs) and master mode

# do require the ESSID to be set - do this here

essid_wlan0="your SSID" #uncommented and edited

# Set the mode of the interface (managed, ad-hoc, master or auto)

# The default is auto

# If it's ad-hoc or master you also may need to specify the channel below

mode_wlan0="auto" #uncommented

#Channel can be set (1-14), but defaults to 3 if not set.

#

# The below is taken verbatim from the BSD wavelan documentation found at

# http://www.netbsd.org/Documentation/network/wavelan.html

# There are 14 channels possible; We are told that channels 1-11 are legal for

# North America, channels 1-13 for most of Europe, channels 10-13 for France,

# and only channel 14 for Japan. If in doubt, please refer to the documentation

# that came with your card or access point. Make sure that the channel you

# select is the same channel your access point (or the other card in an ad-hoc

# network) is on. The default for cards sold in North America and most of Europe

# is 3; the default for cards sold in France is 11, and the default for cards

# sold in Japan is 14.

channel_wlan0="1" #uncommented and edited

# Define a WEP key per ESSID or MAC address (of the AP, not your card)

# The encryption type (open or restricted) must match the

# encryption type on the Access Point

# You can't use "any" for an ESSID here

#key_ESSID="1234-1234-1234-1234-1234-1234-56"

# or you can use strings. Passphrase IS NOT supported

# To use a string, prefix it with s:

# Note - this example also sets the encryption method to open

# which is regarded as more secure than restricted

key_your SSID="open xxxxxxxxxxx" #uncommented and edited

#key_ESSID="s:foobar enc restricted"

# If you have whitespace in your key, here's how to set it and use other

# commands like using open encryption.

#key_ESSID="s:'foo bar' enc open"

# WEP key for the AP with MAC address 001122334455

#mac_key_001122334455="s:foobar"

# Here are some more examples of keys as some users find others work

# and some don't where they should all do the same thing

#key_ESSID="open s:foobar"

#key_ESSID="open 1234-5678-9012"

#key_ESSID="s:foobar enc open"

#key_ESSID="1234-5678-9012 enc open"

```

hope this helped  :Smile: 

----------

## SniperSlap

/etc/init.d/net.wlan0 does not exist.

----------

## quatsch

you can simply create /etc/init.d/net.wlan0 by copying net.eth0. Then you can edit it whatever way you like.

If you know how to start up the thing manually, one thing to consider is to edit

/etc/conf.d/local.start 

This is a script that gets run after all other services are started. You could simply add whatever you do manually to this script and it will be done at boot time.

----------

## UberLord

 *quatsch wrote:*   

> you can simply create /etc/init.d/net.wlan0 by copying net.eth0. Then you can edit it whatever way you like.
> 
> 

 

That's bad advice my friend.

If you take a copy, it never gets updated when we ship newer versions of baselayout.

Better to create a symbolic link to net.eth0 (<=baselayout-1.9.x) or net.lo (>baselayout-1.11.x)

----------

## DRSON

I agree. That's the bad way to do things.

Try this:

cd /etc/init.d

ln -s net.lo net.wlan0

then make your /etc/conf.d/wireless

here is a example of mine:

```
mode_wlan0="managed"

key_Home_Closed="1234-5678-90"

config_Home_Closed=("dhcp")

dhcpcd_Home_Closed="-t 5"

preferred_aps=( "Home-Closed" )

associate_order="forcepreferredonly"
```

I use this for my ntb at home. Settings are for certain ESSID, so you can have several configurations for different networks. I use forcepreferredonly because my card doesn't support scanning (or i can't get it working  :Wink: ) This config is for DHCP, but wireless.examle has detailed description of fixed IP settings, so look there.

Now /etc/init.d/net.wlan0 start should bring your card up and running.

when everything works, just run rc-update add net.wlan0 default and your card will be available at boot time. 

Also consult /etc/conf.d/net and net.example for having multiple NICs on your system and using the one that is available to satisfy net needs for other init scripts (e.g. when your ntb has ethernet and wi-fi and you want to use only one of them, but any of them).

----------

## quatsch

UberLord wrote:

 *Quote:*   

> quatsch wrote:
> 
> you can simply create /etc/init.d/net.wlan0 by copying net.eth0. Then you can edit it whatever way you like.
> 
> That's bad advice my friend. 

 

right. Sorry about this one. in most cases you should symlink it.  

Though what if you want to edit it? There are things in the script that I don't really need since it does thigns like checking the setup which is always the same so long as the machine remains the same. If I make changes, it will get wiped during the next upgrade. If i setup portage to not update it (is it possible?), I might end up with a non-working script in case big changes are made by gentoo. So i just made a copy and cut things out and made some changes (didn't do the gentoo reading so i setup wireless manually without those /etc/conf.d/wireless stuff). It works for now. if it stops working i can revert to the original.

----------

## UberLord

 *quatsch wrote:*   

> 
> 
> Though what if you want to edit it? There are things in the script that I don't really need since it does thigns like checking the setup which is always the same so long as the machine remains the same. If I make changes, it will get wiped during the next upgrade. If i setup portage to not update it (is it possible?), I might end up with a non-working script in case big changes are made by gentoo. So i just made a copy and cut things out and made some changes (didn't do the gentoo reading so i setup wireless manually without those /etc/conf.d/wireless stuff). It works for now. if it stops working i can revert to the original.

 

That is entirely correct. But this is not what most users want as they don't normally go editing init scripts we supply. Plus if there's a serious bug in the script then they will not get the fix, unless they make a new copy and apply their patch again.

But, I must ask why do you need to change it (ie functional requirement)? What changes do you make? Would other users benefit from your patch? Could it be better written as a module (lib/rcscripts/net.modules.d)?

----------

## DRSON

 *quatsch wrote:*   

> 
> 
> Though what if you want to edit it? There are things in the script that I don't really need since it does thigns like checking the setup which is always the same so long as the machine remains the same. If I make changes, it will get wiped during the next upgrade. If i setup portage to not update it (is it possible?), I might end up with a non-working script in case big changes are made by gentoo. So i just made a copy and cut things out and made some changes (didn't do the gentoo reading so i setup wireless manually without those /etc/conf.d/wireless stuff). It works for now. if it stops working i can revert to the original.

 

Well, it works, and it works as well as original version of the script, but denies future changes and updates in system itself. It seems to me like hacking things that work, to get them working. And that /etc/conf.d/wireless stuff is only 6 lines and it is much more flexible  :Very Happy: .

And as handbook says "Gremlins are know to attack your system if you ignore this warning"  :Cool: 

----------

## quatsch

well, I doubt the changes will benefit other users since they are somewhat specific. Like checking for PCMCIA that is done at the beginning. I don't use pcmcia so I got rid of that part. Also it does some checking here and there for this and that where I know what the result is on my particular setup so I got rid of those (like ip6 which I don't use; and my wlan0 should be the default gateway, etc.) It does speed things up noticeably on my very sluggish old laptop after similar editing of other init scripts. (i doubt it would be noticeable on a modern fast laptop).  But I understand you want these things in the default script so it's flexible enough to accomodate different possible setups.  

The only real change had to do with wireless. But this was because I didn't read up on the gentoo way of doing things wireless  :Embarassed:  Maybe the wireless scripts/configuration files should be installed by default? At least with the wireless-tools, maybe? I thought I had everything I need after enabling the hardware and emerging wireless-tools but that wasn't the case. If I had seen a net.wlan0 or wireless or something like that in init.d, I wouldn't have had to read up on man iwconfig and stuff...

Edit: I only edit copies and set things up so that the copies are run. the originals are still in place and will get updated by the portage system. This way, I can always go back to a working system in case the changed scripts stop working.

----------

## UberLord

 *quatsch wrote:*   

> well, I doubt the changes will benefit other users since they are somewhat specific. Like checking for PCMCIA that is done at the beginning. I don't use pcmcia so I got rid of that part. Also it does some checking here and there for this and that where I know what the result is on my particular setup so I got rid of those (like ip6 which I don't use; and my wlan0 should be the default gateway, etc.) It does speed things up noticeably on my very sluggish old laptop after similar editing of other init scripts. (i doubt it would be noticeable on a modern fast laptop).  But I understand you want these things in the default script so it's flexible enough to accomodate different possible setups.

 

The checking for pcmcia step hardly takes any time at all - lol

We cater for very slow systems as well, checkout the modules_force parameter.

The main reason why the networking stuff is slower is because it has to check each module it loads for various things (installed, dependancies, order, etc). If you know what you need you can bypass this with modules_force. For example, lo only needs iproute2 or ifconfig and nothing else, so it's modules_force=( "iproute2" "ifconfig" ) and it's quite fast.

 *Quote:*   

> 
> 
> The only real change had to do with wireless. But this was because I didn't read up on the gentoo way of doing things wireless  Maybe the wireless scripts/configuration files should be installed by default? At least with the wireless-tools, maybe?

 

They get installed by default with baselayout>=1.11.11

----------

## aderby

I've just installed a Ralink 2500 based card and it's all working fine when started manually.  Now I just need to get my /etc/conf.d/wireless settings correct - unfortunately I don't appear to have this wireless.examples file people keep talking about, so I'm having a hard time converting the iwconfig & iwpriv commands I used to the correct syntax.  Any reason why it wouldn't be there on my system (I have a fresh install of wireless-tools and whatever is the current version of baselayout)?  If anyone has a copy they can point me to that would be great. 

Thanks,

Andrew.

----------

## DRSON

That wireless and wireless.example thingie we're talking about is in more recent version of baselayout, that is currently masked by ~x86 keyword.

~x86 means, that they're marked as testing and should be installed with caution, because they might not work correctly or not at all.

More info about portage features can be found at A Portage Introduction in Gentoo Handbook.

----------

## aderby

Didn't check my version of baselayout - to be fair I was away from my Gentoo machine when I posted.  I assumed that the version you were discussing would be stable by now.  On the whole I'm not that keen on the idea of going ~x86 on such a fundamental component.  Also the pressure seems to have gone away somewhat - when I got home I thought what the heck and re-booted.  Everything came up fine - I've currently not got WEP enabled so I guess I can get away without the fancier wifi specific configuration.  I'll look into enabling WEP once baselayout 1.11.11 hits stable.

----------

