Thaaaat is what I have right now, I believe. And yeah, it works great, but it also costs money. I might keep it anyway, but I'd thought it be fun to dive in to some alternative ways of solving this...tpyo kingg wrote: ↑Tue Sep 24, 2019 12:59 pmAnother way is to subscribe to a dynamic DNS service. It might be part of your current DNS subscription, or it may be an add on, o ryou might need to do it completely separately.
Once you have dynamic DNS, you can install and configure the package ddclient. That will phone home to the service and update your address in their register. The end result is that you can then SSH to a host name and it will automatically go to your current address.
Let me be your imagination..I can't really think of any other way of reporting it back than email.
Hmmmm, a free DDNS might be all I need actually. Any recommendations? Is https://duckdns.org reliable?tpyo kingg wrote: ↑Tue Sep 24, 2019 1:14 pmThere are also free-of-charge dynamic DNS options. The service noip.com has one. There are lists of them around. You'll have to read the terms of service to see if that one or anything like that is acceptable. At best you have to renew the free trial every month. It might be least work to keep paying like you have.
If you are just looking to find the IP address before leaving the Raspberry Pi, then you might just have it look up its external address and show that on an LCD or e-paper display. I've done that with an Inky PHat. It's ok as long as you remember to check before leaving and, depending on the ISP, it might not change too often.
Code: Select all
#!/usr/bin/python3 import logging import sys from subprocess import PIPE, run if len(sys.argv) > 1: if sys.argv.upper() == 'DEBUG': log_level = logging.DEBUG elif sys.argv.upper() == 'INFO': log_level = logging.INFO else: log_level = logging.INFO else: log_level = logging.INFO logging.basicConfig(filename='/home/pi/IP-change.log',level=log_level, datefmt='%Y/%m/%d %H:%M:%S', format='%(asctime)s %(message)s') pwd = "https://api.dynu.com/nic/update?hostname=example.com&password=longcomplexstringgoeshere" update = run(['curl', pwd], stdout=PIPE, stderr=PIPE) logging.debug('Program executed under debug logging') logging.debug('Return code = ' + str(update.returncode)) logging.debug('Return Data = ' + update.stdout.decode()) if update.returncode > 0: logging.warning('Curl failed with code ' + str(update.returncode)) if update.stdout.decode() != 'nochg': logging.info('IP address change - ' + update.stdout.decode())
I use duckdns. It's very simple to set up and not too hard to update it with an HTTP request when your public IP changes. (I use a Node-Red flow to update it automatically)
Code: Select all
#!/bin/bash IPv4=$(dig +short myip.opendns.com \@resolver1.opendns.com | grep -v -e '^$' || echo "0.0.0.0")