You are not logged in.

#1 2008-09-19 01:06:08

Black Mage
Member
Registered: 2008-09-17
Posts: 32

[Solved] iwlist rarely shows an AP that stands near the device

This one is either weird, wrong or i have done something completly wrong. im not sure the problem is in wpa_suplicant.

i have a room with a wireless router, its a small room, i usually use my laptop inside the room so its very close, and when visible the signal is always above 90/100.

the network used to be WEP encrypted, i used the simple configure in rc.conf to initialise it with the string (dont mind syntax mistakes if any)
wlan_eth1=(wlan eth1 essid whatever key whatever)
eth1=dhcp

everything always workedand the network would be connected quite fast, since i had no problems i didnt use iwlist scan at all (and when i use it i use it with sudo BTW)
but i assume that if it wouldnt have shown in the scan it probably would create connection problems (correct me please if im wrong)

my first change was moving to netcfg, i was trying to create several profiles, everything workd, and the profile that related to the previous connection was always the one connected to
when availble.

my second and third change (wich i guess one or two of them is the source of the problem) where made on the same time.
i discovered that to have a general configuration to any awailble network, i would have to create a profile that use wpa_supplicant.
and since i read the man and info about wpa i moved my network to it (could it create detection problems?)
the settings where WPA2-Personal with AES

i now used one profile in netcfg that gave wpa the power to connect
wpa would have for now to settings, a general to connect to any awailble network and a wpa one, the wpa with highest priority

i did manage to connect to my wpa network and got working internet after some plays around with the file and holding fingers, so the connection settings are at least somewhat correct.

Last edited by Black Mage (2008-09-24 16:01:27)

Offline

#2 2008-09-19 01:17:04

Black Mage
Member
Registered: 2008-09-17
Posts: 32

Re: [Solved] iwlist rarely shows an AP that stands near the device

[vleon@Old-Death-Machine ~]$ lspci | grep 2200
02:03.0 Network controller: Intel Corporation PRO/Wireless 2200BG Network Connection (rev 05)

/etc/rc.conf
http://pastebin.com/m57331576

/etc/network.d/Network
http://pastebin.com/m352e49f5

/etc/wpa_supplicant.conf
http://pastebin.com/m6d70c469

if any other info is needed just ask smile

thanks in advance for all those who try to help.
if you happen to know and can clear this up please tell me wether iwlist scan is somehow scanning throw wpa_supplican when use and with wnet-tools otherwise (or something like that i dont know how the underline mechanism works).

Offline

#3 2008-09-19 11:03:37

Black Mage
Member
Registered: 2008-09-17
Posts: 32

Re: [Solved] iwlist rarely shows an AP that stands near the device

i now suspect its got something to do with netcfg actually, without netcfg connecting to my netwok was flwless
and it worked great, iwlist also didnt have problems with showing resolts.

i also checked ilist scan when used without netcfg+wpa_supplicant and it showd good resolts.

when i assocciated the essid to my wpa essid and ran wpa_supplicant and then use netcfg it worked fine, including iwlist scan

now when i did not use iwconfig eth1 essid leonet
and had any other essid used it shown this in the wpa_supplicant output:

0: 00:14:bf:de:84:f9 ssid='Leonet' wpa_ie_len=0 rsn_ie_len=20 caps=0x11
   skip - blacklisted
1: 00:1b:9e:a7:70:ce ssid='SIEMENS-A770CE' wpa_ie_len=0 rsn_ie_len=0 caps=0x11
   skip - privacy mismatch
2: 00:11:50:5e:f0:29 ssid='Caspi' wpa_ie_len=0 rsn_ie_len=0 caps=0x11
   skip - privacy mismatch
3: 00:16:e3:94:fa:11 ssid='SIEMENS-Roman' wpa_ie_len=0 rsn_ie_len=0 caps=0x11
   skip - privacy mismatch
