# wireless Howto

## badgers

http://gentoo-wiki.com/HOWTO_Wireless_Configuration_and_Startup

I am really having a hard time. I have a RT2500 and when I use the GUI RaConfig2500 utility it seems to work.

but it does not work at boot and I am trying to set up Mythtv and I won't be able to use the GUI to configure at each reboot.

first I use the hardwired eth0 to see that it works.

```

DavidCPU ~ # ping -I eth0 google.com

PING google.com (64.233.167.99) from 192.168.1.10 eth0: 56(84) bytes of data.

64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=242 time=17.5 ms

64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=2 ttl=242 time=13.3 ms

--- google.com ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1000ms

rtt min/avg/max/mdev = 13.317/15.411/17.506/2.098 ms

DavidCPU ~ # ping -I ra0 google.com

PING google.com (72.14.207.99) from 192.168.1.103 ra0: 56(84) bytes of data.

From 192.168.1.103 icmp_seq=2 Destination Host Unreachable

From 192.168.1.103 icmp_seq=3 Destination Host Unreachable

From 192.168.1.103 icmp_seq=4 Destination Host Unreachable

--- google.com ping statistics ---

6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4998ms

, pipe 3

DavidCPU ~ # route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

192.168.1.0     *               255.255.255.0   U     0      0        0 ra0

loopback        *               255.0.0.0       U     0      0        0 lo

default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

```

here is the other bits of info.

```

DavidCPU ~ # ifconfig

eth0      Link encap:Ethernet  HWaddr 00:20:78:01:5D:C2

          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::220:78ff:fe01:5dc2/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:421877 (411.9 Kb)  TX bytes:378834 (369.9 Kb)

          Interrupt:10 Base address:0xc000

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

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

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

          collisions:0 txqueuelen:0

          RX bytes:560 (560.0 b)  TX bytes:560 (560.0 b)

ra0       Link encap:Ethernet  HWaddr 00:0E:3B:04:CE:BA

          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::20e:3bff:fe04:ceba/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:10 txqueuelen:1000

          RX bytes:3491 (3.4 Kb)  TX bytes:7075 (6.9 Kb)

          Interrupt:5 Base address:0x4000

DavidCPU ~ # iwconfig

lo        no wireless extensions.

sit0      no wireless extensions.

eth0      no wireless extensions.

ra0       RT2500 Wireless  ESSID:"linksys"

          Mode:Managed  Frequency=2.462 GHz  Access Point: 00:13:10:8D:0A:00

          Bit Rate=54 Mb/s   Tx-Power:-3 dBm

          RTS thr=2312 B   Fragment thr=2312 B

          Encryption key:off

          Link Quality=92/100  Signal level=-39 dBm  Noise level:-193 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

DavidCPU ~ #

```

there is no WEP or other encryption, I tried to keep this simple.

DHCP seemed to get it an IP address from the linksys WRT54G router.

I can ping the router

```
DavidCPU ~ # ping -I ra0 192.168.1.1

PING 192.168.1.1 (192.168.1.1) from 192.168.1.103 ra0: 56(84) bytes of data.

64 bytes from 192.168.1.1: icmp_seq=10 ttl=64 time=1.79 ms

64 bytes from 192.168.1.1: icmp_seq=11 ttl=64 time=0.817 ms

64 bytes from 192.168.1.1: icmp_seq=12 ttl=64 time=0.819 ms

--- 192.168.1.1 ping statistics ---

12 packets transmitted, 3 received, 75% packet loss, time 10998ms

rtt min/avg/max/mdev = 0.817/1.144/1.796/0.461 ms

```

any help is appreciated. I would like to take out the eth0 nic and have ra0 come up at boot.

----------

## caplan

Hey badgers,

What does your /etc/conf.d/net file look like?  I had an issue where my ath0 device wouldn't start properly on boot.  Also, what runlevels are your initscripts like?

```
bash# rc-update show
```

Can you manually start your ra0 device?

----------

## badgers

It doesn't show up in rc-update because I removed it so I can try to fix it without it hanging at boot for 1 minute until it times out. I had it starting up at default.

I think their is a config file problem.

It looks like it came up manually in a way.

