Discussion

Correct way to re-enable dropped internet connection

7 3325
ljones  
Post Last Edited by ljones at 2014-9-21 08:45

Hello all! :-)

Ok just writing here to see if anyone can help me out with this at all. Right now I'm in the process of trying to turn my banana pi (bought about a week ago) into a small server. The distro I'm using is the default bananian distro. First of all though I should mention a couple of device I'm using with the b-pi;

- USB Ethernet adapter (chipset ASIX AX88772)
- USB Wifi adapter (chipset AR9271)

I know the b-pi has built-in ethernet btw however I recall reading that the allwinner a10/a20 chipsets don't have full speed ethernet, or the driver isn't 100% That's why I chose a USB device btw.

Anyway the good news is that what I've done so far seems to work. I can securely connect to the b-pi with SSH; it runs a piece of blogging software ("flatpress" (also uses php5)); it works as a web server (lighttpd), and finally works as a wireless access point (using hostapd). I can see the blog load ok and interact with it, I can see the web server running, connect via wifi to the b-pi no problems. I didn't need to install iptables or change /etc/sysctl.conf.

The internet (via ethernet) is connected via USB (eth1); the wifi connector shows up ok as wlan0 and a wireless bridge I've created shows up again ok as br0.

The one issue I am having (and was expecting x.x) is that after what seems to be a random amount of time the internet connection drops. It could seeming happen at any time -- the longest time I've had the connection "up" was for a little over 24 hours; after that it dropped. By "dropped" I mean (for example) use a normal desktop PC then try to look at the blog for example (simply by issuing the b-pi's IP address into a web browser) and nothing happens; also cannot ping the b-pi's IP address. The only way to restore the connection is to pull the usb power cable out from the power supply, wait a few moments then put it back in.

I did come up with this way to try to check if the connection was "up" and then reconnect after 5 tries:

/root/reconnect

  1. #!/bin/sh
  2. #

  3. if=eth0

  4. if [ -e "count.var" ]
  5. then
  6. :
  7. else
  8. echo 0 > count.var
  9. fi

  10. count=`cat count.var`

  11. if ping -c 1 192.168.0.1 | grep "Unreachable"; then
  12. ifconfig eth1 down
  13. ifconfig eth1 up
  14. ifconfig wlan0 down
  15. ifconfig wlan1 up
  16. count=$((count+1))
  17. echo $count > count.var
  18. else
  19. :
  20. # date >> /root/date1.txt
  21. exit
  22. fi

  23. if [ $count -eq 5 ] then
  24. count=0
  25. rm count.var
  26. echo "**fail" >> /root/date1.txt
  27. shutdown -r now
  28. exit
  29. fi

  30. $ chmod +x /root/reconnect
Copy the Code
and in /etc/crontab added:

  1. */1 * * * * root /root/reconnect
Copy the Code
This runs (though since I don't know 'when' the next drop will be I'll have to wait and see if it drops!) but the only snag is this almost seems like a "bodge". You know as if I'm sort of not doing something quite right. Does anyone know if there's a "correct" procedure to use if an internet connection drops at all?

The odd thing though is that I also have a dreamplug here which I'm in the process of replacing (the dreamplug is fine, I have no problems with it less higher power usage) and the b-pi has x2 memory (512mb over 1GB ) and a faster CPU. Though strangely the dreamplug dosen't drop at all -- not once yet it is not doing anything much different with regards to software than what I've stated above (eg not using iptables).

BTW I understand there are programs such as wicd though they can't really be used if you're configuring network devices manually and using software such as hostapd and wireless bridges (br0).

So I wonder then apart from the hardware what's the software on the dreamplug doing that the software on the b-pi isn't doing? Is there some sort of extra command or config file or something I can compare?

ljones
Raymond  
b-pi has Giga Ethernet built onboard.  Maybe you need to try onboard Giga Ethernet and manual fix the IP address as a good alternative.

ljones  
Post Last Edited by ljones at 2014-9-22 10:25