4: 52:1b:9e:a7:70:cf ssid='NELU-PC' wpa_ie_len=0 rsn_ie_len=0 caps=0x1
   skip - blacklisted

Note the Leonet is my wpa essid, the one im tryin to get working
NELU-PC is my neighboor wich has the strongest signal after mine
always above 85/100 quality

im considering to delete this topic and open a more speciffic one, but i want to track dows the problem a bit before i do that.

Offline

#4 2008-09-21 23:17:58

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: [Solved] iwlist rarely shows an AP that stands near the device

Hi BlackMage, I don't understand 100% of your problem report. But I took a look at your config files and see some loose ends and problems.

Loose ends: in your /etc/rc.conf file, I'd "!" out the network daemon. You don't need to run both it and netcfg (=net-profiles). In fact I expect the network daemon won't be doing any work the way your rc.conf file is right now. But it'll help keep things clean down the road. In general, you don't want to run both network and netcfg (=net-profiles). (You COULD do so safely, if you had them controlling separate interfaces; but that would be an unusual way to do things.)

The gateway and ROUTES settings are for the network daemon, so you could comment them out. But they're doing no harm.

In your "Network" profile, it looks like you have no SECURITY setting active. Remove the comment character before "SECURITY=wpa-config" and do a:

sudo /etc/rc.d/net-profiles restart

As to whether you wpa_supplicant.conf file has enough info, I don't know. That depends on your setup. You might try leaving netcfg out of the equation for a bit, and work at getting to the point where you can manually bring up your interface (using "sudo ifconfig eth1 up" or something like that), associate it with your access point (using "sudo iwconfig mode managed essid Leonet" or something like that), and then autheticate using wpa_supplicant.

To do the last, you can run the command-line interface "wpa_cli" in one terminal, and edit your "wpa_supplicant.conf" file in a second terminal. After saving the config file, tell wpa_cli to "reconfigure" and it will  reload the .conf file and try again to authenticate. You can type "status" in wpa_cli to see what's currently going on.

When the wpa_supplicant.conf file is set up properly, then the second manual step I cited above--using iwconfig---won't be necessary. wpa_supplicant should automatically associate with and authenticate against the first network it sees that has the highest priority. But at the start of troubleshooting, I'd try to associate with iwconfig to help narrow in on what stage things might be going wrong.

If your Leonet network is really WEP, then I think the wpa_supplicant.conf file you already have may be fine. If it's WPA, though, as you say at another point in your messages, then you may need to add extra lines. Try adding in:

proto=WPA
key_mgmt=WPA-PSK
scan_ssid=1

Offline

#5 2008-09-22 15:21:03

Black Mage
Member
Registered: 2008-09-17
Posts: 32

Re: [Solved] iwlist rarely shows an AP that stands near the device

Hi thanks for the good answer i actually worked on this a lot yesterday and found out the problem to be wpa_supplicant ap scanning. on the first two tries it
finds only one interface (probably the first unenctypted one with the highest setting), it makes eveything work but it doesnt connect to my ap by default (until i do a couple of iwlist eth1 scan)

wgwn changing ap_scan to "2" my interface shows up well and essid is assigned to it, but dhcp doesnt work, nothing else works actually.
i do use a wpa encryption btw.

i tried some combinations to make it work:
netcfg
autowifi
modifying the network daemon.

the third was the only thing that worked, it seems that the first two didnt let wpa_supplicant continue scanning for interfaces.

i actually had to learn bash scripting to modify my daemon, and asked in the irc if it would be usefull to someone but peopele there kept saying its uncessery without giving
me a good enough reason (im not implying there isnt one)

anyway here's my modified /etc/rc.d/network:
http://pastebin.com/m35028d02

i highlited the lines i added
if someone wants to use it for some reason please backup your currect file, unless you know what youre doing!

it basiclly adds the option to start wpa_supplicant on your device, make sure your /etc/wpa_supplicant.conf works

my new rc.conf looks like that:
http://pastebin.com/m2b50ce72