I can use dhcp to get an IP, I can ping the linksys router but I can't get out to anything else.

that is why I included the cut and past above.

Thanks

----------

## caplan

badgers,

Part of your issue might be that your default gateway is set using eth0:

```
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0 
```

When doing your testing, I'd shutdown eth0:

```
/etc/init.d/net.eth0 stop
```

Ensure your routing table is updated appropriately, then attempt to ping again.  You can also specify which interface to use specifically with ping to ensure you are using your ra0 device:

```
ping -I ra0 www.yahoo.ca
```

If that works and you can confirm your ra0 device works properly when setting up everything manually, you should be able to get it start on boot.  See my issue earlier today.

----------

## badgers

thanks I will try that right now.

----------

## badgers

OK here we are.

I can manually get the wireless up and running via the commandline and not have eth0 in the machine.

I don't want the wireless to use dhcpcd I want to do with it what I did with eth0

here is what eth0 had...

```

DavidCPU ~ # cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_eth0=( "192.168.1.10 netmask 255.255.255.0 brd 192.168.1.255" )

routes_eth0=( "default gw 192.168.1.1" )

```

now should I chage eth0 to be ra0 in this file or do I somehow add it to net.wireless?

thanks

----------

## caplan

Hi badgers,

Just add an entry into your /etc/conf.d/net for your ra0 device:

```
# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_eth0=( "192.168.1.10 netmask 255.255.255.0 brd 192.168.1.255" )

routes_eth0=( "default gw 192.168.1.1" )

config_ra0=( "192.168.1.10 netmask 255.255.255.0 brd 192.168.1.255" )

routes_ra0=( "default gw 192.168.1.1" )
```

You should leave your entries for your eth0 device incase you want to use it later.  Not sure if you are using madwifi or not, but if you are there are some additional entries in your /etc/conf.d/net file you need.  I'm assuming that you don't need them since you already have your wifi working.

Ensure you have a /etc/init.d/net.ra0 initscript.  If not, create one which is just a symlink to /etc/init.d/net.lo.

```
ln -sf /etc/init.d/net.lo /etc/init.d/net.ra0
```

And ensure that your ra0 device is added to the default run level:

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

And take eth0 out of the default runlevel:

```
rc-update del net.eth0 default
```

Assuming everything else works, it should start automatically on boot using your static IP.  You may want to look at your router to always assign you an IP based on your MAC (which is what I do) rather than using a static config on your workstation.  That way when you roam to other places you don't have to do to many config changes.

----------

## badgers

thanks

----------

## badgers

hello I am in a bit of a pickle.

I did what you had said and during boot up I see that ra0 is up and I get the OK in dmesg. BUT it comes up with zero transmit power and as a result no connection.

I have to do an interactive boot to prevent ntpd and sshd from starting as they hang the boot process due to the nic not really transmitting anything.

once in the system I do the following and it works.

/etc/init.d/net.ra0 stop

and then 

ifconfig ra0 up

ifcofig ra0 192.168.1.10

route add default gw 192.168.1.1

and then it works.....

WTF!

here is my /etc/conf.d/wireless  

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

# Global wireless config file for net.* rc-scripts

##############################################################################

# Say that your wireless interface is ath0 - the line

#      #essid_eth0="any"

# becomes

#      #essid_ath0="any"

essid_ra0="linksys"

# Remember to change ESSID to your ESSID.

# Say that your ESSID is My NET - the line

#      #key_ESSID="s:passkey"

# becomes

#      #key_My_NET="s:passkey"

# Notice that the space has changed to an underscore - do the same with all

# characters not in a-z A-Z (english alphabet) 0-9. This only applies to

# variables and not values.

#

# Any ESSID's in values like essid_eth0="My NET" may need to be escaped

# This means placing the character \ before the character

# \" need to be escaped for example

# So if your ESSID is

#      My "\ NET

# it becomes

#      My \"\\ NET

# for example

#      #essid_eth0="My\"\\NET"

#

# So using the above we can use

#      #dns_domain_My____NET="My\"\\NET"

# which is an invalid dns domain, but shows the how to use the variable

# structure

#

# As a final note, most users will just need to set the following options

# key_ESSID1="s:yourkeyhere enc open" # s: means a text key

