2

Just set up ubuntu server, which has a dynamic ip. I am looking for a way to keep my dns server updated. Im using entrydns to do this and they provide the following command to update the server.

curl -k -X PUT -d "" https://entrydns.net/records/modify/TOKEN

What I need is a way of checking whether the ip has changed so I can update the dns server.

7

It would be better to make a script that gets triggered any time the network configuration changes, and have that script unconditionally update DNS. If you're using Network Manager, such a script can go in /etc/NetworkManager/dispatcher.d -- see networkmanager(8) for details.

If you're not using network-manager, /etc/dhcp/dhclient-enter-hooks.d might be more appropriate.

Then you won't have to poll anything.

| improve this answer | |
4

Something like this would do:

#!/bin/bash

# "${0%.sh}.myip" transforms /path/to/script.sh to /path/to/script.myip
if [[ ! -s "${0%.sh}.myip" ]]; then echo "0.0.0.0" > "${0%.sh}.myip"

newip=$(curl -k -X PUT -d "" https://entrydns.net/records/modify/TOKEN)

read oldip < "${0%.sh}.myip"
echo $newip > "${0%.sh}.myip"

if [[ $newip != $oldip]]; echo "IP changed"; fi
| improve this answer | |
2

There might be a simpler way if you can live with a small delay in updating your IP and if there is not a limit on how often you can make updates to your record on entrydns.net

If this command works for updating entrydns.net then just put in in crontab and configure it to run at a set interval.

curl -k -X PUT -d "" https://entrydns.net/records/modify/TOKEN
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.