Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
4  
Have you alread read: Ubuntu Community Help Wiki: Dynamic DNS? –  Pedro Romano Nov 5 '12 at 11:38

2 Answers 2

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.

share|improve this answer
    
+1 for avoiding polling. Thanks! –  Oliver Moran May 7 '13 at 7:58

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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