note the three highlited lines, you should use dhcp if you need it
you can assign iwconfig values before wpa_supplicant is started (my assignes essid)
the syntax bassicly states that you add the arguments you would to a regular wpa_supplicant invocation.
-B is probably the most important, in order for network to use wpa you need to have at least one argument.

Offline

#6 2008-09-23 15:53:07

tigrmesh
IRC Op
From: Florida, US
Registered: 2007-12-11
Posts: 794

Re: [Solved] iwlist rarely shows an AP that stands near the device

Wonderful that you fixed it.  Please mark this thread as solved (edit your first post).  That way, others with using wpa can find help easily.

Also, would you please post your modified rc.conf and /etc/rc.d/network in code blocks in this thread?  That way they'll be available even after the pastebin expires.

Thanks!  smile

Offline

#7 2008-09-24 16:00:07

Black Mage
Member
Registered: 2008-09-17
Posts: 32

Re: [Solved] iwlist rarely shows an AP that stands near the device

allright, so i "solved" the problem with three modifications, two of the mentioned above, and another
one is a simple bash app that is ran with crontab every minute (making sure i have internet connection
and that im connected to the right essid if its availble).

Before i paste the code i want to point out that im new to bash scripting, those are my first scripts and they are
probably not perfect, use at your own risk, bake up files unless you know what you are doing, and if you have suggestions of improvment please paste them here or send me an email to vleon1@gmail.com.

The new Network Daemon (comments are plased before and after the lines that i added):

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

# wireless settings
[ -f /etc/conf.d/wireless ] && . /etc/conf.d/wireless
# ethernet bonding settings
[ -f /etc/conf.d/bonding ] && . /etc/conf.d/bonding
# bridge settings
[ -f /etc/conf.d/bridges ] && . /etc/conf.d/bridges
# dhcpcd settings
[ -f /etc/conf.d/dhcpcd ] && . /etc/conf.d/dhcpcd

ifup()
{
    if [ "$1" = "" ]; then
        echo "usage: $0 ifup <interface_name>"
        return 1
    fi

    wi_up $1 || return 1

## start
    wpa_up $1 || return 1
## end

    eval ifcfg="\$${1}"
    if [ "$ifcfg" = "dhcp" ]; then
        # remove the .pid file if it exists
        /bin/rm -f /var/run/dhcpcd-${1}.pid >/dev/null 2>&1
        /bin/rm -f /var/run/dhcpcd-${1}.cache >/dev/null 2>&1
        /sbin/dhcpcd $DHCPCD_ARGS ${1}
    else
        /sbin/ifconfig $ifcfg
    fi
    return $?
}

wi_up()
{
    eval iwcfg="\$wlan_${1}"
    [ "$iwcfg" = "" ] && return 0

    /usr/sbin/iwconfig $iwcfg
    
##start
    eval wpacfg="\$wpa_${1}"
    if [ "$wpacfg" = "" ]; then
##end
    
        [[ -z "$WIRELESS_TIMEOUT" ]] && WIRELESS_TIMEOUT=2
        sleep $WIRELESS_TIMEOUT
    
        bssid=`iwgetid $1 -ra`
        if [[ "$bssid" = "00:00:00:00:00:00" ]]; then
            printhl "Could not associate $1 - try increasing WIRELESS_TIMEOUT and check network is WEP or has no security"
            return 1
        fi

##start    
    fi
##end

    return 0
}

##start
wpa_up()
{
    eval wpacfg="\$wpa_${1}"
    [ "$wpacfg" = "" ] && return 0

    /usr/sbin/wpa_supplicant $wpacfg

    return 0
}
##end