# key_ESSID2="aaaa-bbbb-cccc-dd"      # no s: means a hex key

# preferred_aps=( "ESSID1" "ESSID2" )

#

# Clear? Good. Now configure your wireless network below

#######################################################################################################################################

# SETTINGS

##############################################################################

# Hard code an ESSID to an interface - leave this unset if you wish the driver

# to scan for available Access Points

# Set to "any" to connect to any ESSID - the driver picks an Access Point

# This needs to be done when the driver doesn't support scanning

# This may work for drivers that don't support scanning but you need automatic

# AP association

# I would only set this as a last resort really - use the preferred_aps

# setting at the bottom of this file

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

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

#essid_ra0="linksys"

# 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_ra0="auto"

# If managed mode fails, drop to ad-hoc mode with the below ESSID?

#adhoc_essid_eth0="WLAN"

#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_ra0="11"

# Setup any other config commands. This is basically the iwconfig argument

# without the iwconfig $iface.

#iwconfig_eth0=""

# Set private driver ioctls. This is basically the iwpriv argument without

# the iwpriv $iface. If you use the rt2500 driver (not the rt2x00 one) then

# you can set WPA here, below is an example.

#iwpriv_eth0=""

#iwpriv_ESSID=(

#       "set AuthMode=WPAPSK"

#       "set EncrypType=TKIP"

#       "set WPAPSK=yourpasskey"

#)

#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.

# Seconds to wait before scanning

# Some drivers need to wait until they have finished "loading"

# before they can scan - otherwise they error and claim that they cannot scan

# or resource is unavailable. The default is to wait zero seconds

#sleep_scan_eth0="1"

# Seconds to wait until associated. The default is to wait 10 seconds.

# 0 means wait indefinitely. WARNING: this can cause an infinite delay when

# booting.

#associate_timeout_eth0="5"

# By default a successful association in Managed mode sets the MAC

# address of the AP connected to. However, some drivers (namely

# the ipw2100) don't set an invalid MAC address when association

# fails - so we need to check on link quality which some drivers

# don't report properly either.

# So if you have connection problems try flipping this setting

# Valid options are MAC, quality and all - defaults to MAC

#associate_test_eth0="MAC"

# Some driver/card combinations need to scan in Ad-Hoc mode

# After scanning, the mode is reset to the one defined above

#scan_mode_eth0="Ad-Hoc"

# Below you can define private ioctls to run before and after scanning

# Format is the same as the iwpriv_eth0 above

# This is needed for the HostAP drivers

#iwpriv_scan_pre_eth0="host_roaming 2"

#iwpriv_scan_post_eth0="host_roaming 0"

# 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_ESSID="s:foobar enc open"

#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

#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"

# You may want to set muliple keys - here's an example

# It sets 4 keys on the card and instructs to use key 2 by default

#key_ESSID="[1] s:passkey1 key [2] s:passkey2 key [3] s:passkey3 key [4] s:passkey4 key [2]"

# You can also override the interface settings found in /etc/conf.d/net

# per ESSID - which is very handy if you use different networks a lot

#config_ESSID=( "dhcp" )

#dhcpcd_ESSID="-t 5"

#routes_ESSID=()

#fallback_ESSID=()

# Setting name/domain server causes /etc/resolv.conf to be overwritten

# Note that if DHCP is used, and you want this to take precedence then

# please put -R in your dhcpcd options

#dns_servers_ESSID=( "192.168.0.1" "192.168.0.2" )

#dns_domain_ESSID="some.domain"

#dns_search_path_ESSID="search.this.domain search.that.domain"

# Please check the man page for resolv.conf for more information

# as domain and search (searchdomains) are mutually exclusive and

# searchdomains takes precedence

# You can also set any of the /etc/conf.d/net variables per MAC address

# incase you use Access Points with the same ESSID but need different

# networking configs. Below is an example - of course you use the same

# method with other variables

#config_001122334455=( "dhcp" )

#dhcpcd_001122334455="-t 10"

#dns_servers_001122334455=( "192.168.0.1" "192.168.0.2" )

# Map a MAC address to an ESSID

# This is used when the Access Point is not broadcasting it's ESSID

