# Can't start wireless network with net script automatically.

## ttwttmttj

Hi All,

  This problem confused me for a long time,

  and I have also googled and read the wireless.example

  for this answer, but unfortunately, it doesn't work.

  I need your help!

  BTW. my wireless card is linksys wusb54gc

  I have a small script(list below) which collected from the network

  and this script sometimes

  (esp. when run this script for the first time after system startup,

  it works correctly)

  can startup the wireless network correctly except I have to run

  it manually with root user.

File: /root/startWireless.sh

#!/bin/bash

/etc/init.d/net.wlan0 stop

modprobe rt73

ifconfig wlan0 down

iwconfig wlan0 mode Managed

ifconfig wlan0 up

iwconfig wlan0 essid  WMJ

iwpriv wlan0 set AuthMode=WPA2PSK

iwpriv wlan0 set WPAPSK=XXXXXX

iwpriv wlan0 set EncrypType=AES

dhclient wlan0

   And I wrote my net file according to above script:

File: /etc/conf.d/net

config_eth0=( "null" )

essid_wlan0="WMJ"

mode_wlan0="managed"

channel_wlan0="11"

iwpriv_wlan0=""

iwpriv_WMJ=(

  "set AuthMode=WPA2PSK"

  "set EncrypType=AES"

  "set WPAPSK=XXXXXX"

)

# According to this note, it seem I have to add the WEP key.

  #NOTE: Even though you can use WPA like so, you may have to set a WEP key

  #if your driver claims the AP is encrypted. The WEP key itself will not be

  #used though.

key_WMJ="s:foobar"

config_wlan0=( "dhcp" )

routes_wlan0=( "default via 192.168.1.1" )

  The problem is the script net can not active wireless net work when the

  system startup, it prints the log list below:

File: log of /etc/init.d/net.wlan0 start , during the system startup.

 * Caching service dependencies ...                                                                                                                       [ ok ] * Starting wlan0

 *   Loading networking modules for wlan0

 *     modules: adsl apipa arping bridge ccwgroup macchanger macnet rename iwconfig essidnet iptunnel iproute2 pppd system dhclient ip6to4

 *       iwconfig provides wireless

 *       iproute2 provides interface

 *       pppd provides ppp

 *       dhclient provides dhcp

 *   Configuring wlan0 for MAC address 00:1D:7E:03:FE:E1 ...                                                                                              [ ok ] *   Configuring wireless network for wlan0

 *   Connecting to "WMJ" in managed mode (WEP enabled) ...                                                                                                [ ok ] *     wlan0 connected to ESSID "WMJ"

 *     in managed mode on channel 11 (WEP enabled)

 *   Configuring wlan0 for ESSID "WMJ" ...                                                                                                                [ ok ] *   Bringing up wlan0

 *     dhcp

 *       Running dhclient ...

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

--- 192.168.1.1 ping statistics ---

1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

  If I launch this net script once after manually run /root/startWireless.sh.

  it works.

  But if it has been launched automatically, it does not works,

  and it seems blocking at the dhclient.

So my question is how can I start my wireless network automatically ?

File: log of my system info (emerge --info)

Portage 2.1.4.4 (default-linux/amd64/2007.0, gcc-4.1.2, glibc-2.6.1-r0, 2.6.24-gentoo-r4 x86_64)

=================================================================

System uname: 2.6.24-gentoo-r4 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5000+

Timestamp of tree: Sat, 03 May 2008 07:00:01 +0000

app-shells/bash:     3.2_p17-r1

dev-lang/python:     2.4.4-r6

dev-python/pycrypto: 2.0.1-r6

sys-apps/baselayout: 1.12.11.1

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.13, 2.61-r1

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1

sys-devel/binutils:  2.18-r1

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.24

virtual/os-headers:  2.6.23-r3

ACCEPT_KEYWORDS="amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=athlon64 -O2 -pipe -msse3 -mno-tls-direct-seg-refs"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/X11/xkb"

CONFIG_PROTECT_MASK="/etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c

 /etc/udev/rules.d"

CXXFLAGS="-march=athlon64 -O2 -pipe -msse3 -mno-tls-direct-seg-refs"

DISTDIR="/root/storage/distdir/"

FEATURES="buildpkg distlocks metadata-transfer sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS=" http://distro.ibiblio.org/pub/linux/distributions/gentoo/ http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/ http://gentoo.inode.at/ ftp://gentoo.inode.at/source/ http://gentoo.gg3.net/ http://gent

oo.channelx.biz/ "

LANG="en_US.UTF-8"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/layman/gentoo-china /usr/portage/local/layman/marineam-xen /usr/portage/local/layman/xen"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="acl amd64 apache2 bash-completion berkdb cjk cli cracklib crypt cups doc dri fortran gdbm gpm hvm iconv immqt-bc ipv6 isdnlog midi mmx mudflap ncurses nls

nptl nptlonly openmp pam pcre perl pppd python readline reflection rt73usb sdl session spl sse sse2 ssl tcpd unicode vim-syntax xorg zlib" ALSA_CARDS="snd-hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix

 dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm a

uthn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers inc

lude info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES

="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="nv nvidia vesa"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

----------

## freelight

You'd have to use wpa_supplicant. /etc/conf.d/net doesn't support WPA, only WEP. The good news is that wpa_supplicant is easy to configure and has both command-line and graphical interfaces. You can then have /etc/conf.d/net look like this:

```
modules=("wpa_supplicant")

wpa_supplicant_wlan0="-Dwext"
```

----------

## ttwttmttj

Hi freelight,

   Thanks a lot for your quickly reply.

   I have just tried add this into /etc/conf.d/net 

   And the log looks like this:

```
* Caching service dependencies ...                                                                                                                                                                        [ ok ]

 * Starting wlan0

 *   Loading networking modules for wlan0

 *     modules: adsl apipa arping bridge ccwgroup macchanger macnet rename wpa_supplicant essidnet iptunnel iproute2 pppd system dhclient ip6to4

 *       wpa_supplicant provides wireless

 *       iproute2 provides interface

 *       pppd provides ppp

 *       dhclient provides dhcp

 *   Configuring wlan0 for MAC address 00:1D:7E:03:FE:E1 ...                                                                                                                                               [ ok ]

 *   Starting wpa_supplicant on wlan0 ...

ioctl[SIOCSIWAUTH]: Operation not supported

WEXT auth param 7 value 0x1 - ioctl[SIOCSIWENCODEEXT]: Operation not supported

ioctl[SIOCSIWENCODEEXT]: Operation not supported

ioctl[SIOCSIWENCODEEXT]: Operation not supported

ioctl[SIOCSIWENCODEEXT]: Operation not supported

ioctl[SIOCSIWAUTH]: Operation not supported

WEXT auth param 4 value 0x0 - ioctl[SIOCSIWAUTH]: Operation not supported                                                                                                                                         [ ok ]th param 5 value 0x1 - 

 *   Starting wpa_cli on wlan0 ...                                                                                                                                                                         [ ok ]

 *     Waiting for association                                                                                                                                                                             [ ok ]

 *     Backgrounding ...

```

   The driver I am using is RT73 which compiled myself.

   and I guess wpa_supplicant does not support this driver without patch.

   It is weird because my script does not use wpa_supplicant at all, why system startup script have to use it ?

   Any way thanks  for your reply !!

----------

## freelight

Hmm. Since the driver isn't supported by wpa_supplicant, you can just automate what you do manually. Add your script to /etc/conf.d/local.

The lack of WPA support in the startup script is a deficiency, but these days wpa_supplicant is recommended for any type of wireless connection simply because it's easier to control and use wpa_gui to hop networks, etc. If you don't need this functionality and don't want to mess with patching wpa_supplicant, just point /etc/conf.d/local to your script and leave it at that.

----------

## pappy_mcfae

If you want your wireless to work, move up to the .25 kernel series, or move down to the .22 family. The .24 kernels suck at wpa_supplicant support, ndiswrapper support, and wireless support in general. The .24 kernel series is not noted for wireless compatibility.

Blessed be!

Pappy

----------

## ttwttmttj

 *freelight wrote:*   

> Hmm. Since the driver isn't supported by wpa_supplicant, you can just automate what you do manually. Add your script to /etc/conf.d/local.
> 
> The lack of WPA support in the startup script is a deficiency, but these days wpa_supplicant is recommended for any type of wireless connection simply because it's easier to control and use wpa_gui to hop networks, etc. If you don't need this functionality and don't want to mess with patching wpa_supplicant, just point /etc/conf.d/local to your script and leave it at that.

 

Hi freelight,

  Thanks a lot for your info, I have added this script to failup function .

  And it works!

```

failup(){

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

    iwconfig wlan0 mode Managed

    ifconfig wlan0 up

    iwconfig wlan0 essid  WMJ

    iwpriv wlan0 set AuthMode=WPA2PSK

    iwpriv wlan0 set WPAPSK=wmjHomeOffice

    iwpriv wlan0 set EncrypType=AES

    dhclient wlan0

  fi

  return 0

}
```

----------

## ttwttmttj

 *pappy_mcfae wrote:*   

> If you want your wireless to work, move up to the .25 kernel series, or move down to the .22 family. The .24 kernels suck at wpa_supplicant support, ndiswrapper support, and wireless support in general. The .24 kernel series is not noted for wireless compatibility.
> 
> Blessed be!
> 
> Pappy

 

hi,

Currently I am using this driver:

2008_0506_RT2870_Linux_STA_v1.3.0.0   rt2870sta.ko

and if newer kernel support this module, I will have a try.

Do you mean, that .25 kernel can support this driver ? 

Thanks.

----------

## pappy_mcfae

If it doesn't, I know for a fact it supports ndiswrapper, and as long as you still have the Windoze drivers, you'll have functional wireless. The .24 kernels are no good for wireless. The .23 family isn't much better. But .22 and .25 kernels support wireless much better...and they don't barf errors when you start wpa_supplicant.

Blessed be!

Pappy

----------

## ttwttmttj

 *pappy_mcfae wrote:*   

> If it doesn't, I know for a fact it supports ndiswrapper, and as long as you still have the Windoze drivers, you'll have functional wireless. The .24 kernels are no good for wireless. The .23 family isn't much better. But .22 and .25 kernels support wireless much better...and they don't barf errors when you start wpa_supplicant.
> 
> Blessed be!
> 
> Pappy

 

Hi pappy_mcfae,

  Thank you very much for your info!

  Yes, I have its windows driver,  this maybe a better way to resolve this problem, 

  I will have a try once .25 kernel tagged as stable for gentoo amd64 portage.

  BTW. I just wrote a email to ralink's technique support and ask if sometime their driver 

  can be formally supported in kernel. 

  Once I get the reply. I will let you know.

  Thanks again.

----------

## pappy_mcfae

If you're going to wait, then I'd suggest you try the support offered by 2.6.22.19 or 2.6.22-gentoo-r10. If they support your hardware, use them. Ndiswrapper runs great on the .22 kernels...and I'm pretty sure it's in the stable branch for amd64. My Core2 runs on the gentoo-source version pretty much exclusively, and I only shut that system off when there's a thunderstorm in the area. I know what lighting strikes do!

Blessed be!

Pappy

----------

