Difference between revisions of "Bering-uClibc 6.x - User Guide - Basic Configuration - Email Alerts"

From bering-uClibc
Jump to: navigation, search
Line 5: Line 5:
  
 
==Email notification example using your own ISP SMTP server:==
 
==Email notification example using your own ISP SMTP server:==
 +
If your ISP provides you with an email account, using their SMTP server to send notification emails is the simplest method since most will only require a simple authentication username & password. Some might use TLS/SSL in which case you will need to get a certificate. In any case check your ISP SMTP server requirements. If you have a Google account, you can use their SMTP server.
 +
 +
For these emails to get out you will have to add these rules to <code class="filename">/etc/shorewall/rules</code>
 +
 +
# pour les mails de Videotron....
 +
SMTP(ACCEPT)    fw      net
 +
ACCEPT          fw      net    tcp 587
 +
ACCEPT          fw      net    tcp 465
  
 
=== This email gets sent when the router IP address changes ===
 
=== This email gets sent when the router IP address changes ===
The script is saved as <code class="filename">/etc/cron.daily/mailIP</code> so it is executed daily at 06:41. It will check if the IP has changed.  
+
The script is saved as <code class="filename">/etc/cron.daily/mailIP</code> so it is executed daily at 06:42. It will check if the IP has changed.  
  
 
*Using sendmail:  
 
*Using sendmail:  
  
  look for the code in:
+
  The code can be found in this forum, along with many other hints...
 
  https://www.snbforums.com/threads/notifications-e-mail.8190/page-8#post-267789  
 
  https://www.snbforums.com/threads/notifications-e-mail.8190/page-8#post-267789  
 
   
 
   
Line 43: Line 51:
 
   sendmail -S relais.videotron.ca:587 </tmp/MyIP1.log -froot@firewall -auxxxxxxxx -apyyyyyyyy blablabla@gmail.com
 
   sendmail -S relais.videotron.ca:587 </tmp/MyIP1.log -froot@firewall -auxxxxxxxx -apyyyyyyyy blablabla@gmail.com
 
   fi
 
   fi
firewall#
+
 
 +
 
  
  
Line 49: Line 58:
 
*Using curl: replace the sendmail stanza with this one:
 
*Using curl: replace the sendmail stanza with this one:
  
   curl --url smtps://smtp.videotron.ca:465 --mail-from root@firewall --mail-rcpt blablabla@gmail.com    --upload-file /tmp/MyIP1.log --ssl-reqd --user xxxxxxxx:yyyyyyyy --insecure -v
+
   curl --url smtps://smtp.videotron.ca:465 --mail-from root@firewall --mail-rcpt blablabla@gmail.com    --upload-file /tmp/MyIP1.log --ssl-reqd --user xxxxxxxx:yyyyyyyy --insecure
 +
 
 +
You want to get an email every week, IP changes or not !!!
 +
 
 +
add this script to <code class="filename">/etc/cron.weekly/mailIP_week</code>
 +
 
 +
firewall# cat mailIP_week
 +
  #!/bin/sh
 +
  #
 +
  # PURPOSE: e-Mail me my external IP toutes les semaines...
 +
  #  si ca marche bien deplace dans cron.monthly
 +
  #
 +
  echo '' > /tmp/MyIP.log
 +
  #
 +
  #
 +
you get the picture...

Revision as of 21:58, 10 July 2018

Note, work in progress...

These examples are not using the Bering-uClibc builtin email notification found in the master configuration file

[ lrcfg... 2) system configuration... 1) Master LRP settings... ]

Email notification example using your own ISP SMTP server:

If your ISP provides you with an email account, using their SMTP server to send notification emails is the simplest method since most will only require a simple authentication username & password. Some might use TLS/SSL in which case you will need to get a certificate. In any case check your ISP SMTP server requirements. If you have a Google account, you can use their SMTP server.

For these emails to get out you will have to add these rules to /etc/shorewall/rules

# pour les mails de Videotron....
SMTP(ACCEPT)    fw       net
ACCEPT          fw       net    tcp 587
ACCEPT          fw       net    tcp 465

This email gets sent when the router IP address changes

The script is saved as /etc/cron.daily/mailIP so it is executed daily at 06:42. It will check if the IP has changed.

  • Using sendmail:
The code can be found in this forum, along with many other hints...
https://www.snbforums.com/threads/notifications-e-mail.8190/page-8#post-267789 


firewall# cat mailIP
  #!/bin/sh
  #
  # transmet l'adresse ip quand il change...
  #
  #
  IPNOW=$(ip addr | grep 255.255. | sed -n 's/^ *inet *\([.0-9]*\).*/\1/p')
  if grep -q $IPNOW /tmp/MyIP.log
  then
  echo "No change"
  else
  echo $IPNOW > /tmp/MyIP.log
  echo "Subject: l'adresse IP aujourd'hui: $IPNOW !!! " > /tmp/MyIP1.log
  echo "From: root@firewall" >> /tmp/MyIP1.log
  echo "Date:  `date -R`" >> /tmp/MyIP1.log
  echo "" >> /tmp/MyIP1.log
  echo "Salut mon petit JR..." >> /tmp/MyIP1.log
  echo "" >> /tmp/MyIP1.log
  echo "nouvel IP:  $IPNOW" >> /tmp/MyIP1.log
  echo "Uptime est: `uptime | cut -d ',' -f1 | sed 's/^.\{12\}//g'`" >> /tmp/MyIP1.log
  echo "" >> /tmp/MyIP1.log
  echo "---- " >> /tmp/MyIP1.log
  echo "de la part de ton gentil Routeur !!!" >> /tmp/MyIP1.log
  echo "" >> /tmp/MyIP1.log
  echo "" >> /tmp/MyIP1.log
  sendmail -S relais.videotron.ca:587 </tmp/MyIP1.log -froot@firewall -auxxxxxxxx -apyyyyyyyy blablabla@gmail.com
  fi



  • Using curl: replace the sendmail stanza with this one:
  curl --url smtps://smtp.videotron.ca:465 --mail-from root@firewall --mail-rcpt blablabla@gmail.com    --upload-file /tmp/MyIP1.log --ssl-reqd --user xxxxxxxx:yyyyyyyy --insecure

You want to get an email every week, IP changes or not !!!

add this script to /etc/cron.weekly/mailIP_week

firewall# cat mailIP_week
 #!/bin/sh
 #
 # PURPOSE: e-Mail me my external IP toutes les semaines...
 #  si ca marche bien deplace dans cron.monthly
 #
 echo  > /tmp/MyIP.log
 #
 #

you get the picture...