Posted: Thu Aug 18, 2016 19:20 Post subject: Send notification if public IP for router changed
Hello,
I have VPN server set up on my dd-wrt router. The public router ip does not change usually. However, in case that ISP assigns a new IP address to my router, can I get immediate notification with new IP address information by email or other method so I can update the ip address on my remote client? Thanks
Joined: 18 Mar 2014 Posts: 12917 Location: Netherlands
Posted: Thu Aug 18, 2016 19:38 Post subject: Re: Send notification if public IP for router changed
Maybe someone can come up with an easier solution but you can setup a dynamic DNS with ddwrt.
Then let the DNS provider notify you when the IP address changes
newnews wrote:
Hello,
I have VPN server set up on my dd-wrt router. The public router ip does not change usually. However, in case that ISP assigns a new IP address to my router, can I get immediate notification with new IP address information by email or other method so I can update the ip address on my remote client? Thanks
Posted: Thu Aug 18, 2016 21:30 Post subject: Re: Send notification if public IP for router changed
egc wrote:
Maybe someone can come up with an easier solution but you can setup a dynamic DNS with ddwrt.
Then let the DNS provider notify you when the IP address changes
newnews wrote:
Hello,
I have VPN server set up on my dd-wrt router. The public router ip does not change usually. However, in case that ISP assigns a new IP address to my router, can I get immediate notification with new IP address information by email or other method so I can update the ip address on my remote client? Thanks
Creating a simple script to get the wan_ipaddr from nvram and compare it to a text file with last known IP address saved seems simple enough:
1. nvram get wan_ipaddr
2. get wan_ipaddr.txt
3. if they are equal, exit
4. if they are different, alert and exit.
The sendmail portion I know is possible as well, but I've not done that myself as I don't want to have my email password saved in a conf file somewhere. I guess if you created an email address specific for these alerts, that wouldn't be so bad. _________________ R7000 Nighthawk - DD-WRT v3.0-r50308
R7000 Nighthawk - DD-WRT v3.0-r50308
~~~~~~~~~~Dismantled for learning opportunities~~~~~~~~~~
WRT54Gv2
WRT54Gv8.2
~~~~~~~~~~Other Settings~~~~~~~~~
https://nextdns.io/?from=2d3sq39x https://pi-hole.net/ https://github.com/DNSCrypt/dnscrypt-proxy
Creating a simple script to get the wan_ipaddr from nvram and compare it to a text file with last known IP address saved seems simple enough:
1. nvram get wan_ipaddr
2. get wan_ipaddr.txt
3. if they are equal, exit
4. if they are different, alert and exit.
The sendmail portion I know is possible as well, but I've not done that myself as I don't want to have my email password saved in a conf file somewhere. I guess if you created an email address specific for these alerts, that wouldn't be so bad.
Is your DDWRT connected directly to the Web or does it have a LAN connection to your ISP Router?
If directly connected, the solution above is the best way.
Sending a mail message can be done by (if no password is required):
Code:
echo "Subject: DDWRT WAN IP Change" | cat - <some text file as body> | sendmail -f<from email> -d"<domain from email>" -S<smtp server>:<tcp port> <to email address>
If DDWRT is not connected to the Web directly, the best way probably is to use some external server that returns your public IP address. For example:
Code:
PubIP=$(wget -T 10 https://ipinfo.io/ip -qO -)
Compare the stored and the received address and if not equal, store the new address in a file and send a message. _________________ Netgear WNDR4300v1 DD-WRT v3.0 BS r29837 | Netgear R6400 DD-WRT v3.0 KB r33525M | Tickets: 5429 IPv4 & IPv6-PD | ProFTP & Samba to USB thumb | DNSMasq DHCPv6 | Pi-Hole on RasPi
Creating a simple script to get the wan_ipaddr from nvram and compare it to a text file with last known IP address saved seems simple enough:
1. nvram get wan_ipaddr
2. get wan_ipaddr.txt
3. if they are equal, exit
4. if they are different, alert and exit.
The sendmail portion I know is possible as well, but I've not done that myself as I don't want to have my email password saved in a conf file somewhere. I guess if you created an email address specific for these alerts, that wouldn't be so bad.
Thanks, do you have other alert option other then email?
Creating a simple script to get the wan_ipaddr from nvram and compare it to a text file with last known IP address saved seems simple enough:
1. nvram get wan_ipaddr
2. get wan_ipaddr.txt
3. if they are equal, exit
4. if they are different, alert and exit.
The sendmail portion I know is possible as well, but I've not done that myself as I don't want to have my email password saved in a conf file somewhere. I guess if you created an email address specific for these alerts, that wouldn't be so bad.
Is your DDWRT connected directly to the Web or does it have a LAN connection to your ISP Router?
If directly connected, the solution above is the best way.
Sending a mail message can be done by (if no password is required):
Code:
echo "Subject: DDWRT WAN IP Change" | cat - <some text file as body> | sendmail -f<from email> -d"<domain from email>" -S<smtp server>:<tcp port> <to email address>
If DDWRT is not connected to the Web directly, the best way probably is to use some external server that returns your public IP address. For example:
Code:
PubIP=$(wget -T 10 https://ipinfo.io/ip -qO -)
Compare the stored and the received address and if not equal, store the new address in a file and send a message.