automatically restart dhcp6c when it crashes?

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Advanced Networking
Author Message
dholth
DD-WRT Novice


Joined: 07 Jan 2011
Posts: 5

PostPosted: Sat Jul 27, 2019 14:25    Post subject: automatically restart dhcp6c when it crashes? Reply with quote
I've been having reliability problems with ipv6 and a new cable modem. I noticed dhcp6c had crashed. Restarting just dhcp6c from the command line seemed to restore connectivity.

How can I have dd-wrt restart dhcp6c when it crashes? Can I have it run under a process manager or put a cron job on my usb storage to check it?
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 3764
Location: Netherlands

PostPosted: Sat Jul 27, 2019 17:02    Post subject: Reply with quote
I do not have IPv6 so can not write a script for you but there is the ping6 command so a script would look something like this, but I do not even know if dhcp6c is a service so just guessing, but this would give you a start.
(I use this kind of script to check my VPN tunnel and restart VPN when the tunnel is down)

Code:

(
logger "Start $(basename $0)"

SLEEP=300 # time (in secs) between each pass

while sleep $SLEEP; do
   logger "sleep $SLEEP $(basename $0)"
   while ! ping6 -c1 -w3 google.com > /dev/null 2>&1; do
       logger "$(basename $0) IPv6 is down, DHCPc6 will be restarted"
       stopservice dhcp6c
       startservice dhcp6c
   done
done
)2>&1 | logger -t $(basename $0)[$$]


Note not tested anything, just to give you an idea and there are probably better/smarter solutions Smile

_________________
Routers:Netgear R7800, Netgear R6400v1, Netgear R6400v2, Linksys EA6900 (XvortexCFE), Linksys E2000 (converted WRT320N), WRT54GS v1.
Install guide Linksys EA6900: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=291230
Simple PBR (Policy Based Routing) script: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318662
Install guide R6400v2:http://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
OpenVPN server setup guide:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318795
Install guide R7800: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
dholth
DD-WRT Novice


Joined: 07 Jan 2011
Posts: 5

PostPosted: Sat Jul 27, 2019 22:20    Post subject: I think that will work Reply with quote
Thanks! I did not know about stopservice / startservice which must be a special dd-wrt thing, running the C code that applies nvram configuration to the various services. Those commands do work to stop and start dhcp6c.

For my script, instead of a ping I will try running
Code:
ip -6 route | grep default via
to make sure the router still knows where to forward ipv6 packets, or just use `ps` to make sure dhcp6c is still running.
dholth
DD-WRT Novice


Joined: 07 Jan 2011
Posts: 5

PostPosted: Tue Aug 13, 2019 14:54    Post subject: automatically restart dhcp6c when it crashes (script) Reply with quote
/opt/bin/check_dhcp6c.sh

Code:
#!/bin/sh
grep -q dhcp6c /proc/[0-9]*/comm || (stopservice dhcp6c; startservice dhcp6c)


/opt/etc/cron.d/check_dhcp6c

Code:
*/1 * * * * root /opt/bin/check_dhcp6c.sh


Startup script in web interface

Code:
ln -s /opt/etc/cron.d/* /etc/cron.d/


radvd and dhcp6s (advertising ipv6 for the lan) seem to react when dhcp6c starts or stops. There appears to be no slack time between stopping dhcp6c and losing connectivity.
portsup
DD-WRT User


Joined: 20 Oct 2018
Posts: 58

PostPosted: Tue Aug 13, 2019 22:18    Post subject: Reply with quote
If you look at the cron section I posted here https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320733
you can adapt it to what you need.

I recommend just restarting the whole router regularly. Under the tabs administration/keep alive you can find the sttings the schedule reboots
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum