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.
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.
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:
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:
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 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.
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).
sudo nano /etc/ddclient.conf
daemon=3600
My dynamic IP only changes rarely, so I only check it hourly (3600 seconds in an hour).
ssl=yes
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.
sudo ddclient -daemon=0 -debug -verbose -noquiet
protocol=otherDDNSservice server=whatever.ddnsservice.org login=MyOtherDDNSserviceusername password=MyOtherDDNSservicepassword mysite4.dnsservice.org, mysite5.dnsservice.org
The following details a troubleshooting method used to repair a ddclient setup.
sudo apt-get remove --purge ddclient
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.
sudo apt-get install ddclient
At the prompts enter the appropriate values, for example:
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.
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
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>
sudo no-ip
sudo apt-get install inadyn
sudo gedit /etc/inadyn.conf
It should contain something like:
--username myusername --password mypassword --update_period 60000 --alias myhost.dyndns.org --background
sudo /usr/sbin/inadyn
export EDITOR=gedit && sudo crontab -e
Edit the file to add the following line:
@reboot /usr/sbin/inadyn
sudo crontab -l
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/.
Here are some example screenshots from Wireless Routers that support dynamic DNS updates:
Netgear router example:
D-Link router example:
Linksys/Cisco router example:
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.
联系客服