Difference between revisions of "Bering-uClibc 6.x - User Guide - Basic Configuration - Email Alerts"
From bering-uClibc
Line 7: | Line 7: | ||
=== This email gets sent when the router IP address changes === | === This email gets sent when the router IP address changes === | ||
− | + | Using sendmail: | |
− | https://www.snbforums.com/threads/notifications-e-mail.8190/page-8#post-267789 | + | |
+ | look for the code in: | ||
+ | https://www.snbforums.com/threads/notifications-e-mail.8190/page-8#post-267789 | ||
+ | [code] | ||
+ | Code: | ||
+ | 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 | ||
+ | firewall# | ||
+ | [/code] | ||
+ | |||
+ | |||
+ | Using curl: | ||
+ | |||
+ | 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 |
Revision as of 18:24, 9 July 2018
Note
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:
This email gets sent when the router IP address changes
Using sendmail:
look for the code in: https://www.snbforums.com/threads/notifications-e-mail.8190/page-8#post-267789
[code]
Code: 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 firewall#
[/code]
Using curl:
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