ifdown()
{
    if [ "$1" = "" ]; then
        echo "usage: $0 ifdown <interface_name>"
        return 1
    fi

##start    
    eval wpacfg="\$${1}"
    if [ "$wpacfg" != "" ]; then
        /usr/sbin/wpa_cli -i $1 terminate >/dev/null
    fi
##end
    
    eval ifcfg="\$${1}"
    if [ "$ifcfg" = "dhcp" ]; then
        if [ -f /var/run/dhcpcd-${1}.pid ]; then
            /bin/kill $(cat /var/run/dhcpcd-${1}.pid)
        fi
    fi
    # Always bring the interface itself down
    /sbin/ifconfig ${1} down >/dev/null 2>&1
    return $?
}

iflist()
{
    for ifline in ${INTERFACES[@]}; do
        if [ "$ifline" = "${ifline#!}" ]; then
            printf " $ifline:\t"
        else
            printf "$ifline:\t"
        fi
        eval real_ifline=\$${ifline#!}
        echo $real_ifline
    done
}

rtup()
{
    if [ "$1" = "" ]; then
        echo "usage: $0 rtup <route_name>"
        return 1
    fi
    eval routecfg="\$${1}"
    if grep -q :: <<< $routecfg; then
            /sbin/route -A inet6 add $routecfg
    else
            /sbin/route add $routecfg
    fi
    return $?
}

rtdown()
{
    if [ "$1" = "" ]; then
        echo "usage: $0 rtdown <route_name>"
        return 1
    fi
    eval routecfg="\$${1}"
    if grep -q :: <<< $routecfg; then
            /sbin/route -A inet6 del $routecfg
    else
            /sbin/route del $routecfg
    fi
    return $?
}

rtlist()
{
    for rtline in ${ROUTES[@]}; do
        if [ "$rtline" = "${rtline#!}" ]; then
            printf " $rtline:\t"
        else
            printf "$rtline:\t"
        fi
        eval real_rtline=\$${rtline#!}
        echo $real_rtline
    done
}

bond_up()
{
    for ifline in ${BOND_INTERFACES[@]}; do
        if [ "$ifline" = "${ifline#!}" ]; then
            eval bondcfg="\$bond_${ifline}"
            /sbin/ifenslave $ifline $bondcfg || error=1
        fi
    done
}

bridge_up()
{
    for br in ${BRIDGE_INTERFACES[@]}; do
        if [ "$br" = "${br#!}" ]; then
            # if the bridge already exists, remove it
            if [ "$(/sbin/ifconfig $br 2>/dev/null)" ]; then
                /sbin/ifconfig $br down
                /usr/sbin/brctl delbr $br
            fi
            /usr/sbin/brctl addbr $br
            eval brifs="\$bridge_${br}"
            for brif in $brifs; do
                if [ "$brif" = "${brif#!}" ]; then
                    /usr/sbin/brctl addif $br $brif || error=1
                fi
            done
        fi
    done
}

bridge_down()
{
    for br in ${BRIDGE_INTERFACES[@]}; do
        if [ "$br" = "${br#!}" ]; then
            /usr/sbin/brctl delbr $br
        fi
    done
}


case "$1" in
    start)
        if ! ck_daemon network; then
            echo "Network is already running.  Try 'network restart'"
            exit
        fi

        stat_busy "Starting Network"
        error=0
        # bring up bridge interfaces
        bridge_up
        # bring up ethernet interfaces
        for ifline in ${INTERFACES[@]}; do
            if [ "$ifline" = "${ifline#!}" ]; then
                ifup $ifline || error=1
            fi
        done
        # bring up bond interfaces
        bond_up
        # bring up routes
        for rtline in "${ROUTES[@]}"; do
            if [ "$rtline" = "${rtline#!}" ]; then
                rtup $rtline || error=1
            fi
        done
        if [ $error -eq 0 ]; then
            add_daemon network
            stat_done
        else
            stat_fail
        fi
        ;;
    stop)
        #if ck_daemon network; then
        #    echo "Network is not running.  Try 'network start'"
        #    exit
        #fi

        stat_busy "Stopping Network"
        rm_daemon network
        error=0
        for rtline in "${ROUTES[@]}"; do
            if [ "$rtline" = "${rtline#!}" ]; then
                rtdown $rtline || error=1
            fi
        done
        for ifline in ${INTERFACES[@]}; do
            if [ "$ifline" = "${ifline#!}" ]; then
                ifdown $ifline || error=1
            fi
        done
        # bring down bridge interfaces
        bridge_down
        if [ $error -eq 0 ]; then
            stat_done
        else
            stat_fail
        fi
        ;;
    restart)
        $0 stop
        /bin/sleep 2
        $0 start
        ;;
    hotplug_ifup|ifup|ifdown|iflist|rtup|rtdown|rtlist)
        $1 $2
        ;;
    *)
        echo "usage: $0 {start|stop|restart}"  
        echo "       $0 {ifup|ifdown|iflist|rtup|rtdown|rtlist}"