No luck x.x Well I did try manually setting the IP address but it still ended up dropping, and didn't seem to reconnect either. So prehaps my script dosen't work (not sure). Only thing I can think of is some sort of power management thing going on (wifi power management is *disabled* btw) maybe for the A20 CPU itself or a missing or not-quite-right config file.

BTW I am also thinking it is possible the on board ethernet will not work for me as hostapd only works with certian ethernet adapters.

ljones

ljones  
Currently still monitoring the server, so far it is still "up". Maybe it was just a bad connection somewhere (will keep watching it all).

ljones

pgk  
BTW I am also thinking it is possible the on board ethernet will not work for me as hostapd only works with certian ethernet adapters.
ljones Posted at 2014-9-22 10:22


I thought the restriction was on the wireless interface side, not the wired side. Don't know why you have an impression of problems with the onboard ethernet generally.

Throughput reported by some seems pretty good - http://forum.lemaker.org/redirect.php?goto=findpost&ptid=5457&pid=26412&fromuid=13207

Compared to the USB 2 max of 480mbps, which won't be achievable I'd have thought the onboard is generally going to be a better option.

ljones  
Well I'll give that a go later :-) . Though in the end I managed to get a much better uptime as I did two things -- first thing was I changed the file /etc/sysctl.conf and removed  two lines about vm.swappiness and vm.vfs_cache. The other thing I did was to go right back and try to rewrite the /etc/network/interfaces file. After that it kept going for just over a week, only reason it stopped is because I switched it off, reconstructed (with the same config files) on another card and put it on (just now!).

If this keeps going it might all be solved.

ljones

Hi!

I'd advise using the gbit onboard, works flawless. That having said, connect an ssd, only boot from sd, possibly unmount /boot when ready.

The wifi usb interface might be improved with this trick:
backup /etc/ifplugd/action.d/ifupdown and replace the content with (copied somewhere, from someone, dont credit me):
(shell script content between ===== )
=====================
#!/bin/sh

#####################################################################
## Purpose
# This file is executed by ifupdown in pre-up, post-up, pre-down and
# post-down phases of network interface configuration. It allows
# ifup(8), and ifdown(8) to manage wpa_supplicant(8) and wpa_cli(8)
# processes running in daemon mode.
#
# /etc/wpa_supplicant/functions.sh is sourced by this file.
#
# This file is provided by the wpasupplicant package.

#####################################################################
# Copyright (C) 2006 - 2009 Debian/Ubuntu wpasupplicant Maintainers
# <pkg-wpa-devel@lists.alioth.debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# On Debian GNU/Linux systems, the text of the GPL license,
# version 2, can be found in /usr/share/common-licenses/GPL-2.

if [ -n "$IF_WPA_MAINT_DEBUG" ]; then
        set -x
fi

# quit if we're called for the loopback
if [ "$IFACE" = lo ]; then
        exit 0
fi

# allow wpa_supplicant interface to be specified via wpa-iface
# useful for starting wpa_supplicant on one interface of a bridge
if [ -n "$IF_WPA_IFACE" ]; then
        WPA_IFACE="$IF_WPA_IFACE"
else
        WPA_IFACE="$IFACE"
fi

# source functions
if [ -f /etc/wpa_supplicant/functions.sh ]; then
        . /etc/wpa_supplicant/functions.sh
else
        exit 0
fi

# quit if executables are not installed
if [ ! -x "$WPA_SUP_BIN" ] || [ ! -x "$WPA_CLI_BIN" ]; then
        exit 0
fi

