LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Wireless Networking (https://www.linuxquestions.org/questions/linux-wireless-networking-41/)
-   -   running script to bring up wireless card (https://www.linuxquestions.org/questions/linux-wireless-networking-41/running-script-to-bring-up-wireless-card-440918/)

jschiwal 05-05-2006 07:57 PM

A problem some people have is that their regular NIC interface is set to start on boot. This might cause a conflict. I set my NIC interface (eth0) to start on connection and my wireless interface to start on boot.

dlennon 05-07-2006 12:35 PM

I am running Fedora 5 and I don't see the abilty to start on conncetion anywhere. In network manager, it only gives you the place to check for starting on boot, which in my case did not work

short101 05-12-2006 05:02 AM

check out /etc/sysconfig/network-scripts/ifcfg-(etho, and ath0) look for an auto bit in the eth0 one (or whatever your wired iface is) and disable the auto. Then eneable it for the wireless interface. There shoould be docs for it somewhere. Seeing as your card actually works, i would suggest asking in the forum for your distro on how to do this correctly.

michael.guerrero 10-22-2006 09:46 AM

There could be another reason your card is not starting up on boot, because I had the same problem, and I run FC5 and ndiswrapper.

The problem I was finding is that NICs are only given 5 seconds to make a link with the access point, and then the "no link present, check cable?" message comes on and the device is shut down--so you won't see it as up in ifconfig.

I'm using a Belkin N5d7050 with 128b WEP encryption, and 5 seconds is just way to short for it to establish the link. It takes my card between 30 and 40 seconds to get a link, so I needed to extend the time the system gives it.

The timeout for checking if there's a link is controlled by a function called check_link_down() in the file /etc/sysconfig/network-scripts/network-fuctions (Fedora Core 5).

The way it works is the script ifup-eth (etc/sysconfig/network-scripts) calls the function check_link_down() which checks your wireless link (wlan0 on my system--wlan is considered an eth device) to see if it is connected to the AP. If there is no link between the card and the AP it fails and you get the "no link present, check cable?" message at boot.

The tool that checks if the link is present is ethtool, and it is called in the check_link_down function.

The wireless card has to sync up to the AP, and if it's encrypted it takes a bit longer (naturally).

So, what I did to make it work was just give the card more time to sync up. Check_link_down() looks like so:

Code:

check_link_down ()
{
    if [ -x /sbin/mii-tool -o -x /sbin/ethtool ]; then
        if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then
          ip link set dev $1 up >/dev/null 2>&1
        fi
        timeout=0
        while [ $timeout -le 10 ]; do
            check_mii_tool $1
            m=$?
            check_ethtool $1
            e=$?
            if [ $m -eq 1 ] || [ $e -eq 1 ] ; then
                return 1
            fi
            if [ $m -eq 2 ] && [ $e -eq 2 ] ; then
                return 1
            fi
            usleep 500000
            timeout=$((timeout+1))
        done
        return 0
    fi
    return 1
}

So, what you can see from that is we have a timeout counter ($timeout), which increments up to 10 times. If we get to 10 and the link still isn't present then we've timed out and we get the fail message.

Looking further down, we see usleep 500000. That means we wait for .5 seconds each time we loop through the while statement to give the link a chance to sync up.

If you multiply 10 tries by .5 seconds a try, you find out your wireless card only has 5 seconds to sync up with the access point. This is not enough time for my card.

My fix was easy, I just changed the usleep 500000 (.5 seconds) to usleep 5000000 (5 seconds).

Don't worry, you won't have to wait the entire 50 seconds because the while loop has a return statement that breaks the loop if the link is present. You only have to wait long enough for ethtool to see a good link (mine ususally takes 7 passes through to get sync'd up). Once it sees the link, it will break the loop and continue to boot as normal.

jevin 04-10-2007 10:23 AM

is there any way that i can edit the check_link_down () part of the network-functions file to run a script everytime the link comes up?

i want to run a script everytime that a link is detected as up.
thanks,

Jevin

michael.guerrero 04-10-2007 04:25 PM

It is a shell script, so if you have root privilages, you can edit it. Then you can call another shell script from within that function if you like.


All times are GMT -5. The time now is 08:38 PM.