# Why I need "ifconfig ath0 up" before net.ath0 script

## z_sfeng

I need to connect AP with hidden ESSID. 

I linked net.ath0 to net.lo. but it doesn't work at startup. I have to manually run

```
ifconfig ath0 up
```

then

```
/etc/init.d/net.ath0
```

 works.

I use iwconfig, and this is my /etc/conf.d/wireless:

```

essid_ath0="myessid"

key_myessid="s:mykey enc open"

config_myessid=( "dhcp" )

preferred_aps=( "myessid", "antheressid")

```

ant there is nothing in /etc/conf.d/net

So. my problem is: the wifi basically works, but couldn't automatically start at boot. 

What could I do? 

and my baselayout is 1.11.14-r8

----------

## _loki_

you need to run

```

/etc/init.d/net.ath0 start

```

to start the device, for automatic startup ob boot run

```

rc-update add net.ath0 default

```

configuration should work..

----------

## z_sfeng

I think I didn't state my question clearly.

I put net.ath0 to default rc-level by rc-update.

but I got error at startup:

```
Failed to configure wireless for ath0
```

If I run this manually:

```

ifconfig ath0 up

/etc/init.d/net.ath0 start
```

then everythink works fine.

My quesiton is: 

Why do i have to run "ifconfig ath0 up" manually?

How can I bypass it?

----------

## UberLord

Try this in conf.d/net

```

preup() {

   if [[ ${IFACE} == "ath0" ]] ; then

      # Some atheros cards need an extra up

      # NOTE: the card is upped a few times anyway, so this *should* be redundant

      interface_up "${IFACE}"

      # Maybe give it time to settle

      sleep 2

   fi

   return 0

}
```

----------

## z_sfeng

Yes! this script works perfect.

Thanks alot.    :Laughing: 

----------

## mikegpitt

Excellent!  I was having a similar problem after an upgrade.  Thanks, UberLord, as always you are the master at gentoo networking!  The preup fcn works great.

----------

## Penguin of Wonder

Uberlord, I found this thread trying to figure out how to fix my wireless connection as well. The script worked for my atheros card as well. Thanks alot!

----------

## UberLord

If anyone can provide a better fix so you don't need that preup code then I'll accept any donations!

I do wonder why my atheros works just fine though.

----------

## 96140

This should work for me -- next time I reboot I'll try it.

The odd thing is that all I did was switch essids/keys when I switched to my new home network -- I even used the same hardware, but suddenly I've had to manually run ifconfig ath0 down, ifconfig ath0 up, /etc/init.d/net.ath0 start after logging in to connect.

I'm wondering if something happened before I set up WEP, when my card associated with my (briefly) open router. No idea, really; it's the strangest thing.

Thanks for the script, UberLord.

----------

## Penguin of Wonder

My computer crashed (all my fault, not Linux's or Gentoo's) so with no backups made of my system I had to reinstall everything. Upon re-install I used the preup code from Uberlord assuming I would need it like I did last time. But now I don't need it, and if I include it, then it gives a bunch of errors about netmount not being able to start?? I don't know. I am as offically confused about this as anyone else.

----------

## UberLord

Edited the post to always return 0

Should fix your problem  :Smile: 

For more commentry on this and other madwifi issues, track this bug

https://bugs.gentoo.org/show_bug.cgi?id=143698

----------

