Announcement

Collapse
No announcement yet.

My final solution to my wireless issues

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    My final solution to my wireless issues

    wicd started failing on any of my real networks and the default network manager failed miserably.
    Finally I tried a solution I have been comming up with for some time now using wpa_gui.
    Here are the steps I took for wpa_gui

    sudo apt-get remove wicd
    since I had wicd installed otherwise you need to remove networkmanager using
    sudo apt-get remove network-manager
    then I did
    sudo apt-get install wpagui dhcpcd
    I use dhcpcd because editing dhclient's scripts to get it from taking down the interface is super complicated.

    then I created /etc/wpa_supplicant.conf that looks as follows

    ctrl_interface=/var/run/wpa_supplicant
    ctrl_interface_group=4
    update_config=1
    then I created /etc/wpa_action that looks as follows

    fixresolv()
    {
    DOMAIN=`grep DNSDOMAIN /var/lib/dhcpcd/dhcpcd-$1.info | cut -d\' -f 2`
    HASSEARCH=`grep search /etc/resolv.conf`
    if [ "$HASSEARCH" = "" ] && ! [ "$DOMAIN" = "" ];then
    RESOLV=`cat /etc/resolv.conf`
    echo -e "search $DOMAIN\n$RESOLV" > /etc/resolv.conf
    fi
    }

    case "$2" in
    CONNECTED)
    dhcpcd $1 >> /var/log/wpa_action
    if ! [ -L /etc/resolv.conf ];then
    mv /etc/resolv.conf /etc/resolv.conf.before.dhcpcd
    ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
    fi
    fixresolv $1
    ;;
    DISCONNECTED)
    dhcpcd -k $1 >> /var/log/wpa_action
    if [ -L /etc/resolv.conf ];then
    rm /etc/resolv.conf
    mv /etc/resolv.conf.before.dhcpcd /etc/resolv.conf
    fi
    ;;
    *)
    echo $1 $2 > /tmp/wpa_unknown_action
    ;;
    esac
    then I created /etc/init.d/wpa_supplicant than looks as follows

    interface=`iwconfig 2>/dev/null | grep ESSID | head -n 1| awk '{print $1}'`

    start()
    {
    /sbin/wpa_supplicant -WB -i $interface -c /etc/wpa_supplicant.conf
    /sbin/wpa_cli -B -a /etc/wpa_action
    }

    stop()
    {
    killall -9 wpa_supplicant
    }

    usage()
    {
    echo "$0 start|stop"
    }

    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    *)
    usage
    ;;
    esac
    Since I no longer have a network manager I need some way for when I plug in a wired connection for it to set that up. Here is the script I created to do that.

    fixresolv()
    {
    DOMAIN=`grep DNSDOMAIN /var/lib/dhcpcd/dhcpcd-$1.info | cut -d\' -f 2`
    HASSEARCH=`grep search /etc/resolv.conf`
    if [ "$HASSEARCH" = "" ] && ! [ "$DOMAIN" = "" ];then
    RESOLV=`cat /etc/resolv.conf`
    echo -e "search $DOMAIN\n$RESOLV" > /etc/resolv.conf
    fi
    }

    connected(){
    echo connected
    dhcpcd $1
    if ! [ -L /etc/resolv.conf ];then
    mv /etc/resolv.conf /etc/resolv.conf.before.dhcpcd
    ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
    fi
    }

    dissconnected(){
    echo dissconnected
    dhcpcd -k $1
    if [ -L /etc/resolv.conf ];then
    rm /etc/resolv.conf
    mv /etc/resolv.conf.before.dhcpcd /etc/resolv.conf
    fi
    }

    PRESTATE=" no"
    STATE=" no"

    loop()
    {
    while [ "x" = "x" ]; do
    STATE=`ethtool eth0|grep "Link detected"|cut -d: -f2`
    if ! [ $PRESTATE = $STATE ];then
    PRESTATE=$STATE
    if [ "$STATE" = " no" ];then
    dissconnected $1
    else
    connected $1
    fi
    fi
    sleep 1
    done
    }

    PID=`cat /var/run/wired.pid`
    case "$1" in
    start)
    if ! [ "$PID" = "" ];then
    RUNNING=`ps h -p $PID`
    fi
    if [ "$RUNNING" = "" ];then
    $0 loop
    else
    echo Already running
    fi
    ;;
    loop)
    loop eth0 &
    echo $! > /var/run/wired.pid
    ;;
    stop)
    if ! [ "$PID" = "" ];then
    RUNNING=`ps h -p $PID`
    fi
    if [ "$RUNNING" = "" ];then
    echo Not running
    else
    kill $PID
    fi
    esac

    then I created a file /etc/rc2.d/S50wpa_supplicant and /etc/rc2.d/S50wired that are soft links to /etc/init.d/wpa_supplicant and /etc/init.d/wired

    ln -s /etc/init.d/wpa_supplicant /etc/rc2.d/S50wpa_supplicant
    ln -s /etc/init.d/wired /etc/rc2.d/S50wired
    then I made the script files executable
    chmod a+x /etc/init.d/wpa_supplicant
    chmod a+x /etc/init.d/wired
    chmod a+x /etc/wpa_action
    now wpa_supplicant loads by default and dhcpcd is run every time it connects to a new network.

    As a user I run wpa_gui and it connects to wpa_supplicant and is easy to add new networks to.

    I'm just wondering if there is a better way to do what I did or anything wrong with it?


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

    Known issues: when you are on a large network and in the process of switching access points you probably don't want to run "dhcpcd -k" I'll try and see what happens if I don't.

    #2
    Re: My final solution to my wireless issues

    I suspect that most if not all of the improvement came from using dhcpcd instead of dhclient, but it is hard to argue with success.

    Comment


      #3
      Re: My final solution to my wireless issues

      I may well have mis-read you here but are you saying you had wicd and networkmanager installed at the same time?

      Comment


        #4
        Re: My final solution to my wireless issues

        No. I hate network-manager and remove it even if I am not installing wicd. I am saying that wicd calls a dhcp client to configure the network, and when you have dhclient installed that is what gets called. When you have dhcpcd installed that is what gets called. I suspect that using wicd in conjunction with dhcpcd would work with no problems.

        Comment


          #5
          Re: My final solution to my wireless issues

          Sorry, I was referring to the OP, mando_hacker. I know the 2 cannot co-exist and installation of 1 ought to remove the other. If for some reason that did not happen I suspect that itself might cause the problem.

          Comment


            #6
            Re: My final solution to my wireless issues

            wicd removed network manager I was saying I did not know how to remove network manager without using apt-get to install wicd, since that is what I tried first. But it still royally sucked. It couldn't even connect properly to a non encrypted network at my school. I have had no problems with wpa_gui. I'm still trying to figure out the right way to start wpa_client so that I don't have it wait like it does. However my method as I posted it works a million times better than either wicd or networkmanager. Why couldn't they use wpa_gui as the default it is far better than either wicd or network manager. Also why dhclient instead of dhcpcd dhcpcd seems to work so much better.

            Comment

            Working...
            X