个人工具

“UbuntuHelp:DynamicDNS”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
(未显示2个用户的7个中间版本)
第2行: 第2行:
 
{{Languages|UbuntuHelp:DynamicDNS}}
 
{{Languages|UbuntuHelp:DynamicDNS}}
 
Parent page: [[UbuntuHelp:InternetAndNetworking| Internet and Networking]]
 
Parent page: [[UbuntuHelp:InternetAndNetworking| Internet and Networking]]
== Dynamic DNS ==
+
== Dynamic DNS Introduction ==
Every computer which is attached to the internet has an IP address. DNS is the process of relating a name to an IP address so that a website or other service can be accessed using an easily-remembered named (like 'www.google.com'), rather than a number (like '192.168.0.1').
+
Every computer attached to the Internet has an IP address. [http://en.wikipedia.org/wiki/Domain_Name_System DNS] is the process of relating a [http://en.wikipedia.org/wiki/Uniform_Resource_Locator URL] name (like 'www.google.com') to an [http://en.wikipedia.org/wiki/IP_address IP address] (like '74.125.19.103') so that a website (or other service) on a computer can be accessed using an easily-remembered URL name, rather than the IP address number of the computer. The relationship between a URL and its corresponding IP address is known as a [http://en.wikipedia.org/wiki/Domain_Name_System#DNS_resource_records DNS record].
Most servers on the internet have a fixed IP address that never changes. This means that a 'static' DNS record can be set once such that it always redirects the DNS name to right place.
+
A large number of databases on the Internet (known as [http://en.wikipedia.org/wiki/Name_server DNS name servers]) keep track of these DNS records and exchange the information between each other so that they all are consistent. Every request by a web browser (for a URL) on the Internet is then routed through one of these name servers for resolution to an IP address.  
However, most home users will be assigned a dynamic IP address that will change periodically, or each time they connect to the internet. In the past this made it very difficult to make a home computer accessible from the broader Internet. But with an increasing number of "Dynamic DNS" service providers, this is not such a problem.
+
Most servers on the Internet have a [http://en.wikipedia.org/wiki/IP_address#Static_and_dynamic_IP_addresses fixed (static) IP address] that never changes. This means that a DNS record needs to only be set once in a name server's DNS database, since the URL for that server will always be directed to the same IP address.
Dynamic DNS services offer you a DNS entry with a hostname of your choice. You are then responsible for updating the DNS entry whenver your IP address changes. This pages gives details about how to do that.
+
However, many home users are assigned a constantly changing [http://en.wikipedia.org/wiki/IP_address#Static_and_dynamic_IP_addresses dynamic IP address] by their [http://en.wikipedia.org/wiki/Internet_service_provider ISP]. In the past this has made it difficult for a server on a home computer to be assigned a URL that could be found from the Internet.  
=== Registering with a Dynamic DNS provider ===
+
A number of DNS name servers now offer a method, however, by which a computer with a constantly changing IP address can update a "Dynamic DNS" database using a small software utility on their computer (or directly from their router).
Dynamic DNS requires that a server somewhere on the internet keep track of 'where you are'. That is, it records your host name, and records what the IP address is that corresponds to your hostname.
+
These Dynamic DNS services allow the user to choose a hostname URL and set an initial IP address to correspond to that hostname URL. The software utility on the user's computer (or a router's built-in utility) then periodically checks for a change to the computer's IP address, and when a new IP address is discovered, it updates the Dynamic DNS database to reflect that change.  
Many Dynamic DNS provider offer a free service with a limited range of hostnames to choose from. Paid services will permit a larger selection of hostnames, including use of your own registered domain name.
+
== Registering with a Dynamic DNS provider ==
So before you can get started using Dynamic DNS, you'll need to register with one of these such services. Here is a selection:
+
Dynamic DNS requires that a name server somewhere on the Internet keep track of 'where you are' (i.e. your computer's (or router's) current IP address). That is, its database must always be updated to make sure your hostname URL always corresponds to your current IP address.
* [https://www.dyndns.com/services/dns/dyndns/ dyndns.com]
+
In order to use one of these Dynamic DNS services, registration is required first. Here is a selection of these services:
* [http://www.no-ip.com/getting_started.php no-ip]
+
* [http://www.dyndns.com/support/clients/ DynDNS.com]
* [http://www.zoneedit.com/doc/dynamic.html zoneedit]
+
* [http://www.no-ip.com/getting_started.php No-IP]
* [http://www.easydns.com/dynamicdns.php3 easy DNS]
+
* [http://www.easydns.com/dynamicdns.php3 EasyDNS]
* [http://www.afraid.org Afraid.org] (free)
+
* [http://www.zoneedit.com/doc/dynamic.html#faq1 ZoneEdit]
Upon registering, you will be provided with username and password, as well a hostname that you will be using as the DNS name that will allow external access to your machine.
+
* [http://www.dnspark.com/services/dynamicDNS.php DNSPark]
=== Set up DNS Notification ===
+
* [http://namecheap.simplekb.com/kb.show?show=article&articleid=583&categoryid=11 NameCheap]
Now that you have a DNS provider, you need to set up a way that your IP address will be updated whenever it is changed. There are two ways of doing this:
+
* [http://www.dslreports.com/faq/240 DSLReports]
* using the built-in capabilities of your Cable/DSL modem or Router
+
* [http://freedns.afraid.org/ FreeDNS (Afraid.org)]
* using dynamic DNS software that you install on your computer
+
Upon registering, you will select a username and password, as well as a hostname that you will use as the DNS name (to allow external access to your machine using a URL).
Try first to find out if your modem/router supports Dynamic DNS reporting/notification/updating. If your modem has a built-in 'website' you may find the necessary information by entering its IP address into your browser, for example http://10.1.1.1/ or http://192.168.01/
+
Many Dynamic DNS providers offer a selection of URL hostnames available for free use with their service. However, with a paid plan, any URL hostname (including your own registered domain name) can be used.
However, even if your modem/router does support dynamic DNS reporting, there are cases where you will need to use the second approach: perhaps you modem/router is too old, or perhaps you want the DNS entry to follow your *computer* around, rather than stay with your DSL/Cable connection.
+
== Setting up Dynamic DNS service updates ==
== Using your Computer to perform Dynamic DNS Notification ==
+
Once you have chosen a Dynamic DNS service provider, you need to set up a way that your IP address record will be updated whenever it is changed. There are two ways of doing this:
There are several alternatives. You may need to add the Ubuntu Universe to your set of software repositories. See [[UbuntuHelp:InstallingSoftware|InstallingSoftware]] for all the details.
+
* using a dynamic DNS software utility that is installed on your computer
=== inadyn ===
+
* using the built-in capabilities of a cable/DSL modem/router
Install the <code><nowiki>inadyn</nowiki></code> package using Synaptic Package manager, then:
+
Many router/modems support Dynamic DNS reporting/notification/updating directly. If your router's configuration is accessible from a web browser, try accessing it by logging into the local IP address of your router (for example, http://10.1.1.1/ or http://192.168.0.1/ ) and look for the Dynamic DNS (DDNS) settings.
The following will allow your Ubuntu Linux machine to be accessible anywhere that you are given an externally-accessible IP address. This includes most ISPs but excludes many office LANs.
+
However, even if your modem/router does support dynamic DNS reporting, there are cases in which you may wish to use a software utility on your computer to perform the updates anyway:
First edit the file <code><nowiki>/etc/inadyn.conf</nowiki></code>:
+
* you are using several Dynamic DNS services at once (most routers only accommodate one service at a time)
 +
* the router does not support your particular Dynamic DNS service
 +
* your server is on a mobile computer (e.g. laptop) which is not always connected to the same network/router/modem.
 +
=== Using a software utility to perform Dynamic DNS Updates ===
 +
There are several available utilities. Each Dynamic DNS service may work better with a particular utility. (You may need to add the Ubuntu Universe to your set of software repositories to install some of these utilities. See [[UbuntuHelp:InstallingSoftware|InstallingSoftware]].)
 +
==== ddclient ====
 +
[http://sourceforge.net/apps/trac/ddclient ddclient] is the original Linux utility for dynamic DNS updates. [http://sourceforge.net/apps/trac/ddclient/wiki/Protocols The ddclient wiki] lists some configurations for several Dynamic DNS services. More info can be found on the [http://sourceforge.net/projects/ddclient/forums/forum/399428 ddclient forums]. The following section has been adapted from [http://ubuntuguide.org/wiki/Dynamic_IP_servers Ubuntuguide.org Dynamic IP servers].
 +
* Install ddclient using a software package manager, or using the command-line interface:
 
<pre><nowiki>
 
<pre><nowiki>
gksudo gedit /etc/inadyn.conf
+
sudo apt-get install ddclient
 
</nowiki></pre>
 
</nowiki></pre>
It should contain something like to the following:
+
If this is the first time you have installed ddclient, you will be prompted by the installation script for the URL hostname(s) that you registered with DynDNS (or other Dynamic DNS service). You will also be prompted for the username/password your registered with your Dynamic DNS service. Lastly, you will be asked which ethernet port you primarily use to connect to the Internet (eth0 for wired or wlan0 for wireless, usually). Most of the time this is all you will need to do for the utility to function correctly.
 +
You can also later edit the ddclient configuration file, however, to suit your specific needs (or if you make changes to your service, hostname, or other variables).
 +
* Edit the ddclient configuration file (using kate instead of nano in Kubuntu, or gedit instead of nano in Ubuntu):
 
<pre><nowiki>
 
<pre><nowiki>
--username myusername
+
sudo nano /etc/ddclient.conf
--password mypassword
+
--update_period 60000
+
--alias myhost.dyndns.org
+
--background
+
 
</nowiki></pre>
 
</nowiki></pre>
Now test that it works by typing
+
* To set the number of seconds between updates, I add the line
 
<pre><nowiki>
 
<pre><nowiki>
sudo /usr/sbin/inadyn
+
daemon=3600
 
</nowiki></pre>
 
</nowiki></pre>
Next, add inadyn to your 'crontab':
+
My dynamic IP only changes rarely, so I only check it hourly (3600 seconds in an hour).
 +
* To use secure SSL communications, I add the line
 
<pre><nowiki>
 
<pre><nowiki>
export EDITOR=gedit
+
ssl=yes
sudo crontab -e
+
 
</nowiki></pre>
 
</nowiki></pre>
Edit the file to add the following additional line:
+
* To use the DynDNS checkip service (which will autodetect your current IP address), I add the line
 
<pre><nowiki>
 
<pre><nowiki>
@reboot /usr/sbin/inadyn
+
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
 
</nowiki></pre>
 
</nowiki></pre>
Then save and exit the editor. Verify using
+
My configuration file now looks like:
 
<pre><nowiki>
 
<pre><nowiki>
sudo crontab -l
+
# Configuration file for ddclient generated by debconf
 +
#
 +
# /etc/ddclient.conf
 +
#
 +
# Check the current IP address. Either check the eth0 port for its current IP address (can't be used on a LAN),
 +
# or use the DynDNS IP checking service.
 +
daemon=3600
 +
pid=/var/run/ddclient.pid
 +
#use=if, if=eth0
 +
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
 +
#
 +
# Login and change the values at the DynDNS site, using SSL.
 +
protocol=dyndns2
 +
ssl=yes
 +
server=members.dyndns.org
 +
login=myDynDNSusername
 +
password='myDynDNSuserpassword'
 +
mysite_1.dynds.org,mysite_2.dyndns.org,mysite_3.dyndns.org
 
</nowiki></pre>
 
</nowiki></pre>
When you reboot, you should see indyn listed when you type
+
Note: if this doesn't work, try changing web-skip to 'Current Address'
 +
Note that the password must be enclosed in quotation marks, e.g 'myDynDNSuserpassword' for DynDNS.
 +
* Ensure that the configuration is working:
 
<pre><nowiki>
 
<pre><nowiki>
ps -A | grep inadyn
+
sudo ddclient -daemon=0 -debug -verbose -noquiet
 
</nowiki></pre>
 
</nowiki></pre>
You should be able to log in to your Dynamic DNS provider's website and verify that the DNS entry is being updated. Certainly this is possible with www.dyndns.org, in any case. Alternatively you can type your hostname into a service like http://www.dnsstuff.com/.
+
* Note that you can add additional services and/or domain names to be updated simply by adding an additional block to the configuration file (appropriate for the service). Here is an example (see below for references to additional examples).
=== ddclient ===
+
<pre><nowiki>
More details required here. The documentation is good however, and there is a Ubuntu package for ddclient in the Ubuntu Universe.
+
protocol=otherDDNSservice
Install ddclient and the package installer scripts will ask you for your information.
+
server=whatever.ddnsservice.org
http://ddclient.sourceforge.net/?page=0
+
login=MyOtherDDNSserviceusername
----
+
password=MyOtherDDNSservicepassword
''The following instructions is a wiki formatted excerpt from the ubuntu-users mailing list on the issue of repairing a ddclient setup:''
+
mysite4.dnsservice.org, mysite5.dnsservice.org
''http://linux.derkeiler.com/Mailing-Lists/Ubuntu/2007-12/msg01412.html''
+
</nowiki></pre>
''Author: Unknown''
+
===== Troubleshooting =====
1. Remove/purge all of the previous install attempts:
+
The following details a [http://linux.derkeiler.com/Mailing-Lists/Ubuntu/2007-12/msg01412.html troubleshooting method] used to repair a ddclient setup.
 
+
* Remove/purge all of the previous install attempts:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get remove --purge ddclient
 
sudo apt-get remove --purge ddclient
 
</nowiki></pre>
 
</nowiki></pre>
2. Install ssh & ssh socket so that you can send your password via ssh instead of in the clear:
+
* Install ssh & ssh socket so that you can send your password via ssh instead of in the clear:
 
+
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install ssh libio-socket-ssl-perl
 
sudo apt-get install ssh libio-socket-ssl-perl
 
</nowiki></pre>
 
</nowiki></pre>
 
''Note: ssh w/ddclient won't work without libio-socket-ssl-perl, so make sure that you install that even if you have ssh already installed.''
 
''Note: ssh w/ddclient won't work without libio-socket-ssl-perl, so make sure that you install that even if you have ssh already installed.''
2. Reinstall ddclient from the repo:
+
* Reinstall a current ddclient package from the repositories:
 
+
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install ddclient
 
sudo apt-get install ddclient
 
</nowiki></pre>
 
</nowiki></pre>
 
At the prompts enter the appropriate values, for example:
 
At the prompts enter the appropriate values, for example:
Dynamic DNS service provider: ''www.dyndns.com''
+
*Dynamic DNS service provider: ''www.dyndns.com''
DynDNS fully qualified domain names: ''your-hostname.dyndns.org''
+
*DynDNS fully qualified domain names: ''your-hostname.dyndns.org''
Username for dynamic DNS service: ''your-username''
+
*Username for dynamic DNS service: ''your-username''
Password: ''your-password''
+
*Password for dynamic DNS service: ''your-password''
Enter the interface which is used for using dynamic DNS service: ''web''
+
*Interface used for dynamic DNS service: ''web''
3. Modify the /etc/ddclient.conf to send the password using ssh and to properly check for the IP address:
+
* Modify the /etc/ddclient.conf to send the password using ssh and to properly check for the IP address:
 
+
 
<pre><nowiki>
 
<pre><nowiki>
gksu gedit /etc/ddclient.conf
+
sudo gedit /etc/ddclient.conf
 
</nowiki></pre>
 
</nowiki></pre>
 
Add entries for "daemon", "ssl" and replace "use=if, if=web" with "use=web" to match the following example:
 
Add entries for "daemon", "ssl" and replace "use=if, if=web" with "use=web" to match the following example:
第116行: 第137行:
 
Now ddclient is set to run as a daemon. Because you had other ddclient configs previously, check:
 
Now ddclient is set to run as a daemon. Because you had other ddclient configs previously, check:
 
<pre><nowiki>
 
<pre><nowiki>
gksu gedit /etc/default/ddclient
+
sudo gedit /etc/default/ddclient
 
</nowiki></pre>
 
</nowiki></pre>
 
Check to make sure it contains the following lines:
 
Check to make sure it contains the following lines:
第125行: 第146行:
 
</nowiki></pre>
 
</nowiki></pre>
 
''Note: you can set the interval shorter or longer, but if you do, also reset your /etc/ddclient.conf to match. https://bugs.launchpad.net/ubuntu/+source/ddclient/+bug/152875''
 
''Note: you can set the interval shorter or longer, but if you do, also reset your /etc/ddclient.conf to match. https://bugs.launchpad.net/ubuntu/+source/ddclient/+bug/152875''
Now, just to be sure everything sticks I generally reboot at this point, then check the status afterwards:
+
Now, just to be sure everything sticks I generally reboot at this point, then check the status afterward:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo /etc/init.d/ddclient status
 
sudo /etc/init.d/ddclient status
第143行: 第164行:
 
Then I obtain a new IP address/lease from my service provider (shutting off the modem, having my router request a new lease, whatever) & monitor
 
Then I obtain a new IP address/lease from my service provider (shutting off the modem, having my router request a new lease, whatever) & monitor
 
https://www.dyndns.com/account/services/hosts/ to see if the change actually makes it to dyndns. Also monitor /var/log/syslog to watch the changes there as well.
 
https://www.dyndns.com/account/services/hosts/ to see if the change actually makes it to dyndns. Also monitor /var/log/syslog to watch the changes there as well.
=== no-ip ===
+
==== no-ip ====
This is another Dynamic DNS reporting client.
+
This is another Dynamic DNS reporting client. Install the noip2 package from a software package manager, or from the command-line interface:
 +
<pre><nowiki>
 +
sudo apt-get install noip2
 +
</nowiki></pre>
 +
* Run no-ip and follow the installation prompts:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo no-ip -C
 
sudo no-ip -C
第152行: 第177行:
 
Do you wish to run something at successful update?[N] <N>
 
Do you wish to run something at successful update?[N] <N>
 
</nowiki></pre>
 
</nowiki></pre>
Next, start the no-ip client
+
* Start the no-ip client
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo no-ip
 
sudo no-ip
 
</nowiki></pre>
 
</nowiki></pre>
== Using your Modem/Router for Dynamic DNS Reporting ==
+
==== inadyn ====
Here are some example screenshots from Wireless Routers that support dynamic DNS reporting:
+
* Install the [http://www.inatech.eu/inadyn/ inadyn] package using a software package manager, or from the command-line interface:
Example:
+
<pre><nowiki>
 +
sudo apt-get install inadyn
 +
</nowiki></pre>
 +
* Edit the file /etc/inadyn.conf:
 +
<pre><nowiki>
 +
sudo gedit /etc/inadyn.conf
 +
</nowiki></pre>
 +
It should contain something like:
 +
<pre><nowiki>
 +
--username myusername
 +
--password mypassword
 +
--update_period 60000
 +
--alias myhost.dyndns.org
 +
--background
 +
</nowiki></pre>
 +
* Test that it works:
 +
<pre><nowiki>
 +
sudo /usr/sbin/inadyn
 +
</nowiki></pre>
 +
* Add inadyn to your 'crontab':
 +
<pre><nowiki>
 +
export EDITOR=gedit && sudo crontab -e
 +
</nowiki></pre>
 +
Edit the file to add the following line:
 +
<pre><nowiki>
 +
@reboot /usr/sbin/inadyn
 +
</nowiki></pre>
 +
* Verify using:
 +
<pre><nowiki>
 +
sudo crontab -l
 +
</nowiki></pre>
 +
* When you reboot, you should see indyn listed when you type:
 +
<pre><nowiki>
 +
ps -A | grep inadyn
 +
</nowiki></pre>
 +
You should be able to log in to your Dynamic DNS provider's website and verify that the DNS entry is being updated. Certainly this is possible with www.dyndns.org, in any case. Alternatively you can type your hostname into a service like http://www.dnsstuff.com/.
 +
=== Using your Modem/Router to perform Dynamic DNS Updates ===
 +
Here are some example screenshots from Wireless Routers that support dynamic DNS updates:
 +
Netgear router example:
 
https://help.ubuntu.com/community/DynamicDNS?action=AttachFile&do=get&target=dyndns.jpg
 
https://help.ubuntu.com/community/DynamicDNS?action=AttachFile&do=get&target=dyndns.jpg
Another example:
+
D-Link router example:
 
https://help.ubuntu.com/community/DynamicDNS?action=AttachFile&do=get&target=routerdyn.jpg
 
https://help.ubuntu.com/community/DynamicDNS?action=AttachFile&do=get&target=routerdyn.jpg
 +
Linksys/Cisco router example:
 +
https://help.ubuntu.com/community/DynamicDNS?action=AttachFile&do=get&target=linksysdyndns.jpg
 +
== Redirecting a registered hostname to a dynamic DNS name ==
 +
A user may already have a hostname URL registered with a name server that does not have Dynamic DNS capabilities. Most DNS services allow URL forwarding, however. It is therefore possible to set up a free Dynamic DNS service (using the instructions above) with a free hostname URL and then forward the static hostname URL (that is already registered) to the Dynamic DNS hostname URL.
 +
For example, I set up a free Dynamic DNS hostname URL at DynDNS.com that is foobar.dyndns.org. I set up my software utility (DynDNS likes ddclient or inadyn) to constantly update the Dynamic DNS database for foobar.dyndns.org.
 +
However, I have used example.myoriginalfoobar.com as a registered hostname URL for years, with a static DNS service (DinosaurDNS.org) that doesn't have Dynamic DNS capabilities. I login to DinosaurDNS.org and set my DNS record for example.myoriginalfoobar.com to forward (using a CNAME (Alias) record) to foobar.dyndns.org.
 +
Now anyone trying to access example.myoriginalfoobar.com will be redirected to foobar.dyndns.org, which will then redirect them to whichever IP address my Dynamic DNS updating utility has specified.
 +
== Other resources ==
 +
* [http://ubuntuguide.org/wiki/Dynamic_IP_servers Ubuntuguide.org Dynamic IP servers] -- information about setting up a Dynamic IP webserver address with ddclient
 
----
 
----
[[category:CategoryDocumentation]]
+
[[category:CategoryInternet]] [[category:CategoryNetworking]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 22:07的最新版本

Parent page: Internet and Networking

Dynamic DNS Introduction

Every computer attached to the Internet has an IP address. DNS is the process of relating a URL name (like 'www.google.com') to an IP address (like '74.125.19.103') so that a website (or other service) on a computer can be accessed using an easily-remembered URL name, rather than the IP address number of the computer. The relationship between a URL and its corresponding IP address is known as a DNS record. A large number of databases on the Internet (known as DNS name servers) keep track of these DNS records and exchange the information between each other so that they all are consistent. Every request by a web browser (for a URL) on the Internet is then routed through one of these name servers for resolution to an IP address. Most servers on the Internet have a fixed (static) IP address that never changes. This means that a DNS record needs to only be set once in a name server's DNS database, since the URL for that server will always be directed to the same IP address. However, many home users are assigned a constantly changing dynamic IP address by their ISP. In the past this has made it difficult for a server on a home computer to be assigned a URL that could be found from the Internet. A number of DNS name servers now offer a method, however, by which a computer with a constantly changing IP address can update a "Dynamic DNS" database using a small software utility on their computer (or directly from their router). These Dynamic DNS services allow the user to choose a hostname URL and set an initial IP address to correspond to that hostname URL. The software utility on the user's computer (or a router's built-in utility) then periodically checks for a change to the computer's IP address, and when a new IP address is discovered, it updates the Dynamic DNS database to reflect that change.

Registering with a Dynamic DNS provider

Dynamic DNS requires that a name server somewhere on the Internet keep track of 'where you are' (i.e. your computer's (or router's) current IP address). That is, its database must always be updated to make sure your hostname URL always corresponds to your current IP address. In order to use one of these Dynamic DNS services, registration is required first. Here is a selection of these services:

Upon registering, you will select a username and password, as well as a hostname that you will use as the DNS name (to allow external access to your machine using a URL). Many Dynamic DNS providers offer a selection of URL hostnames available for free use with their service. However, with a paid plan, any URL hostname (including your own registered domain name) can be used.

Setting up Dynamic DNS service updates

Once you have chosen a Dynamic DNS service provider, you need to set up a way that your IP address record will be updated whenever it is changed. There are two ways of doing this:

  • using a dynamic DNS software utility that is installed on your computer
  • using the built-in capabilities of a cable/DSL modem/router

Many router/modems support Dynamic DNS reporting/notification/updating directly. If your router's configuration is accessible from a web browser, try accessing it by logging into the local IP address of your router (for example, http://10.1.1.1/ or http://192.168.0.1/ ) and look for the Dynamic DNS (DDNS) settings. However, even if your modem/router does support dynamic DNS reporting, there are cases in which you may wish to use a software utility on your computer to perform the updates anyway:

  • you are using several Dynamic DNS services at once (most routers only accommodate one service at a time)
  • the router does not support your particular Dynamic DNS service
  • your server is on a mobile computer (e.g. laptop) which is not always connected to the same network/router/modem.

Using a software utility to perform Dynamic DNS Updates

There are several available utilities. Each Dynamic DNS service may work better with a particular utility. (You may need to add the Ubuntu Universe to your set of software repositories to install some of these utilities. See InstallingSoftware.)

ddclient

ddclient is the original Linux utility for dynamic DNS updates. The ddclient wiki lists some configurations for several Dynamic DNS services. More info can be found on the ddclient forums. The following section has been adapted from Ubuntuguide.org Dynamic IP servers.

  • Install ddclient using a software package manager, or using the command-line interface:
sudo apt-get install ddclient

If this is the first time you have installed ddclient, you will be prompted by the installation script for the URL hostname(s) that you registered with DynDNS (or other Dynamic DNS service). You will also be prompted for the username/password your registered with your Dynamic DNS service. Lastly, you will be asked which ethernet port you primarily use to connect to the Internet (eth0 for wired or wlan0 for wireless, usually). Most of the time this is all you will need to do for the utility to function correctly. You can also later edit the ddclient configuration file, however, to suit your specific needs (or if you make changes to your service, hostname, or other variables).

  • Edit the ddclient configuration file (using kate instead of nano in Kubuntu, or gedit instead of nano in Ubuntu):
 sudo nano /etc/ddclient.conf
  • To set the number of seconds between updates, I add the line
 daemon=3600

My dynamic IP only changes rarely, so I only check it hourly (3600 seconds in an hour).

  • To use secure SSL communications, I add the line
 ssl=yes
  • To use the DynDNS checkip service (which will autodetect your current IP address), I add the line
 use=web, web=checkip.dyndns.com/, web-skip='IP Address'

My configuration file now looks like:

 # Configuration file for ddclient generated by debconf
 #
 # /etc/ddclient.conf
 #
 # Check the current IP address. Either check the eth0 port for its current IP address (can't be used on a LAN),
 # or use the DynDNS IP checking service.
 daemon=3600
 pid=/var/run/ddclient.pid
 #use=if, if=eth0
 use=web, web=checkip.dyndns.com/, web-skip='IP Address'
 #
 # Login and change the values at the DynDNS site, using SSL.
 protocol=dyndns2
 ssl=yes
 server=members.dyndns.org
 login=myDynDNSusername
 password='myDynDNSuserpassword'
 mysite_1.dynds.org,mysite_2.dyndns.org,mysite_3.dyndns.org

Note: if this doesn't work, try changing web-skip to 'Current Address' Note that the password must be enclosed in quotation marks, e.g 'myDynDNSuserpassword' for DynDNS.

  • Ensure that the configuration is working:
 sudo ddclient -daemon=0 -debug -verbose -noquiet
  • Note that you can add additional services and/or domain names to be updated simply by adding an additional block to the configuration file (appropriate for the service). Here is an example (see below for references to additional examples).
 protocol=otherDDNSservice
 server=whatever.ddnsservice.org
 login=MyOtherDDNSserviceusername
 password=MyOtherDDNSservicepassword
 mysite4.dnsservice.org, mysite5.dnsservice.org
Troubleshooting

The following details a troubleshooting method used to repair a ddclient setup.

  • Remove/purge all of the previous install attempts:
sudo apt-get remove --purge ddclient
  • Install ssh & ssh socket so that you can send your password via ssh instead of in the clear:
sudo apt-get install ssh libio-socket-ssl-perl

Note: ssh w/ddclient won't work without libio-socket-ssl-perl, so make sure that you install that even if you have ssh already installed.

  • Reinstall a current ddclient package from the repositories:
sudo apt-get install ddclient

At the prompts enter the appropriate values, for example:

  • Dynamic DNS service provider: www.dyndns.com
  • DynDNS fully qualified domain names: your-hostname.dyndns.org
  • Username for dynamic DNS service: your-username
  • Password for dynamic DNS service: your-password
  • Interface used for dynamic DNS service: web
  • Modify the /etc/ddclient.conf to send the password using ssh and to properly check for the IP address:
sudo gedit /etc/ddclient.conf

Add entries for "daemon", "ssl" and replace "use=if, if=web" with "use=web" to match the following example:

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

daemon=300
pid=/var/run/ddclient.pid
ssl=yes
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
login=your-username
password=your-password
protocol=dyndns2
server=members.dyndns.org
your-hostname.dyndns.org

Reference for secure updates: https://www.dyndns.com/support/kb/using_ddclient_with_dyndns_services.html Now ddclient is set to run as a daemon. Because you had other ddclient configs previously, check:

sudo gedit /etc/default/ddclient

Check to make sure it contains the following lines:

run_ipup="false"
run_daemon="true"
daemon_interval="300"

Note: you can set the interval shorter or longer, but if you do, also reset your /etc/ddclient.conf to match. https://bugs.launchpad.net/ubuntu/+source/ddclient/+bug/152875 Now, just to be sure everything sticks I generally reboot at this point, then check the status afterward:

sudo /etc/init.d/ddclient status

You should see:

Status of Dynamic DNS service update utility: ddclient is running

However, that may not always catch problems in the ddclient.conf file, so issue:

sudo /etc/init.d/ddclient restart

if you do not get an error similar to the following you probably are good to go:

WARNING: file /etc/ddclient.conf, line x

Then I obtain a new IP address/lease from my service provider (shutting off the modem, having my router request a new lease, whatever) & monitor https://www.dyndns.com/account/services/hosts/ to see if the change actually makes it to dyndns. Also monitor /var/log/syslog to watch the changes there as well.

no-ip

This is another Dynamic DNS reporting client. Install the noip2 package from a software package manager, or from the command-line interface:

sudo apt-get install noip2
  • Run no-ip and follow the installation prompts:
sudo no-ip -C
Please enter the login/email string for no-ip.com: <your_login>
Please enter the password for user 'your_login': <your_password>
Please enter an update interval:[30] <interval time in minutes>
Do you wish to run something at successful update?[N] <N>
  • Start the no-ip client
sudo no-ip

inadyn

  • Install the inadyn package using a software package manager, or from the command-line interface:
sudo apt-get install inadyn
  • Edit the file /etc/inadyn.conf:
sudo gedit /etc/inadyn.conf

It should contain something like:

--username myusername
--password mypassword
--update_period 60000
--alias myhost.dyndns.org
--background
  • Test that it works:
sudo /usr/sbin/inadyn
  • Add inadyn to your 'crontab':
export EDITOR=gedit && sudo crontab -e

Edit the file to add the following line:

@reboot /usr/sbin/inadyn
  • Verify using:
sudo crontab -l
  • When you reboot, you should see indyn listed when you type:
ps -A | grep inadyn

You should be able to log in to your Dynamic DNS provider's website and verify that the DNS entry is being updated. Certainly this is possible with www.dyndns.org, in any case. Alternatively you can type your hostname into a service like http://www.dnsstuff.com/.

Using your Modem/Router to perform Dynamic DNS Updates

Here are some example screenshots from Wireless Routers that support dynamic DNS updates: Netgear router example: DynamicDNS?action=AttachFile&do=get&target=dyndns.jpg D-Link router example: DynamicDNS?action=AttachFile&do=get&target=routerdyn.jpg Linksys/Cisco router example: DynamicDNS?action=AttachFile&do=get&target=linksysdyndns.jpg

Redirecting a registered hostname to a dynamic DNS name

A user may already have a hostname URL registered with a name server that does not have Dynamic DNS capabilities. Most DNS services allow URL forwarding, however. It is therefore possible to set up a free Dynamic DNS service (using the instructions above) with a free hostname URL and then forward the static hostname URL (that is already registered) to the Dynamic DNS hostname URL. For example, I set up a free Dynamic DNS hostname URL at DynDNS.com that is foobar.dyndns.org. I set up my software utility (DynDNS likes ddclient or inadyn) to constantly update the Dynamic DNS database for foobar.dyndns.org. However, I have used example.myoriginalfoobar.com as a registered hostname URL for years, with a static DNS service (DinosaurDNS.org) that doesn't have Dynamic DNS capabilities. I login to DinosaurDNS.org and set my DNS record for example.myoriginalfoobar.com to forward (using a CNAME (Alias) record) to foobar.dyndns.org. Now anyone trying to access example.myoriginalfoobar.com will be redirected to foobar.dyndns.org, which will then redirect them to whichever IP address my Dynamic DNS updating utility has specified.

Other resources