# WARNING: This will override the ESSID being broadcast due to some

# Access Points sending an ESSID even when they have been configured

# not to!

# Change 001122334455 to the MAC address and ESSID to the ESSID

# it should map to

#essid_001122334455="ESSID"

# This lists the preferred ESSIDs to connect to in order

# ESSID's can contain any characters here as they must match the broadcast

# ESSID exactly.

# Surround each ESSID with the " character and seperate them with a space

# If the first ESSID isn't found then it moves onto the next

# If this isn't defined then it connects to the first one found

#preferred_aps=( "ESSID 1" "ESSID 2" )

# You can also define a preferred_aps list per interface

#preferred_aps_eth0=( "ESSID 3" "ESSID 4" )

# You can also say whether we only connect to preferred APs or not

# Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly" and "forceany"

# "any" means it will connect to visible APs in the preferred list and then any

# other available AP

# "preferredonly" means it will only connect to visible APs in the preferred list

# "forcepreferred" means it will forceably connect to APs in order if it does not find

# them in a scan

# "forcepreferredonly" means it forceably connects to the APs in order and does not bother

# to scan

# "forceany" does the same as forcepreferred + connects to any other available AP

# Default is "any"

#associate_order="any"

#associate_order_eth0="any"

# You can define blacklisted Access Points in the same way

#blacklist_aps=( "ESSID 1" "ESSID 2" )

#blacklist_aps_eth0=( "ESSID 3" ESSID 4" )

# If you have more than one wireless card, you can say if you want

# to allow each card to associate with the same Access Point or not

# Values are "yes" and "no"

# Default is "yes"

#unique_ap="yes"

#unique_ap_eth0="yes"

# IMPORTANT: preferred_only, blacklisted_aps and unique_ap only work when

# essid_eth0 is not set and your card is capable of scanning

# NOTE: preferred_aps  list ignores blacklisted_aps - so if you have

# the same ESSID in both, well, you're a bit silly :p

##############################################################################

# ADVANCED CONFIGURATION

#

# Two functions can be defined which will be called surrounding the

# associate function.  The functions are called with the interface

# name first so that one function can control multiple adapters.

#

# The return values for the preassociate function should be 0

# (success) to indicate that configuration or deconfiguration of the

# interface can continue.  If preassociate returns a non-zero value, then

# interface configuration will be aborted.

#

# The return value for the postassociate function is ignored

# since there's nothing to do if it indicates failure.

#preassociate() {

#       # The below adds two configuration variables leap_user_ESSID

#       # and leap_pass_ESSID. When they are both confiugred for the ESSID

#       # being connected to then we run the CISCO LEAP script

#

#       local user pass

#       eval user=\"\$\{leap_user_${ESSIDVAR}\}\"

#       eval pass=\"\$\{leap_pass_${ESSIDVAR}\}\"

#

#       if [[ -n ${user} && -n ${pass} ]]; then

#               if [[ ! -x /opt/cisco/bin/leapscript ]]; then

#                       eend "For LEAP support, please emerge net-misc/cisco-aironet-client-utils"

#                       return 1

#               fi

#               einfo "Waiting for LEAP Authentication on \"${ESSID//\\\\//}\""

#               if /opt/cisco/bin/leapscript ${user} ${pass} | grep -q 'Login incorrect'; then

#                       ewarn "Login Failed for ${user}"

#                       return 1

#               fi

#       fi

#

#       return 0

#}

#postassociate() {

#       # This function is mostly here for completeness... I haven't

#       # thought of anything nifty to do with it yet ;-)

#       # Return 0 always

#       return 0

#}
```

super long so I guess I could have missed something.

now that it is up this is what iwconfig reads.

```
DavidCPU ~ # iwconfig

lo        no wireless extensions.

ra0       RT2500 Wireless  ESSID:"linksys"

          Mode:Managed  Frequency=2.462 GHz  Access Point: 00:13:10:8D:0A:00

          Bit Rate=54 Mb/s   Tx-Power:-3 dBm

          RTS thr=2312 B   Fragment thr=2312 B

          Encryption key:off

          Link Quality=93/100  Signal level=-36 dBm  Noise level:-193 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

```

----------

