Dynamic IP servers

来自Ubuntu中文
跳到导航跳到搜索

I happen to like the DynDNS service because they are one of the oldest (and have free services available). The examples use this service, but there are other services that can be used with similar setups.

Single URL and a DynDNS-capable router

My router happens to have a built-in updater for DynDNS (and for TZO). In the DDNS section of the router configuration, I can set the name of a single URL I have registered with DynDNS (or TZO), along with the username and password I have previously set up at DynDNS.com. The router does the rest automatically for me. If you are using a single URL and have a similar router capability, then this will be the easiest setup by far. First register for a username (with password) at DynDNS (or TZO) and set the URL name there that the server on your host will use. Then input the information into your router's configuration page. The router will do the rest.

Multiple URLs

I use multiple URLs because I run multiple webservers from my host computer. However, the router I currently use only allows me to update one of the URLs. I therefore need an updater program in order to update all of the URLs at the same time.

ddclient

ddclient is a perl-based client that updates the DynDNS (or other dynamic IP DNS service) database to keep track of your host computer's changing dynamic IP address. DynDNS is a public DNS server, and will match your URL name to whichever (current) dynamic IP address that the ddclient sends to DynDNS. Setup will be easiest if first register for a username/password at DynDNS (or other dynamic IP DNS service) and set up your desired URLs there, first. Then install the updater client program:

sudo apt-get install ddclient
If this is the first time you have installed ddclient, you will be prompted for the URLs you registered with DynDNS (or other dynamic IP DNS service). You will also be prompted for the username/password your registered with DynDNS. Lastly, you will be asked which ethernet port you primarily use to connect to the Internet (eth0 for wired, wlan0 for wireless, usually).

The system will function with no further setup if you input the variables correctly. See this DynDNS page for instructions on additional customizations available for use with DynDNS.

Edit ddclient configuration

  • Edit the ddclient configuration file (use 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 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

Other DDNS services