Automation of some error conditions

I check the router’s operation quite often and I think it’s unnecessary.

Is it possible to somehow automate the signalling (email) that Storage has failed ??

Similarly, I long for some kind of autoblock of IP addresses in the WAN, from where multiple faulty logins came (like Synology routers have).

1 Like

Your router has a dynamic firewall, if enabled it will block what is defined as suspicious.
Check sentilel and dynamic firewall for detailes.

If you want to auto ban specifics check out fail2ban package.
There is some writing about it here on the forum, e.g.

Adaptive firewall is familiar to me, thank you for reminding me about fail2ban, I will look into it

Now I’m still missing to indicate by email the loss of Storege /srv/ so that one doesn’t have to check the router unnecessarily.

Here it is, @JardaB

script
# TestExtStor.sh: test whether external memory is present (mounted)
# send mail and/or SMS when something is missing
#                                                   (c) jada4p 2023

# send as SMS to my mobile phone via mail to myself and gmail filter
# sending it to my address at post.cz where it is forwarded to mobile
# operator's SMS gate

# it seems that Vodafone terminated possibility of sending SMS by mail

# inspired by @JardaB request and loss of one of USB flash after reboot
# based on use of "df" and some other scripts
# commands 'df | grep "^/dev/s" | wc -l' return '0' when no external
# memory was found, otherwise count of them

# TestExtStor.sh -m send mail
#                -s send SMS
#                -b send both mail and SMS
#                -i display usage

# usage: default mode is "m" - changed from prior 'b' due to troubles
# at Vodafone ISP

M="M"

for i
do
case $i in
-m) #                                                        send mail
    M="M"
    shift
    ;;
-s) #                                                        send SMS
    M="S"
    shift
    ;;
-b) #                                                        send both
    M="B"
    shift
    ;;
-i) #                                                    display usage
    echo "TestExtStor.sh -m send mail"
    echo "               -s send SMS"
    echo "               -b send both mail and SMS"
    echo "               -i display usage"
    echo "default mode is 'm'"
    exit
    ;;
*)  #                                             error, display usage
    if [ "$i" == "" ]
      then continue
      else
           echo "invalid parameter: '$i', usage:"
           /root/TestExtStor.sh -i
           exit
    fi
    ;;
esac
done

C=2                            # number of external storage units used

N=`df | grep "^/dev/s" | wc -l`                      # found N units

if [ $N = $C ]
  then
#      echo "OK - (all) external memory unit(s) found"
       exit
  else
#      echo "BAD - some external memory unit(s) missing"
       MSG=`df`
       SMS="Router TOjp - external storage error"
       if [ "$M" == "B" -o "$M" == "M" ]
         then
#             echo "sending mail"
              echo -e "Subject: $SMS\n\n$MSG" | msmtp root
              if [ "$M" != "M" ]
                then
#                    echo "sending SMS"
                     echo -e "Subject: SMS\n\n$SMS" | msmtp root
              fi
         else
              if [ "$M" == "S" ]
                then
#                    echo "sending SMS"
                     echo -e "Subject: SMS\n\n$SMS" | msmtp root
                else
                     echo "wrong mode $M, see usage"
                     /root/TestExtStor.sh -i
                     exit
              fi
       fi
fi

You have to change value of variable C to correspond count of your units… As to possibility of sending SMS, I have to ask Vodafone where the problem is…