Skip to content

Instantly share code, notes, and snippets.

Created March 28, 2017 18:27
What would you like to do?
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 = '*************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:
current_ip = subprocess.check_output(['curl', ''])
if old_ip != current_ip:['curl', '--data', field_name + '=' + current_ip, formular_url])
old_ip = current_ip
except Exception as e:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment