# getting my computer to connect to the network at startup?

## 2kmike

Hi there,

sorry if i appear to have been spamming the forums with questions of late, but my new years resolution is to not use windows at home for a minimum of a year, therefore i'm running out of time....! Still got to sort out my laptop yet as well!

anyway, I'm down to 2 more problems with my gentoo machine (the other is the printer but i'll worry about that at a later date!)

the problem I have with networking I have had all along but have been working around it, my wireless card is detected as wlan0 therefore as soon as i boot up and log in I type

```

ifconfig wlan0 192.168.1.69 broadcast 192.168.1.255 netmask 255.255.255.0

iwconfig wlan0 key mykey....

iwconfig wlan0 essid myessid....

route add default gw 192.168.1.254

```

If I do this in that order, it tends to connect about 90% of the time, however sometimes I have to go through it again, or re-add the essid and default gateway to get it to connect to the network.

what i'm wondering is how to get it to connect to the network at boot? I read all the stuff in the handbook but still can't work out how to get it to work with the card in this machine

sorry to be a pain in the arse

thanks

Mike

----------

## poly_poly-man

 *2kmike wrote:*   

> sorry if i appear to have been spamming the forums with questions of late,

 

well, that's what we're here for...

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=4

skip the wpa_supplicant section (assuming you're using wep), and put lines similar to those in you /etc/conf.d/net.

Then take a look at net.example.

So, in otherwords,

```
modules=( "iwconfig" )

essid_wlan0="myessid"

key_myessid="s:mykey"

config_wlan0=( "192.168.1.69\24" )

routes_wlan0=( "default via 192.168.1.254" )
```

in /etc/conf.d/net. If you're using ~arch and have openrc, drop the parentheses and spaces.

----------

## 2kmike

hi there,

that isn't unlike what i had in there to begin with, but i've altered it round and there is no diference...

if i run ifconfig it doesn't detect there is even a card there until I do the 

ifconfig wlan0 192.168.1.69 broadcast 192.168.1.255 netmask 255.255.255.0 

is this because nothing is being called during the boot process?

in the handbook it says to run this

 *Quote:*   

> 
> 
> rc-update add net.eth0 default
> 
> 

 

however because i don't have an eth0 it caused an error on boot so i removed it, however when i tried it with wlan0 rather than eth0 it wouldn't accept it. Apologies if i'm being stupid

----------

## ppurka

You must have the file /etc/init.d/net.wlan0. If you don't have that file, then do a symlink:

```
cd /etc/init.d

ln -s net.lo net.wlan0
```

----------

## 2kmike

Hi ppurka

I tried what you suggested and i was getting the error on boot

```

* failed to configure wireless for wlan0

```

also once I logged I was unable to connect to the network using the above method, despited repeatedly trying until i deleted the symlink and rebooted the machine?

I hope this makes sense to someone, because it's puzzling me. 

I know it's not a massive problem having to type 4 lines into the computer everytime I log in and want to access the network and internet, but it's getting a bit wearing now.

thanks for the help so far though

Mike

----------

## vaguy02

Well, I hate to say it and the people above me will shoot me for saying this. But why don't you just add the commands that you run in order to a custom script and add that script to local.start

*watches for the hand of doom*

----------

## NeddySeagoon

2kmike,

I suspect your card (you don't day what it is, or what driver you are using) cannot cope with the speed the commands are sent to it.

Its OK when you give them manually but the script will send them much faster.

Try adding some of the delays listed here under Troubleshooting Wireless Tools near the bottom.

----------

## 2kmike

Hi there,

Sorry for not supplying enough details...

the card is an Ralink RT2500 and the driver that i'm using is  RT2500PCI which is built directly into the kernel directly rather than a module.

what i found odd (maybe i'm wrong) is that when i did the symlink it would fail, but even when i typed ifconfig wlan0 down and ifconfig didn't detect it, i was unable to connect to the network after typing the above commands? apologies if i'm being thick?

I will give the your suggestion a go however.

Thanks for the help

----------

## NeddySeagoon

2kmike,

Any and all network interfaces need a symlink to net.lo in /etc/init.d/

net.lo runs as whatever file its called as, so when you use the net.wlan0 symlink, it runs as net.wlan0.

You need that symlink to make it work at startup so you can do 

```
rc-update add net.wlan0 default
```

That needs to be defualt, not boot too as only net.lo should be in boot.

I use the ralink rt73 built as a kernel module. I suggest you make your wireless support modular until it works, as its often useful to try various module load time options, which you can do without a reboot, if the code in question is build as a loadable kernel module.

What kernel are you using, for me, it appears that 2.6.26 or 2.6.27 worked best.

When you can get the link up, post iwconfig wlan0 - you may want to censor your encryption key.

----------

