Red don't reconnect after power failure in bridge mode

Hello,

I use a cable modem for internet access in my home and ipfire for home use. Since release 139 and now in 141, whenever there is a power outage, the system does not automatically connect, not receiving an IP from the internet provider. The modem is in bridge mode. The dynamic IP is provided by the internet provider.

I need the system, when restarting automatically, to also connect automatically, even if the modem takes a while. Normally, it works on boot and reconnect automatically, but this time it just show “connecting…”. The problem is that the provider’s modem takes a longer time to start and provide the dynamic IP. Ipfire boots before the modem. So, what can I do on ipfire to resolve the issue? If I’m out, I have no access until I get home. When I get home, I have to force the reconnection by applying a Mac Address and obtaining the Reconnect button.

I see Core 139 won't connect internet but I didn’t see solution there.

I am grateful for the help. Thank you.

Sincerely,

I have not tried this yet but it may help.

There is a watchdog addon in pakfire and it looks like it can monitor a network interface.

https://wiki.ipfire.org/addons/watchdog

Hello Jon,

Thank you for your help.

But I think it’s complicated. If the system can do a test or try to reconnect after a timeout, every time it is not connected, this capability would be good. I will try to implement a script for this. But I think the ipfire system could be more fast to reconnect red0 interface. Before the update to 139/141, the system always did reconection with success after a reboot, but now it’s not working properly.

I wrote this script and put in /etc/fcron.cyclic/reconnect:

#!/bin/bash

RED=$(cat /sys/class/net/red0/operstate)

if [ ! $RED == "up" ]; then
  connscheduler reconnect
else 
  echo "red0 is $RED"
fi 

exit 0

If someone have a better idea, please talk to me. If the above statement is not good, I ask you to help me. I will be very grateful.
:slightly_smiling_face:

2 Likes

Hello people,

Maybe there should be a simple reconnect button here.

Hello,

thanks for this script. :smiley:

I changed a little bit
#### Red don’t reconnect after power failure in bridge mode - #3 by moisesbites

#!/bin/bash
d=date +%Y-%m-%d\/%H:%M
RED=$(cat /sys/class/net/red0/operstate)

if [ ! $RED == “up” ]; then
connscheduler reconnect
else
echo “$d | red0 is $RED”
fi

exit 0

and add a cronjob

reconnect

*/20 * * * * sh /root/cron/reconnect.sh >> /var/log/reconnect.log 2>&1

Hope it worked, i’ll test it now.

now, with some changes, this worked for me at a router from vodafone cable in bridge mode, for reconnect after boot or other errors

#!/bin/bash
d=`date +%Y-%m-%d\/%H:%M:%S`
con=1
RED1=$(cat /sys/class/net/red0/operstate)
RED2=$(cat /sys/class/net/red0/flags)


if [ ! $RED2 == "0x3" ]; then
  echo "$d | red0 is down $RED2 > reconnect"
  con=0
fi

if [ ! $RED1 == "up" ]; then
  echo "$d | red0 is down > reconnect"
  con=0
fi

if [ $con == 1 ]; then
  echo "$d | red0 was up"
fi

if [ $con == 0 ]; then
  /usr/local/bin/connscheduler reconnect
  e=`date +%Y-%m-%d\/%H:%M:%S`
  echo "$e | red0 is up?"
fi

exit 0