auto reconnect after connection lost

Post Reply
Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

auto reconnect after connection lost

Unread post by Dombo71 » Wed Jul 05, 2017 2:25 pm

Dear all.
problem with my Xu4
My router is a bit buggy..
When my isp has a hick in the wan line
My Xu4 does not automatic reconnect with my lan
Is there a option to auto reconnect when there is a connection lose

Now i reboot the xu4 manually and then is working everything fine'
I use armbian on my Xu4

User avatar
odroid
Site Admin
Posts: 29981
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: auto reconnect after connection lost

Unread post by odroid » Wed Jul 05, 2017 3:47 pm

I have no idea about how Armbian network manager handles the Ethernet reconnection.
Post your question on Armbian's forum since most people in this forum are using our official Ubuntu or meveric's Debian OS images.

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Fri Jul 07, 2017 2:53 am

Thanks..

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Wed Mar 07, 2018 6:09 am

Dear all...
I am now running linux server:
Ubuntu 16.04.3 LTS (GNU/Linux 4.14.13-100 armv7l)

When my ISP have a network hik or a other network error. My xu4 i not auto reconnect to my lan, and then there is no internet possible. The things that are only working is a reboot or a power off /?on. Only my other hardware like a Pi or Cubieboard do just reconnect without any problems? So i do not think it is in my router...

So is there perhaps a way to auto reconnect to my lan and perhaps internet. Is there a way to check this connection? So a package or option to auto reconnect. And perhaps a option to check to connection?

Or do you have a other/better solution?

Aks the Odroid they say i need to ask in to this forum..
So please is there no one with this problem???
Or perhaps is there some one that now what i can do with this problem/?/??

A package?
A setting??

I try Dietpi
raspian
now Ubuntu..
All the same problem.
So there must be a hardware problem i think

Please...
Love the speeds of my Xu4
Only for my home automation is the not reconnect a great problem..
All my other boards reconnect without any problem.
CB
PI B
PI 3

so XU4 can do this as well i think..
Thanks for all the support!!

User avatar
rooted
Posts: 6435
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Contact:

Re: auto reconnect after connection lost

Unread post by rooted » Wed Mar 07, 2018 6:45 am

You could run this script from a cron job every few minutes, it's hacky but should work.

Code: Select all

if ! ping -Q 1 -c 1 -t 1 google.com; then ifdown eth0 sleep 3 ifup eth0 fi

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Wed Mar 07, 2018 6:52 am

rooted wrote:You could run this script from a cron job every few minutes, it's hacky but should work.

Code: Select all

if ! ping -Q 1 -c 1 -t 1 google.com; then ifdown eth0 sleep 3 ifup eth0 fi
mmm Thanks..
Hacky do mean it is not the best option bud do the job?

Please give me the good format for the cronjob

I am a bricklayer so not the best scripter...

User avatar
rooted
Posts: 6435
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Contact:

Re: auto reconnect after connection lost

Unread post by rooted » Wed Mar 07, 2018 7:19 am

Hacky meaning it will work but doesn't address why it's happening

Put the script in a file, say we call it "netmon" and you put it in the /home/odroid directory.

First make the script executable

Code: Select all

chmod +x /home/odroid/netmon
Then run:

Code: Select all

crontab -e
And add this:

Code: Select all

5 * * * * /bin/bash /home/odroid/netmon > /dev/null 2>&1
The 5 is minutes, change it to how often you want it to run.

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Thu Mar 08, 2018 5:21 am

mm
In a lua?
Or??

please a example of the file..?
I am a noop with scripting..

User avatar
rooted
Posts: 6435
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Contact:

Re: auto reconnect after connection lost

Unread post by rooted » Thu Mar 08, 2018 5:32 am

Put this in a file named "netmon"

Code: Select all

if ! ping - Q 1 - c 1 - t 1 google . com ; then ifdown eth0 sleep 3 ifup eth0 fi

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Tue Mar 13, 2018 5:59 am

dear..

Please some more info...
Noob here i cannot get uit to work..
Please a aexample document..
Lua or python or??

Hope you wil dot this..
Thanks..

User avatar
rooted
Posts: 6435
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Contact:

Re: auto reconnect after connection lost

Unread post by rooted » Tue Mar 13, 2018 8:08 pm

I can't make it any more easy.

elatllat
Posts: 1175
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1
Contact:

Re: auto reconnect after connection lost

Unread post by elatllat » Wed Mar 14, 2018 12:45 am

Dombo71 rooted did all the work he can for you, if you want to complicate things by using some other language that's up to you.
if you want to understand bash instead of just using what rooted wrote for you, then read the ping manual.

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Wed Mar 14, 2018 3:39 am

rooted wrote:Put this in a file named "netmon"

Code: Select all

if ! ping - Q 1 - c 1 - t 1 google . com ; then ifdown eth0 sleep 3 ifup eth0 fi

OkeOnly this in a file?

Type a lua?
Only what is the head of a lua file?


An then a crontab that part is ok by me.

elatllat
Posts: 1175
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1
Contact:

Re: auto reconnect after connection lost

Unread post by elatllat » Wed Mar 14, 2018 4:33 am

Forget lua; it has 0 advantage, and is missing so much.

Cron will assume sh but you can hint with

Code: Select all

#!/path/to/exe
at the top of the script, and/or you can force it with

Code: Select all

/bin/sh /script.sh
in crontab.

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Sun Mar 18, 2018 8:42 pm

Dear all..
Should this do the tric?
Hope i did something good with your advice...
ScreenShot020.png
ScreenShot020.png (86.1 KiB) Viewed 1110 times
Or what do i wrong..

elatllat
Posts: 1175
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1
Contact:

Re: auto reconnect after connection lost

Unread post by elatllat » Mon Mar 19, 2018 5:21 pm

Use #!/bin/bash as the first line.
Generally sudo in scripts / cron is bad, use the root's crontab instead.

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Tue Mar 20, 2018 5:24 am

Did what you guys say..
Make it from root. [ and remove sudo ]
Only did does not do the trick...

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Sun Mar 25, 2018 6:18 pm

Dear...
There is something missing in the script i think:

Code: Select all

root@odroid:~# cd /home/odroid/domoticz/scripts
root@odroid:/home/odroid/domoticz/scripts# ./netmon.sh
./netmon.sh: line 4: syntax error: unexpected end of file
root@odroid:/home/odroid/domoticz/scripts#
The script:
ScreenShot025.png
ScreenShot025.png (3.81 KiB) Viewed 1002 times

Hope some one can tell me what?

thanks

elatllat
Posts: 1175
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1
Contact:

Re: auto reconnect after connection lost

Unread post by elatllat » Mon Mar 26, 2018 12:00 am

Code: Select all

#!/bin/bash

ping -qnc 1 -t 100 8.8.8.8 > /dev/null
if [ "$?" != "0" ] ; then
    ifdown eth0
    sleep 3
    ifup eth0
fi
Last edited by elatllat on Sun Apr 01, 2018 8:07 am, edited 1 time in total.

Dombo71
Posts: 22
Joined: Wed Jun 14, 2017 3:34 am
languages_spoken: english / duttch
ODROIDs: Xu4 :-)
Contact:

Re: auto reconnect after connection lost

Unread post by Dombo71 » Sun Apr 01, 2018 5:11 am

Please some one can/will help me with this missing part.

thanks from the WAF

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 3 guests