# [SOLVED] Starting wireless network automatically

## ycUygB1

I'm able to start my wireless network manually via:

    ifconfig ath0 up

    dhcpcd ath0

but I'm totally unable to have the network bring itself up at boot time.

For now, I'd like to connect to my preferred networks, if possible.

Here's the contents of /etc/init.d/net

iface_eth0="dhcp"

modules=( "dhcpcd" )

modules=( "ifconfig" )

preferred_aps=( "naparst" "tmobile" )

iface_ath0=( "dhcp" )

config_ath0=( "dhcp" )

dhcpcd_ath0=("-t  60 -d -B")

I've tried changing the above commands in a variety of ways, with no effect.

And /etc/init.d/wireless

preferred_aps=( "naparst" "tmobile" )

and 

/etc/init.d/net.ath0 stop

 * Caching service dependencies ...

 *  Can't find service 'net.wlan0' needed by 'hostapd';  continuing...                                                      [ ok ]

 * Bringing ath0 down ...                                  [ ok ]

emigration conf.d # /etc/init.d/net.ath0 start

 * Bringing ath0 up ...                                    [ ok ]

emigration conf.d # lsmod

Module                  Size  Used by

pcmcia                 28756  - 

yenta_socket           23432  - 

rsrc_nonstatic         13408  - 

pcmcia_core            54084  - 

snd_atiixp             21632  - 

snd_ac97_codec         83128  - 

snd_pcm                94756  - 

snd_timer              25316  - 

snd                    49620  - 

snd_page_alloc          9860  - 

ntfs                  224692  - 

ohci_hcd               21860  - 

ehci_hcd               33416  - 

8139too                26016  - 

ath_pci                63616  - 

ath_rate_onoe           8808  - 

wlan                  121692  - 

ath_hal               148272  - 

evdev                   9248  - 

However, even after commanding /etc/init.d/net.ath0 start,

the interface still isn't even up, and I have to start it 

manually.  From what I can tell, the script net.ath0 isn't doing

anything.  However, my hardwired eth0 starts perfectly at boot with

ifplugd.  This seems like it should be simple.

HaroldLast edited by ycUygB1 on Sat Aug 06, 2005 4:37 pm; edited 1 time in total

----------

## a2gentoo

You havent given enough info to give you a real detailed answer. We kinda need to know what wireless card you are using.

With that said. There is a possibility that your Baselayout is messed up. It happened to me on my laptop. Actually it seems to be pretty common. Try re-emerging the base layout using the following.

 *Quote:*   

> emerge --oneshot --noconfmem baselayout 

 

This will give you a clean up-to-date baselayout. (be sure to watch for any changes in the update). This solution didnt cure ALL of my problems (I have an Intel Pro 220) But it cured MOST of them.

c

----------

## ycUygB1

The ath0 interface is an Atheros chipset, the driver is madwifi.

I tried the command.  It had no effect.

Here's what we're dealing with:

emigration ~ # /etc/init.d/net.ath0 restart

 * Bringing ath0 down ...                                                        [ ok ]

 * Bringing ath0 up ...                                                          [ ok ]

So it should be up now, and it should have an IP address, right?

emigration ~ # ifconfig

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

But it isn't up, because it isn't listed above.

I can bring it up manually...

emigration ~ # ifconfig ath0 up 

emigration ~ # ifconfig

ath0      Link encap:Ethernet  HWaddr 00:11:F5:2D:35:98  

          inet addr:10.252.143.167  Bcast:10.252.143.191  Mask:255.255.255.224

          UP BROADCAST NOTRAILERS MULTICAST  MTU:1500  Metric:1

          RX packets:259 errors:487 dropped:0 overruns:0 frame:487

          TX packets:230 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:199 

          RX bytes:231884 (226.4 Kb)  TX bytes:48588 (47.4 Kb)

          Interrupt:18 Memory:e8aa0000-e8ab0000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

And then give it an IP address manually.

emigration ~ # dhcpcd ath0

****  dhcpcd: already running

****  dhcpcd: if not then delete /var/run/dhcpcd-ath0.pid file

emigration ~ # dhcpcd -k  

****  dhcpcd: not running

emigration ~ # dhcpcd ath0

****  dhcpcd: already running

****  dhcpcd: if not then delete /var/run/dhcpcd-ath0.pid file

emigration ~ # rm /var/run/dhcpcd-ath0.pid 

emigration ~ # dhcpcd ath0

----------

## optiactive

Could you post the contents of your /etc/init.d/net.ath0 file? It might explain why your card isn't starting automatically.

----------

## ycUygB1

emigration init.d # ls -l net.ath0

lrwxrwxrwx  1 root root 6 Jul 26 21:32 net.ath0 -> net.lo

emigration init.d # more net.lo

#!/sbin/runscript

# Copyright 1999-2004 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.lo,v 1.10 2004/04/21 17:09:18 vapier Exp $

start() {

        ebegin "Bringing ${IFACE} up"

        /sbin/ifconfig lo 127.0.0.1 up 2>/dev/null

        /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 \

                gw 127.0.0.1 dev lo 2> /dev/null

        eend 0

}

stop() {

        ebegin "Bringing ${IFACE} down"

        /sbin/ifconfig ${IFACE} down &>/dev/null

        eend 0

}

emigration init.d #

----------

## optiactive

net.ath0 is a symlink to net.lo in /etc/init.d. Remove the net.ath0 symlink and copy net.lo to net.ath0 in the same directory (/etc/init.d). Then, change the code in the start function of the /etc/init.d/net.ath0 script to run the commands you use to manually start your wireless card.

Lastly, create a symlink from /etc/runlevels/boot/net.ath0 to /etc/init.d/net.ath0.

That should make your wireless card work at boot time.

----------

## ycUygB1

Well, of course you are correct, and thank you for that.  It worked.

The question is:  why does the handbook tell me to make net.ath0 a symlink if that doesn't work?

Now onto figuring out why I can't connect to non-broadcasted ESSIDs.

I assume the code I put in /etc/conf.d/net will connect to my preferred networks, even if the essids are not broadcasted, right?

Harold

----------

## optiactive

Sorry, I don't know. I guess I'll have to try to configure my system correctly, now.  :Smile:  I took a quick look, and the advice is to use wpa_supplicant. You can find some info here:

http://gentoo-wiki.com/HOWTO_Wireless_Configuration_and_Startup#Configuration_using_iwconfig

Good luck!

----------

## ycUygB1

Ok, here's the wisdom of one noob to another:

I don't have any idea why the handbook says to symlink to loopback.

But I found a script in /etc/init.d (in my case it was called net.wlan0), that was not

symlinked to loopback.  This script is clearly the one that Gentoo intends for us to use for real interfaces.

It calls ifconfig and iwconfig, which are (Gentoo written?) scripts themselves that read the environment variables defined

in /etc/conf.d/net and /etc/conf.d/wireless.  So the whole thing makes sense, except for the symlink thing.  That's a mystery.

Also, it isn't clear how hotplug devices are supposed to be set up.  

As far as seeing hidden essids, that seems to be a function of buggy drivers.  Some drivers, such as the madwifi driver

are so young that they haven't added that feature yet.

Lost in the fog....

----------

## IamBorg

For my Atheros chipset with madwifi drivers, I had a problem with the network not starting on boot.  Then I added /etc/modules.autoload.d/kernel-2.6 the line ath_pci.  This is the module that needs to be loaded.  It was automatically being loaded when I inserted the card in after boot.  Maybe this will help.  Also, you should be able to use the forcepreferred aps for the card to try those ESSIDs even if it doesn't see them from the scanning process.

My problem that I've been trying to find the answers for is how to set my dhcpd parameters and to use the configurations within the conf.d/wireless and not the older style in conf.d/net so that my ntp.conf file doesn't get overwritten.  (I've recently upgraded my system.) 

---EDIT---

OK.  I just deleted the old settings and now the new are used and my answers have been revealed.

----------

## ycUygB1

I wrote that post and question six days ago, but it seems like an eternity given all that has happened.

I got into a long discussion with Uberlord in another thread, and he helped me out.

The deal is that I was running a very old version of the net.lo script.  Actually, there were a few

of them floating around my system because I had been ignoring the warnings about updating my config files

after emerges.

After you do an emerge, of baselayout (FOR INSTANCE), new files (such as /etc/init.d/net.lo) are written

to the system, but don't clobber the existing ones in /etc/init.d until you affirmatively tell the system to do that,

by running etc-update or dispatch-conf.

The new net.lo script is much better than the old one, and actually works fine with iwconfig.

The reason that everything is symlinked to net.lo is just to avoid duplication of the code.  net.lo calls dhcpcd

and ifconfig just as you would expect.  The boot messages are very nice.

For modern 32-bit wifi cards, you can just call coldplug at boot and hotplug at default, and the cards should

be detected.  For 16-bit cards, such as the orinoco pcmcia chipset, you have to call pcmcia and net.ethx at default and leave out coldplug.

I have a mix of 32-bit and 16-bit, and I call pcmcia and net.ethx at default.

So, my advice is:

  1.  Update to the latest baselayout.

  2.  Run etc-update (don't ignore this one.)

  3.  Call pcmcia, hotplug, and net.ethx at default 

  4.  iwconfig works fine.

Uberlord doesn't like pcmcia, but you have to use it for 16-bit cards.

----------

