ipFire behind LIWEST cable modem in bridging mode - getting no RED ip

Hello,
I was notified of this thread because someone linked to the thread I raised years ago. I still have the problem that I reported there, so I worked around it with the following script.

This is saved as /usr/local/bin/pingcheck.sh and linked in to the /etc/fcron.minutely/ directory.

#!/bin/bash
#
########################################################################
# Begin
#
# Description : Gateway ping check
#
# Authors     : DNL
#
# Version     : 01.20
#
# Notes       : Designed to run regularly from cron. Restarts red0
#               network if unable to ping ISP's router.
#
########################################################################

PING_TIMEOUT=5
MAX_RETRIES=4
ATTEMPT=0

# Don't run in the first 120 seconds after IPFire has booted
if [[ $( cut -d'.' -f1 /proc/uptime ) -gt 120 ]]; then

	RED_TYPE=$(grep RED_TYPE /var/ipfire/ethernet/settings | cut -d'=' -f2)
	REMOTE_IP=$(cat /var/ipfire/red/remote-ipaddress)

	if [[ "$RED_TYPE" == "DHCP" ]]; then
		while [[ $ATTEMPT -le $MAX_RETRIES ]]; do
			if ping -q -c 1 -w $PING_TIMEOUT "${REMOTE_IP}" &>/dev/null
			then
				# Connection is up - exit quietly
				exit 0
			else
				ATTEMPT=$(( ATTEMPT+1 ))
				sleep $PING_TIMEOUT
			fi
		done
		logger -p local0.info -t pingcheck.sh[$$] "Unable to ping upstream router. Restarting RED connection"

		# try `connscheduler reconnect` first instead of restarting the network. -  sadly it does not work for me.
		#/usr/local/bin/connscheduler reconnect > /dev/null
		/etc/init.d/network stop
		# DEBUG logger -p local0.info -t pingcheck.sh[$$] "Stopping red connection returned $?"
		# DEBUG logger -p local0.info -t pingcheck.sh[$$] "Starting red connection"
		/etc/init.d/network start

	fi
fi

This cron job has run on my system since that thread years ago and has proven to be reliable.
EDIT: @arne_f 's tip of running connsheduler reconnect sadly does not work at all for me, so I have resorted back to a full network stop/start. Perhaps the problem I have is related to what the connscheduler script does?

Thanks for the tip about modifying the timeout in /var/ipfire/dhcpc/dhcpcd.conf @bonnietwin . EDIT: I tried it just now at 120 and it still failed to work. Two minutes seems like a very long time, but given that connscheduler reconnect fails for me perhaps I have another issue.

3 Likes