Why would you do this?
Here is one example. This is my use case.
At home, my WAN connection is DHCP and I have multiple uplinks. So my external IP changes quite a bit.
I use DDNS when connecting to my VPN server at home. When I’m at work or school, I type vpn.mydomain.com in my VPN client. I don’t have to worry about my IP changing at home.
Prerequisites
- You need a domain from simply.com.
This guide is based on their API. - You need a Linux server available inside your network.
- This guide is not for lazy people. I make you do a lot of the work yourself 😉
Step 1. Create Python script that updates the A record.
from requests import get
import os
command = "curl -s -u \"ACCOUNTNAME:PASTE_YOUR_API_KEY_HERE\" \"https://api.simply.com/2/ddns/?domain=YOUR_DOMAIN&hostname=THE_A_RECORD\""
print(command)
stream = os.popen(command)
output = stream.read()
print(output)
# Example on how to construct the curl command
command = "curl -s -u \"ACCOUNTNAME:nFTort8fghjjYXDEIQds45u8\" \"https://api.simply.com/2/ddns/?domain=apple.com&hostname=vpn\""
print(command)
Step 2. Use Cron to automatically run the script
For this idea to make sense, you want your server to run this script every x minutes.
With linux, this is very easy.
Btw crontab -e uses vim by default. Here is a guide on how to change that: link.
Open your shell and type “crontab -e”.
Cronjob template:
15 * * * * /usr/bin/python full_path_to_your_script >/dev/null 2>&1
This means the script will run every hour when the clock is xx:15.>/dev/null 2>&1
means the output of the cronjob gets deleted. By default, you get a mail every time the cronjob runs.
This is a calculator for the time settings: link.
Step 3. Done
This is not the most thorough guide in the world. If you want me to add something to the guide or need help. Feel free to write a comment or contact me.