Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject:
PostPosted: Thu Aug 13, 2009 7:34 pm 
Offline
Senior Member

Joined: Fri Sep 21, 2007 4:12 pm
Posts: 78
Just to add an option...

Install BIND, configure it as your authoritative master for the domain. Have linode host your domain, and transfer it from your linode.

Then, configure BIND to do dynamic updates.

http://linux.yyz.us/nsupdate/
http://linux.yyz.us/nsupdate/nsupdate-man.html

This gives you full remote administration of every record under the sun, not (typically) just A records, in addition to running over :53/udp and direct to the name server as opposed to :80/tcp to the webserver to the auth layer to name server.

It may be a little more complicated than a wget, but it is easily scriptable and infinitely more flexible.

Or, in short, "roll your own dynamic DNS" :)


Top
   
 Post subject:
PostPosted: Wed Aug 26, 2009 8:14 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
This requires wget on your Linode and your ssh session to come via the IP you want to show. DomainID and ResourceID can be obtained using domain.list and domain.resource.list.

Code:
ssh you@yourlinode "wget -O - -q https://api.linode.com/?api_key=$LINODE_API_KEY\&api_action=domain.resource.update\&domainid=$DOMAINID\&resourceid=$RESOURCEID\&target=\`echo \$SSH_CLIENT | cut -d' ' -f1\`"