do_start () {
        if test_wpa_cli; then
                # if wpa_action is active for this IFACE, do nothing
                ifupdown_locked && exit 0

                # if the administrator is calling ifup, say something useful
                if [ "$PHASE" = "pre-up" ]; then
                        wpa_msg stderr "wpa_action is managing ifup/ifdown state of $WPA_IFACE"
                        wpa_msg stderr "execute \`ifdown --force $WPA_IFACE' to stop wpa_action"
                fi
                exit 1
        elif ! set | grep -q "^IF_WPA"; then
                # no wpa- option defined for IFACE, do nothing
                exit 0
        fi

        # ensure stale ifupdown_lock marker is purged
        ifupdown_unlock

        # preliminary sanity checks for roaming daemon
        if [ -n "$IF_WPA_ROAM" ]; then
                if [ "$METHOD" != "manual" ]; then
                        wpa_msg stderr "wpa-roam can only be used with the \"manual\" inet METHOD"
                        exit 1
                fi
                if [ -n "$IF_WPA_MAPPING_SCRIPT" ]; then
                        if ! type "$IF_WPA_MAPPING_SCRIPT" >/dev/null; then
                                wpa_msg stderr "wpa-mapping-script \"$IF_WPA_MAPPING_SCRIPT\" is not valid"
                                exit 1
                        fi
                fi
                if [ -n "$IF_WPA_MAPPING_SCRIPT_PRIORITY" ] && [ -z "$IF_WPA_MAPPING_SCRIPT" ]; then
                        wpa_msg stderr "\"wpa-mapping-script-priority 1\" is invalid without a wpa-mapping-script"
                        exit 1
                fi
                IF_WPA_CONF="$IF_WPA_ROAM"
                WPA_ACTION_SCRIPT="/sbin/wpa_action"
        fi

        # master function; determines if ifupdown.sh should do something or not
        if [ -n "$IF_WPA_CONF" ] && [ "$IF_WPA_CONF" != "managed" ]; then
                if [ ! -s "$IF_WPA_CONF" ]; then
                        wpa_msg stderr "cannot read contents of $IF_WPA_CONF"
                        exit 1
                fi       
                WPA_SUP_CONF_CTRL_DIR=$(sed -n -e 's/[[:space:]]*#.*//g' -e 's/[[:space:]]\+.*$//g' \
                        -e 's/^ctrl_interface=\(DIR=\)\?\(.*\)/\2/p' "$IF_WPA_CONF")
                if [ -n "$WPA_SUP_CONF_CTRL_DIR" ]; then
                        WPA_CTRL_DIR="$WPA_SUP_CONF_CTRL_DIR"
                        WPA_SUP_CONF="-c $IF_WPA_CONF"
                else
                        # specify the default ctrl_interface since none was defined in
                        # the given IF_WPA_CONF
                        WPA_SUP_CONF="-c $IF_WPA_CONF -C $WPA_CTRL_DIR"
                fi
        else
                # specify the default ctrl_interface
                WPA_SUP_CONF="-C $WPA_CTRL_DIR"
        fi
}

do_stop () {
        if test_wpa_cli; then
                # if wpa_action is active for this IFACE and calling ifdown,
                # do nothing
                ifupdown_locked && exit 0
        elif test_wpa_supplicant; then
                # wpa_supplicant process exists for this IFACE, but wpa_cli
                # process does not. Allow stop mode to kill this process.
                :
        else
                exit 0
        fi
}

case "$MODE" in
        start)
                do_start
                case "$PHASE" in
                        pre-up)
                                kill_wpa_supplicant
                                init_wpa_supplicant        || exit 1
                                conf_wpa_supplicant         || { kill_wpa_supplicant; exit 1; }
                                ;;
                        post-up)
                                init_wpa_cli                 || { kill_wpa_supplicant; exit 1; }
                                ;;
                esac
                ;;

        stop)
                do_stop
                case "$PHASE" in
                        pre-down)
                                kill_wpa_cli
                                ;;
                        post-down)
                                kill_wpa_supplicant
                                ;;
                        *)
                                wpa_msg stderr "unknown phase: \"$PHASE\""
                                exit 1
                                ;;
                esac
                ;;
       
        *)
                wpa_msg stderr "unknown mode: \"$MODE\""
                exit 1
                ;;
esac

exit 0
====================

Cheers!

PS
wget http://www.badeend.nl/ifupdown
probably saves you from typing/typos

You have to log in before you can reply Login | Sign Up

Points Rules