An alternative to DDNS

 

# An alternative to DDNS
#
# What if you want to access your local home server from the internet but have a dynamic ip address?
# Typically you use dynamic domain name resolution (ddns) for this. There are serveral providers out
# there offering you a ddns subdomain. However, you have to create an account, spent money or accept
# limitations of the provider.
#
# So, here an alternative:
# – Create a Google Formular containing one input field: your ip address.
# – From your local server, determine your current external ip address (e.g. by retrieving it from
# a website).
# – Whenever your ip changes, paste it to your google formular.
# – Now, you only have to store/know a permanent link to your google sheet to read the current ip of
# your home server.
# – The python script below implements the idea. Feel free to run it on your home server.
#
# – Dependencies: Python, curl, google account
# – Usage: Make sure to edit the variables formular_url and field_name according to your formular.
#!/usr/bin/env python
import subprocess
import time
if __name__ == '__main__':
# The url to the formular
formular_url = 'https://docs.google.com/forms/d/1POTEbzxEou_ZKpMM6M*************K5fNrkFX4/formResponse'
# Inspect the source code of your Google Formular website to get the name of your field
field_name = 'entry.1461371975'#my example
old_ip = ''
while True:
try:
current_ip = subprocess.check_output(['curl', 'ipecho.net/plain'])
if old_ip != current_ip:
subprocess.call(['curl', '–data', field_name + '=' + current_ip, formular_url])
old_ip = current_ip
except Exception as e:
pass
time.sleep(10*60)

view raw
ip_notify.py
hosted with ❤ by GitHub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s