esac

# vim: set ts=2 noet:

The new rc.conf (i paste all of it to avoid confusions for new arch users, the relevant part starts and end with
a comment):

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime"
# USEDIRECTISA: use direct I/O requests instead of /dev/rtc for hwclock
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.utf8"
HARDWARECLOCK="localtime"
USEDIRECTISA="no"
TIMEZONE="Asia/Jerusalem"
KEYMAP="us"
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MOD_BLACKLIST: Prevent udev from loading these modules
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
#
MOD_AUTOLOAD="yes"
#MOD_BLACKLIST=() #deprecated
MODULES=(!tsdev acpi-cpufreq cpufreq_ondemand 3c59x mii slhc ipw2200 ac97_bus snd-mixer-oss snd-pcm-oss snd-page-alloc snd-pcm snd-timer snd snd-ac97-codec snd-intel8x0 snd-intel8x0m soundcore)

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="Old-Death-Machine"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
# 
# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below

##start
eth0="dhcp"
eth1="dhcp"
wlan_eth1="eth1 essid Leonet" #< note that the options here are used if you want for example preset an essid
wpa_eth1="-B -Dwext -ieth1 -c/etc/wpa_supplicant.conf" #< it gives wpa_supllicant argument, must have
#at least one argument to work, and you would probably want the -B argument anyway (rus wpa in the 
#background"

INTERFACES=(!eth0 eth1)
##end

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)
 
# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#

#NETWORKS=(Network)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#

##note that the network daemon should be in daemons..
DAEMONS=(syslog-ng crond cpufreq acpid hal network netfs samba alsa gpm keytouch)

The script that would be run with crontab:

#!/bin/bash

#Check if there is a connection:
bssid=`iwgetid eth1 -ra`
if [[ "$bssid" = "00:00:00:00:00:00" ]]; then
    /etc/rc.d/network restart >/dev/null 2>&1
fi

#Check if I am connected to my AP. if not, knock three times to makes sure im home :P
essid=`iwgetid eth1 -r`
if [ "$essid" != "Leonet" ] ; then
    #A dirty and lazy hack, wpa_supplicant has some bug, the interface sits near the laptop but coulf
    #be ignored for up to three scans. but once it scans OK we are good to go.
    scan=`iwlist eth1 scan | grep "Leonet"`
    scan=`iwlist eth1 scan | grep "Leonet"`
    scan=`iwlist eth1 scan | grep "Leonet"`
        #The above is a hack, the AP doesnt always show in the first or second scan, so we use four scans
        #to make sure, the bug is in wpa_supplicant if im not mistaken
    if [ "$scan" != "" ] ; then
        /etc/rc.d/network restart >/dev/null 2>&1
        essid=`iwgetid eth1 -r`
    fi
fi

you should run the next line with root privivlegs, usually with sudo:

crontab -e

add a line like this to the new file:

*/1 * * * * /usr/bin/tweaks

replace 1 with the number of minutes you want to pass beetwen invocations of the scrip
and replace /usr/bin/tweaks with the place you put the script in
dont forget to make the script executable with

chmod +x /the/scripts/dir

Last edited by Black Mage (2008-09-24 17:19:17)

Offline

Board footer

Powered by FluxBB