(Please see http://gist.github.com/175969 to make sure all the quotes, backslashes, backticks, dollarsigns, and ampersands didn't get eaten by the forum.)

The SSH_CLIENT variable is set by sshd and expanded on the server side; LINODE_API_KEY, DOMAINID, and RESOURCEID need to be set locally (or replaced with the actual values, depending on sense of adventure).

This has a nonzero chance of causing death or serious injury.


Top
   
 Post subject:
PostPosted: Wed Aug 26, 2009 8:26 pm 
Offline
Senior Member

Joined: Thu Aug 28, 2003 12:57 am
Posts: 273
Thanks to Caker, the feature I have requested is now in the Linode API. If you specify the Target parameter as "[remote_addr]" in a domain.resource.update request, then the host entry will be updated using the IP address that you have made the request from.


Top
   
 Post subject:
PostPosted: Wed Aug 26, 2009 9:52 pm 
Offline
Senior Member

Joined: Thu Aug 28, 2003 12:57 am
Posts: 273
Just to give some more explicit instructions in case anyone needs to know the exact requests needed to do dynamic dns:

First, you have to create a Domain Zone under the Linode DNS Manager.

Next, find out what the ID is of this domain:

Code:
wget -qO- https://api.linode.com/?api_key="<your_key>"\&api_action=domain.list | sed 's/,/\n/g'


Find your domain's ID in this output.

Next, find out what the ID of the DNS entry is:

Code:
wget -qO- https://api.linode.com/?api_key="<your_key>"\&api_action=domain.resource.list\&DomainID="<your_domain_id>" | sed 's/},/}\n/g'


Find your DNS entry's ID in this output.

Finally, once you know <your_domain_id> and <your_resource_id>, you can use the following command to dynamically update your DNS entry using the IP address of the requester, at any time:

Code:
wget -qO- https://api.linode.com/?api_key="<your_key>"\&api_action=domain.resource.update\&DomainID="<your_domain_id>"\&ResourceID="<your_resource_id>"\&Target="[remote_addr]"


Have fun.


Last edited by bji on Thu Aug 27, 2009 1:44 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Thu Aug 27, 2009 11:50 am 
Offline
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
bji wrote:
Just to give some more explicit instructions in case anyone needs to know the exact requests needed to do dynamic dns:


Thanks so much for this. I tried it out and it works perfectly.

Now that I have the last line built, does it seem unreasonable to run this from cron on daily basis?


Last edited by glg on Thu Aug 27, 2009 3:39 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Thu Aug 27, 2009 1:47 pm 
Offline
Senior Member

Joined: Thu Aug 28, 2003 12:57 am
Posts: 273
glg wrote:
bji wrote:
Just to give some more explicit instructions in case anyone needs to know the exact requests needed to do dynamic dns:


Thanks so much for this. I tried it out and with one minor correction it works perfectly. In the second command, you're missing a closing " after the domain ID.


Glad to be of service, and thanks for the correction - I've fixed it in my post so it won't bite anyone in future.

Quote:
Now that I have the last line built, does it seem unreasonable to run this from cron on daily basis?


I think it's perfectly reasonable - in fact, it's what I'm doing as well.

Also, you might want to run it on system start up as well, especially if you're running behind a cable modem like I am. After a power outage, the cable modem will often get a new IP address, and since after a power outage my server has gone down as well, I find it to be a good time to update the dynamic dns entry, just in case the IP has changed.


Top
   
 Post subject:
PostPosted: Thu Aug 27, 2009 3:41 pm 
Offline
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
bji wrote:
Glad to be of service, and thanks for the correction - I've fixed it in my post so it won't bite anyone in future.


Cool, I removed mine to not confuse things. You could copy that to a new post in the tips/tricks group...

bji wrote:
Quote:
Now that I have the last line built, does it seem unreasonable to run this from cron on daily basis?


I think it's perfectly reasonable - in fact, it's what I'm doing as well.

Also, you might want to run it on system start up as well, especially if you're running behind a cable modem like I am. After a power outage, the cable modem will often get a new IP address, and since after a power outage my server has gone down as well, I find it to be a good time to update the dynamic dns entry, just in case the IP has changed.


Yeah, I'm on a cable modem, that's a good call.


Top
   
 Post subject:
PostPosted: Tue Nov 24, 2009 10:23 pm 
Offline
Senior Newbie

Joined: Sun Nov 08, 2009 4:31 am
Posts: 15
Just writing a quick note to say thanks everyone for the brilliant posts. This helped me ALOT.

-M


Top
   
 Post subject: My implementation
PostPosted: Mon Nov 30, 2009 2:21 pm 
Offline

Joined: Fri Oct 24, 2008 12:40 pm
Posts: 1
Website: http://www.cnysupport.com
Location: Syracuse, NY
If you have a web server running on your linode and another location on a Dynamic DNS, and would like to update linode's DNS without logging in via ssh, here's my implementation.

The script compares the current WAN IP to the previous WAN IP and only updates when necessary.

The BBCode editor seems to be mangling the code, so it's probably going to be easier to just pick it up on my website:

http://www.cnysupport.com/index.php/lin ... ate-script

Have fun!

Terry


-------------------------------
This is a PHP script that returns the IP address of the client. Create this file in the web root on your web server.

Save As: MyIP.php
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
-------------------------------
This is a shell script that runs on the remote (dynamic) machine. Name it anything you like and put it /etc/cron.hourly.

Change the variables to reflect your settings.

It only updates the DNS when your WAN IP has actually changed.

You can pick up this entire document without any weird formatting at: http://www.cnysupport.com/Linode_DDNS.txt

#!/bin/sh

LINODE_API_KEY=your linode key
DOMAIN_ID=your domain id
RESOURCE_ID=your resource id
WAN_IP=`wget -O - -q http://www.sampledomain.com/MyIP.php`

OLD_WAN_IP=`cat /var/CURRENT_WAN_IP.txt`


if [ "$WAN_IP" = "$OLD_WAN_IP" ]; then
echo "IP Unchanged"
else
echo $WAN_IP > /var/CURRENT_WAN_IP.txt
wget -qO- https://api.linode.com/?api_key="$LINODE_API_KEY"\&api_action=domain.resource.update\&DomainID="$DOMAIN_ID"\&ResourceID="$RESOURCE_ID"\&Target="$WAN_IP"
fi



--------------------------


Top
   
 Post subject: Re: My implementation
PostPosted: Mon Nov 30, 2009 11:40 pm 
Offline
Senior Member

Joined: Thu Aug 28, 2003 12:57 am
Posts: 273
tpcarmen wrote:
If you have a web server running on your linode and another location on a Dynamic DNS, and would like to update linode's DNS without logging in via ssh, here's my implementation.


Hello. What do you mean "without logging in via ssh"? The recipe that was posted previously in this thread does not require ssh and does not require a PHP script on your web server. Can you explain again what the benefit is of doing it the way you suggest instead of the recipe that was given earlier? Thanks.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group