个人工具

“Quick HOWTO : Ch19 : Dynamic DNS/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第5行: 第5行:
 
{{Translator|fei3ban}}<br>  
 
{{Translator|fei3ban}}<br>  
  
{{Languages|Quick_HOWTO_:_Ch19_:_Dynamic_DNS}}<br>
+
{{Languages|Quick_HOWTO_:_Ch19_:_Dynamic_DNS}}<br><br>  
<br>
+
&amp;nbsp;
+
  
Introduction
+
= 简介<br>  =
  
In many home networking environments, the DSL or cable modem IP address is provided by DHCP and therefore changes from time to time. This can cause problems with the DNS zone files explained in Chapter 18, "Configuring DNS," which assume the IP address of a server won't change continuously. It is for this reason that there are two broad types of DNS:
+
<br>在大多数家庭网络环境,通过DSL或者Cable Modem连接网络的主机IP地址都是通过DHCP获得并随时间经常改变,这会给DNS服务(区域文件)带来问题。第18章“配置DNS”一节假定服务器地址是固定不变的。因此,产生了两大类DNS:
  
Static DNS
+
“静态DNS”<br>当ISP为您提供固定不变的静态IP地址时,你的DNS服务器作为您的站点域认证信息源。你可以把静态DNS看作是DNS的“传统”或“常规”模式。
  
This is used when your ISP provides you with unchanging fixed or static Internet IP addresses. Your DNS server acts as the authoritative source of information for your my-site.com domain. You can consider static DNS as the "traditional" or "regular" form of DNS.
+
“动态DNS”<br>当你通过DHCP从您的ISP处获得动态IP地址时,你就不得不使用第三方DNS提供商来为您的站点域提供DNS信息服务。<br>本章将详细讲解动态DNS的配置过程。<br><br>
  
Dynamic DNS (DDNS)
+
= 准备动态DNS  =
  
Used when you get a changing dynamic Internet IP addresses via DHCP from your ISP. You will have to use the services of a third-party DNS provider to provide DNS information for your my-site.com domain.  
+
和DSL不同的是,大多数的cable modem供应商(类似有线宽频)不允许你在家开办主机站点,他们阻止入站的HTTP(TCP 端口80)和SMTP 邮件(TCP端口25)而允许其他的TCP通讯.许多动态DNS(DDNS)供应商意识到这点并提供了自动重定向让访问你主机的web客户通过一个不同的TCP端口.尽管这样也工作的很好,但是还是不方便.看起来很诱人的虚拟主机服务却要增加每月$10的费用,并且很多搜索引擎都不索引重定向的页面.<br>
  
This chapter will explain the details of dynamic DNS configuration.
+
== <br>为你的web站点测试ISP(互联网供应商)的连通性<br>  ==
  
==简介==&lt;br&gt;在大多数家庭网络环境,通过DSL或者Cable Modem连接网络的主机IP地址都是通过DHCP获得并随时间经常改变,这会给DNS服务(区域文件)带来问题。第18章“配置DNS”一节假定服务器地址是固定不变的。因此,产生了两大类DNS:
+
第一件事就是你要知道你的ISP是用DSL还是cable modem,最简单的方法就是打电话问,但是有时候答案是yes但是他们却说no.这时你就要自己做些测试.<br><br>
  
“静态DNS”&lt;br&gt;当ISP为您提供固定不变的静态IP地址时,你的DNS服务器作为您的站点域认证信息源。你可以把静态DNS看作是DNS的“传统”或“常规”模式。
+
== 设置 ==
 
+
“动态DNS”&lt;br&gt;当你通过DHCP从您的ISP处获得动态IP地址时,你就不得不使用第三方DNS提供商来为您的站点域提供DNS信息服务。&lt;br&gt;本章将详细讲解动态DNS的配置过程。&lt;br&gt;[编辑] Dynamic DNS Preparation
+
 
+
Unlike DSL, most cable modem providers may not allow you to host sites at home by blocking inbound HTTP (TCP port 80) and SMTP mail (TCP port 25) while allowing most other TCP traffic through. Many DDNS providers are aware of this and provide a redirect service to bypass the problem. Under the system, Web queries first hit their servers on the regular TCP ports and then these servers automatically redirect the Web clients to use the IP address of your server on a different TCP port. Although this works well, it has disadvantages. The cost of the service can make hosting with a $10 /month virtual hosting service look very attractive, and many search engines do not index redirected pages.&lt;br&gt;[编辑] Testing ISP Connectivity For Your Website
+
 
+
The very first thing you need to do is to determine whether your ISP allows inbound connections on your DSL or cable modem line. The easiest way to do this is to phone them and ask, but in some cases they'll say no when in fact the answer is yes. Here is how you can test it out for yourself.&lt;br&gt;[编辑] Setup
+
 
+
You need to do some basic setup tests before testing can begin.
+
 
+
1. Configure and start Apache on your Linux web server as described in Chapter 20, "The Apache Web Server."&lt;br&gt; 2. Connect your Linux server directly to your cable or DSL modem, and configure the Ethernet NIC for DHCP as described in Chapter 3, "Linux Networking.".&lt;br&gt; 3. Make sure you can ping your default gateway.&lt;br&gt; 4. Use the ipconfig command to determine the new IP address of your Web server. (This command is explained Chapter 3 also.).&lt;br&gt; 5. From the Linux Web server itself, try to TELNET to this IP address on port 80 as explained in Chapter 4, "Simple Network Troubleshooting."
+
 
+
If you can, then you most likely have Apache configured correctly
+
 
+
设置  
+
  
 
在测试开始之前你需要做一些基本调试.  
 
在测试开始之前你需要做一些基本调试.  
第53行: 第37行:
 
5.在你的Linux web服务器上,尝试TELNET到新设置的ip地址,端口用80.参考第4章 ch4--"simple Network Trobleshooting".  
 
5.在你的Linux web服务器上,尝试TELNET到新设置的ip地址,端口用80.参考第4章 ch4--"simple Network Trobleshooting".  
  
如果你能完成这几步,说明你有很大的希望去正确配置Apache&lt;br&gt;[编辑] Testing From The Internet  
+
如果你能完成这几步,说明你有很大的希望去正确配置Apache<br>[编辑] Testing From The Internet  
 
+
You may be able to see web pages from the web server itself. Ask a friend somewhere else on the Internet to try to telnet to this IP address on port 80.
+
 
+
If port 80 works, then ask the friend to point a Web browser to the IP address and see whether a valid Web page appears. If your Linux server will eventually be placed behind a firewall, then adjust your network topology accordingly and test port 80 port forwarding to your Web server.
+
 
+
If the TELNET to port 80 fails, your ISP probably doesn't allow HTTP access to its networks. Configure your Web server to run on a different TCP port, preferably above 1024. The Apache httpd.conf file uses the listen directive to do this. Change it to your new value and restart httpd.
+
 
+
#httpd.conf listen directive, change "80" to some other value.
+
 
+
Listen 80
+
 
+
Test again with telnet on this new port. If it works, try the web browser test too. If the test port is 1234, then use the following URL:
+
  
http://server-ip-address:1234
+
从互联网测试
  
Note: If you are running iptables, remember to adjust the rules to match this new port, or stop iptables temporarily while doing this testing.  
+
这时你应该可以看到页面在你自己的网站上.请朋友在其他地方尝试去telnet(用80端口)你网站的ip地址.  
  
If you can get a connection with correctly displayed pages on a non standard port then you can additionally sign up for a redirect service with your DDNS provider as explained earlier.&lt;br&gt;[编辑] Test Port Forwarding
+
&nbsp;如果80端口工作正常,再让朋友用浏览器连接你的网站看是否能看到页面.如果你的Linux服务器是在防火墙后面,那你要适当调整下你的网络结构,<br>&nbsp;并且测试80端口指向你的服务器.<br>&nbsp;如果TELNET到80端口失败,很可能是的ISP不允许HTTP处理.设置你的web站点使用不同的TCP端口,尽量在1024以上.Apache 的httpd.conf文件用来监听管理这个.改变它为你要的数值,然后重启httpd.
 +
<pre>#httpd.conf listen directive, 改变 "80"为其他值
 +
Listen 80
 +
</pre>
 +
&nbsp;再用telnet测试这个新设置的端口.如果工作,再尝试浏览器测试.如果测试的端口是1234,要使用下面的连接:<br>
 +
<pre>http://server-ip-address:1234</pre>
 +
<br>
  
If your Linux server will eventually be placed behind a firewall, then adjust your network topology accordingly. Let Apache run on port 80, and test port forwarding from the nonstandard port to port 80 on your Web server from the Internet.  
+
<br> 注意:如果你在运行iptable, 记住调整规则已匹配新端口,或者在测试期间停止ipstable.如果你能在非标准的端口连接到页面,然后你记下来给你的DDNS供应商做重定向.  
  
One of the features of the curl troubleshooting utility is that it allows you download a Web page's HTML code to your screen without interpreting it. You can determine the external IP address of your router or firewall by logging onto your Linux Web server and issuing the curl command to query the DynDNS.org IP information server. In this case, you are interested in only the line that tells you what the server thinks your IP address is; use the grep command to extract just that part. In this example, the IP address is 24.4.97.110.
+
== 测试端口转发  ==
  
[root@bigboy tmp]# curl -s http://checkip.dyndns.org/ | grep -i address&lt;br&gt;Current IP Address: 24.4.97.110[root@bigboy tmp]#
+
如果你的Linux 服务器是在防火墙的后面,应该适当调整你的网络结构,让Apache运行在端口80,然后从互联网测试端口转发,从非标准
  
&lt;br&gt;[编辑] Registering DDNS
+
端口到80端口.curl-疑难排解工具的一个特点是他允许你下载页面的HTML的代码到你屏幕上.你应该靠你web服务器的日志能确定你的路由器或者防火墙的外部地址以及curl的命令发出请求到DynDNS.org的ip信息服务器.在这个情况里你只需要关于的ip的资料,用grep命令就可以得到这个部分.在这个范例中,ip地址是24.4.97.110.
 +
<pre>[root@bigboy tmp]# curl -s http://checkip.dyndns.org/ | grep -i address
 +
Current IP Address: 24.4.97.110[root@bigboy tmp]#
 +
</pre>
 +
== <br>注册DDNS  ==
  
 
Once you have decided to go ahead with DDNS you'll need to choose between the broad categories of Dynamic DNS service.  
 
Once you have decided to go ahead with DDNS you'll need to choose between the broad categories of Dynamic DNS service.  
第91行: 第73行:
 
If you choose to create your own domain and use a paid DDNS service then you'll need to follow these steps:  
 
If you choose to create your own domain and use a paid DDNS service then you'll need to follow these steps:  
  
1. Register your domains (such as my-site.com) with such companies as Verisign and RegisterFree.&lt;br&gt; 2. Create an account with the DDNS provider and register your websites (sometimes called hosts) as part of your domain (as in www.my-site.com and mail.my-site.com) with them. Your DDNS registration process will provide you with a username and password which you'll need to use when configuring your DDNS client.&lt;br&gt; 3. Update your domain information with your main DNS registrar (Verisign and RegisterFree) to tell them to direct queries to *.my-site.com to the DNS name servers of the DDNS provider.&lt;br&gt; 4. Install a DDNS client on your web servers that continuously runs, only updating the DDNS provider's DNS servers with the most current DHCP IP address of the site whenever it detects a change.  
+
1. Register your domains (such as my-site.com) with such companies as Verisign and RegisterFree.<br> 2. Create an account with the DDNS provider and register your websites (sometimes called hosts) as part of your domain (as in www.my-site.com and mail.my-site.com) with them. Your DDNS registration process will provide you with a username and password which you'll need to use when configuring your DDNS client.<br> 3. Update your domain information with your main DNS registrar (Verisign and RegisterFree) to tell them to direct queries to *.my-site.com to the DNS name servers of the DDNS provider.<br> 4. Install a DDNS client on your web servers that continuously runs, only updating the DDNS provider's DNS servers with the most current DHCP IP address of the site whenever it detects a change.  
  
Note: You should also be prepared for slower response times for your home-based site than if you were using a static IP and a regular DNS service.&lt;br&gt;[编辑] Install a DDNS Client On Your Server  
+
Note: You should also be prepared for slower response times for your home-based site than if you were using a static IP and a regular DNS service.<br>[编辑] Install a DDNS Client On Your Server  
  
All DDNS service providers require that you use a DDNS client on your web server that will periodically update the IP address information in your provider's DDNS record. The very popular one DDclient, for example, now comes in a RPM format.&lt;br&gt;[编辑] Dynamic DNS And NAT Router/Firewalls  
+
All DDNS service providers require that you use a DDNS client on your web server that will periodically update the IP address information in your provider's DDNS record. The very popular one DDclient, for example, now comes in a RPM format.<br>[编辑] Dynamic DNS And NAT Router/Firewalls  
  
 
As discussed in Chapter 2, "Introduction to Networking," to conserve the limited number of IP addresses available for Internet purposes, most home router/firewalls use network address translation (NAT) to map a single, public, DHCP-obtained IP address to the many private IP addresses within your network.  
 
As discussed in Chapter 2, "Introduction to Networking," to conserve the limited number of IP addresses available for Internet purposes, most home router/firewalls use network address translation (NAT) to map a single, public, DHCP-obtained IP address to the many private IP addresses within your network.  
第101行: 第83行:
 
NAT can fool the operation of some DDNS client software. In these cases, the software can report only the true IP address of the Linux box's NIC interface. If the Linux box is being protected behind a NAT router/firewall, then the NIC reports in its data stream to the DDNS provider a private IP address that no one can reach directly via the Internet. The reported value is therefore invalid.  
 
NAT can fool the operation of some DDNS client software. In these cases, the software can report only the true IP address of the Linux box's NIC interface. If the Linux box is being protected behind a NAT router/firewall, then the NIC reports in its data stream to the DDNS provider a private IP address that no one can reach directly via the Internet. The reported value is therefore invalid.  
  
Some DDNS providers use more intelligent clients, such as DDclient, that can be configured to let the DDNS provider record the public IP address from which the data stream is originating. Once this is done, you'll have to also configure your router/firewall to do port forwarding to make all HTTP traffic destined for the IP address of the router/firewall to be exclusively address translated using NAT and forwarded to a single server on your home network. If your firewall is Linux based, then the examples in Chapter 14, "Linux Firewalls Using iptables," will be helpful. Many Web-based small office/home office (SOHO) firewalls have easy interfaces to configure port forwarding, please refer to your manufacturer's manual on how to do this&lt;br&gt;[编辑] DDNS Client Software - SOHO Router / Firewalls  
+
Some DDNS providers use more intelligent clients, such as DDclient, that can be configured to let the DDNS provider record the public IP address from which the data stream is originating. Once this is done, you'll have to also configure your router/firewall to do port forwarding to make all HTTP traffic destined for the IP address of the router/firewall to be exclusively address translated using NAT and forwarded to a single server on your home network. If your firewall is Linux based, then the examples in Chapter 14, "Linux Firewalls Using iptables," will be helpful. Many Web-based small office/home office (SOHO) firewalls have easy interfaces to configure port forwarding, please refer to your manufacturer's manual on how to do this<br>[编辑] DDNS Client Software - SOHO Router / Firewalls  
  
Most new SOHO router/firewalls have built in dynamic DNS clients for one or more of the major DDNS service providers. There is usually a Dynamic DNS web menu which will prompt for the name of the service provider and your DDNS username and password. With this support, there is no need to install software on your web server.&lt;br&gt;[编辑] DDNS Client Software - Linux DDclient  
+
Most new SOHO router/firewalls have built in dynamic DNS clients for one or more of the major DDNS service providers. There is usually a Dynamic DNS web menu which will prompt for the name of the service provider and your DDNS username and password. With this support, there is no need to install software on your web server.<br>[编辑] DDNS Client Software - Linux DDclient  
  
One of the most commonly used clients is DDclient, which can overcome the NAT limitations of DDNS by actually logging into your SOHO firewall to determine the latest IP address information. Like most RedHat and Fedora Linux software products, DDclient is available in the RPM format. (If you need a refresher on RPMs, consult Chapter 6, "Installing Linux Software.") You can usually download the software from your DDNS provider, or you can find it at rpmfind.net. The RPM name usually starts with ddclient followed by a version number, as in ddclient-3.6.3-1.noarch.rpm.&lt;br&gt;[编辑] The /etc/ddclient.conf file  
+
One of the most commonly used clients is DDclient, which can overcome the NAT limitations of DDNS by actually logging into your SOHO firewall to determine the latest IP address information. Like most RedHat and Fedora Linux software products, DDclient is available in the RPM format. (If you need a refresher on RPMs, consult Chapter 6, "Installing Linux Software.") You can usually download the software from your DDNS provider, or you can find it at rpmfind.net. The RPM name usually starts with ddclient followed by a version number, as in ddclient-3.6.3-1.noarch.rpm.<br>[编辑] The /etc/ddclient.conf file  
  
 
The ddclient.conf file is usually installed completely commented out, but provides many configuration examples for the most popular DDNS providers.  
 
The ddclient.conf file is usually installed completely commented out, but provides many configuration examples for the most popular DDNS providers.  
第111行: 第93行:
 
The most important general parameters to configure are:  
 
The most important general parameters to configure are:  
  
*Username: Your DDNS account's login name&lt;br&gt; * Password: Your DDNS account's password&lt;br&gt; * Use: The method used to determine the IP address to advertise to the DDNS server
+
*Username: Your DDNS account's login name<br> * Password: Your DDNS account's password<br> * Use: The method used to determine the IP address to advertise to the DDNS server
  
 
Some important DDNS provider parameters are  
 
Some important DDNS provider parameters are  
  
*Server: The name of the DDNS provider's main DNS server&lt;br&gt; * Protocol: The methodology the DDNS client should use to communicate with the DDNS server&lt;br&gt; * Your domain: The domain to which your web server will belong
+
*Server: The name of the DDNS provider's main DNS server<br> * Protocol: The methodology the DDNS client should use to communicate with the DDNS server<br> * Your domain: The domain to which your web server will belong
  
 
You can use the ddclient command to determine the best use parameter to use in the ddclient.conf file. In this example, only the use=web option gives a valid Internet IP address and should be considered as a first option:  
 
You can use the ddclient command to determine the best use parameter to use in the ddclient.conf file. In this example, only the use=web option gives a valid Internet IP address and should be considered as a first option:  
  
[root@bigboy tmp]# ddclient -daemon=0 -query&lt;br&gt;use=if, if=lo address is 127.0.0.1&lt;br&gt;use=if, if=wlan0 address is 192.168.1.100&lt;br&gt;use=web, web=dyndns address is 97.158.253.26&lt;br&gt;[root@bigboy tmp]#  
+
[root@bigboy tmp]# ddclient -daemon=0 -query<br>use=if, if=lo address is 127.0.0.1<br>use=if, if=wlan0 address is 192.168.1.100<br>use=web, web=dyndns address is 97.158.253.26<br>[root@bigboy tmp]#  
  
 
Take a look at a sample configuration. This example specifies a username of my-account-login-name and a password of my-account-password using the dyndns DDNS service provider's settings to track the Web site named mysite-example.dnsalias.com.  
 
Take a look at a sample configuration. This example specifies a username of my-account-login-name and a password of my-account-password using the dyndns DDNS service provider's settings to track the Web site named mysite-example.dnsalias.com.  
第125行: 第107行:
 
#General Parameter Section
 
#General Parameter Section
  
login=my-account-login-name&lt;br&gt;password=my-account-password  
+
login=my-account-login-name<br>password=my-account-password  
  
 
#DDNS Provider Parameters Section
 
#DDNS Provider Parameters Section
  
server=members.dyndns.org, \&lt;br&gt;protocol=dyndns2 \&lt;br&gt;mysite-example.dnsalias.com  
+
server=members.dyndns.org, \<br>protocol=dyndns2 \<br>mysite-example.dnsalias.com  
  
 
You can add one of the following use lines to the General Parameter Section near the top of the file to define the method that will be used to determine the correct IP address:  
 
You can add one of the following use lines to the General Parameter Section near the top of the file to define the method that will be used to determine the correct IP address:  
第137行: 第119行:
 
use=web  
 
use=web  
  
*Use The IP Address Of A Specific Server NIC&amp;nbsp;: You can also use this option which will query the IP address of the DDclient web server's NIC interface of your choice. This is probably most valuable for servers connected directly to the Internet, and not via NAT
+
*Use The IP Address Of A Specific Server NIC&nbsp;: You can also use this option which will query the IP address of the DDclient web server's NIC interface of your choice. This is probably most valuable for servers connected directly to the Internet, and not via NAT
  
 
use=if, if=eth0  
 
use=if, if=eth0  
第143行: 第125行:
 
*Login To Your SOHO Firewall For Information: The ddclient.conf file has a list of use statements for various vendor's firewalls. If your model isn't listed, you can create your own parameters as outlined in the ddclient README file. This option is good for NAT environments where the "use=web" option isn't considered a good alternative.
 
*Login To Your SOHO Firewall For Information: The ddclient.conf file has a list of use statements for various vendor's firewalls. If your model isn't listed, you can create your own parameters as outlined in the ddclient README file. This option is good for NAT environments where the "use=web" option isn't considered a good alternative.
  
After editing your configuration file you'll have to start ddclient as shown in the next section.&lt;br&gt;[编辑] How to Get DDclient Started  
+
After editing your configuration file you'll have to start ddclient as shown in the next section.<br>[编辑] How to Get DDclient Started  
  
 
You can configure DDclient to start at boot time using the chkconfig command:  
 
You can configure DDclient to start at boot time using the chkconfig command:  
第151行: 第133行:
 
You can start, stop, and restart DDclient after boot time using the DDclient initialization script as in:  
 
You can start, stop, and restart DDclient after boot time using the DDclient initialization script as in:  
  
[root@bigboy tmp]# service ddclient start&lt;br&gt;[root@bigboy tmp]# service ddclient stop&lt;br&gt;[root@bigboy tmp]# service ddclient restart  
+
[root@bigboy tmp]# service ddclient start<br>[root@bigboy tmp]# service ddclient stop<br>[root@bigboy tmp]# service ddclient restart  
  
 
Remember to restart the ddclient process every time you make a change to the ddclient.conf file for the changes to take effect on the running process.  
 
Remember to restart the ddclient process every time you make a change to the ddclient.conf file for the changes to take effect on the running process.  
第165行: 第147行:
 
Use the rpm command to get a list of installed DDclient files, one of which is the read-me file  
 
Use the rpm command to get a list of installed DDclient files, one of which is the read-me file  
  
[root@bigboy tmp]# rpm -ql ddclient&lt;br&gt;...&lt;br&gt;/usr/doc/ddclient-3.6.3/README&lt;br&gt;...&lt;br&gt;[root@bigboy tmp]#  
+
[root@bigboy tmp]# rpm -ql ddclient<br>...<br>/usr/doc/ddclient-3.6.3/README<br>...<br>[root@bigboy tmp]#  
  
 
Alternately, you can use the locate command to find all the DDclient files:  
 
Alternately, you can use the locate command to find all the DDclient files:  
  
[root@bigboy tmp]# locate ddclient | grep READ&lt;br&gt;/usr/doc/ddclient-3.6.3/README&lt;br&gt;/usr/doc/ddclient-3.6.3/README.cisco&lt;br&gt;[root@bigboy tmp]#  
+
[root@bigboy tmp]# locate ddclient | grep READ<br>/usr/doc/ddclient-3.6.3/README<br>/usr/doc/ddclient-3.6.3/README.cisco<br>[root@bigboy tmp]#  
  
 
If the command doesn't work, try updating your locate database with the locate -u command followed by the locate ddclient command once more:  
 
If the command doesn't work, try updating your locate database with the locate -u command followed by the locate ddclient command once more:  
第179行: 第161行:
 
You can test your dynamic DNS by:  
 
You can test your dynamic DNS by:  
  
*Looking at the status page of your DNS provider and making sure the IP address that matches your www site is the same as your router/firewall's public IP address.&lt;br&gt; * Using the "host www.my-site.com" command from your Linux command prompt to determine whether you are getting a valid response. If you failed to add your host record, you will get an error message like:
+
*Looking at the status page of your DNS provider and making sure the IP address that matches your www site is the same as your router/firewall's public IP address.<br> * Using the "host www.my-site.com" command from your Linux command prompt to determine whether you are getting a valid response. If you failed to add your host record, you will get an error message like:
  
 
[root@bigboy tmp]# host www.my-site.com  
 
[root@bigboy tmp]# host www.my-site.com  
  
Server: 127.0.0.1&lt;br&gt;Address: 127.0.0.1#53  
+
Server: 127.0.0.1<br>Address: 127.0.0.1#53  
  
 
**server can't find www.my-site.com: NXDOMAIN
 
**server can't find www.my-site.com: NXDOMAIN
第189行: 第171行:
 
This error could be because your domain hasn't propagated fully throughout the Internet. You can test to make sure everything is okay by forcing NS lookup to query the name servers directly. The example below queries the miniDNS name server ns1.minidns.net:  
 
This error could be because your domain hasn't propagated fully throughout the Internet. You can test to make sure everything is okay by forcing NS lookup to query the name servers directly. The example below queries the miniDNS name server ns1.minidns.net:  
  
[root@bigboy tmp]# host www.my-site.com ns1.minidns.net&lt;br&gt;www.my-site.com has address 97.158.253.26&lt;br&gt;[root@bigboy tmp]#  
+
[root@bigboy tmp]# host www.my-site.com ns1.minidns.net<br>www.my-site.com has address 97.158.253.26<br>[root@bigboy tmp]#  
  
 
[编辑] Conclusion  
 
[编辑] Conclusion  
  
Always remember that dynamic DNS works, but it is frequently unreliable as residential class broadband data circuits are not monitored, maintained, or managed as closely as business class lines. It is a good starting place to help you become familiar with Web hosting, but as your Web site becomes busier and more financially important to you, you may need to consider a regular data center far away from spilt coffee and the washing machine that always trips the circuit breakers.&nbsp; <br>
+
Always remember that dynamic DNS works, but it is frequently unreliable as residential class broadband data circuits are not monitored, maintained, or managed as closely as business class lines. It is a good starting place to help you become familiar with Web hosting, but as your Web site becomes busier and more financially important to you, you may need to consider a regular data center far away from spilt coffee and the washing machine that always trips the circuit breakers.

2008年6月22日 (日) 01:09的版本




简介


在大多数家庭网络环境,通过DSL或者Cable Modem连接网络的主机IP地址都是通过DHCP获得并随时间经常改变,这会给DNS服务(区域文件)带来问题。第18章“配置DNS”一节假定服务器地址是固定不变的。因此,产生了两大类DNS:

“静态DNS”
当ISP为您提供固定不变的静态IP地址时,你的DNS服务器作为您的站点域认证信息源。你可以把静态DNS看作是DNS的“传统”或“常规”模式。

“动态DNS”
当你通过DHCP从您的ISP处获得动态IP地址时,你就不得不使用第三方DNS提供商来为您的站点域提供DNS信息服务。
本章将详细讲解动态DNS的配置过程。

准备动态DNS

和DSL不同的是,大多数的cable modem供应商(类似有线宽频)不允许你在家开办主机站点,他们阻止入站的HTTP(TCP 端口80)和SMTP 邮件(TCP端口25)而允许其他的TCP通讯.许多动态DNS(DDNS)供应商意识到这点并提供了自动重定向让访问你主机的web客户通过一个不同的TCP端口.尽管这样也工作的很好,但是还是不方便.看起来很诱人的虚拟主机服务却要增加每月$10的费用,并且很多搜索引擎都不索引重定向的页面.


为你的web站点测试ISP(互联网供应商)的连通性

第一件事就是你要知道你的ISP是用DSL还是cable modem,最简单的方法就是打电话问,但是有时候答案是yes但是他们却说no.这时你就要自己做些测试.

设置

在测试开始之前你需要做一些基本调试.

1.在你的Linux web 服务器上配置并且启动Apache,参考第20章 ch20--"The Apache Web Server".

2.直接连接你的linux服务器到cable或者DSL的调制解调器,配置以太网卡的DHCP参数,参考第3章 ch3--"Linux Networking".

3.确认你可以ping到你的默认网关.

4.使用ip设置命令去设置你的web服务器的新的ip地址.(命令用法可以参考底3章).

5.在你的Linux web服务器上,尝试TELNET到新设置的ip地址,端口用80.参考第4章 ch4--"simple Network Trobleshooting".

如果你能完成这几步,说明你有很大的希望去正确配置Apache
[编辑] Testing From The Internet

从互联网测试

这时你应该可以看到页面在你自己的网站上.请朋友在其他地方尝试去telnet(用80端口)你网站的ip地址.

 如果80端口工作正常,再让朋友用浏览器连接你的网站看是否能看到页面.如果你的Linux服务器是在防火墙后面,那你要适当调整下你的网络结构,
 并且测试80端口指向你的服务器.
 如果TELNET到80端口失败,很可能是的ISP不允许HTTP处理.设置你的web站点使用不同的TCP端口,尽量在1024以上.Apache 的httpd.conf文件用来监听管理这个.改变它为你要的数值,然后重启httpd.

#httpd.conf listen directive, 改变 "80"为其他值
Listen 80

 再用telnet测试这个新设置的端口.如果工作,再尝试浏览器测试.如果测试的端口是1234,要使用下面的连接:

http://server-ip-address:1234



注意:如果你在运行iptable, 记住调整规则已匹配新端口,或者在测试期间停止ipstable.如果你能在非标准的端口连接到页面,然后你记下来给你的DDNS供应商做重定向.

测试端口转发

如果你的Linux 服务器是在防火墙的后面,应该适当调整你的网络结构,让Apache运行在端口80,然后从互联网测试端口转发,从非标准

端口到80端口.curl-疑难排解工具的一个特点是他允许你下载页面的HTML的代码到你屏幕上.你应该靠你web服务器的日志能确定你的路由器或者防火墙的外部地址以及curl的命令发出请求到DynDNS.org的ip信息服务器.在这个情况里你只需要关于的ip的资料,用grep命令就可以得到这个部分.在这个范例中,ip地址是24.4.97.110.

[root@bigboy tmp]# curl -s http://checkip.dyndns.org/ | grep -i address
Current IP Address: 24.4.97.110[root@bigboy tmp]# 


注册DDNS

Once you have decided to go ahead with DDNS you'll need to choose between the broad categories of Dynamic DNS service.

  • Free Dynamic DNS: Your website name will be a sub domain of the DDNS provider's domain. For example if the DDNS provider's domain is isp.net, then your site will become my-site.my-isp.net. You can perform all the necessary steps on your DDNS service provider's Web site. Remember that this type of service may be undesirable for a company that wants to establish its own corporate identity. Another disadvantage is that you must rely on your DDNS provider staying in business or else you may lose your domain. When you own your own domain this worry largely goes away as you are fully in control of the DNS registration and renewal process.

Another disadvantage is that you must rely on your DDNS provider staying in business or else you may lose your domain. When you own your own domain this worry largely goes away as you are fully in control of the DNS registration and renewal process.

  • Paid Customized DNS: You can register the domain name of your choice and still host your website on a DHCP line.

If you choose to create your own domain and use a paid DDNS service then you'll need to follow these steps:

1. Register your domains (such as my-site.com) with such companies as Verisign and RegisterFree.
2. Create an account with the DDNS provider and register your websites (sometimes called hosts) as part of your domain (as in www.my-site.com and mail.my-site.com) with them. Your DDNS registration process will provide you with a username and password which you'll need to use when configuring your DDNS client.
3. Update your domain information with your main DNS registrar (Verisign and RegisterFree) to tell them to direct queries to *.my-site.com to the DNS name servers of the DDNS provider.
4. Install a DDNS client on your web servers that continuously runs, only updating the DDNS provider's DNS servers with the most current DHCP IP address of the site whenever it detects a change.

Note: You should also be prepared for slower response times for your home-based site than if you were using a static IP and a regular DNS service.
[编辑] Install a DDNS Client On Your Server

All DDNS service providers require that you use a DDNS client on your web server that will periodically update the IP address information in your provider's DDNS record. The very popular one DDclient, for example, now comes in a RPM format.
[编辑] Dynamic DNS And NAT Router/Firewalls

As discussed in Chapter 2, "Introduction to Networking," to conserve the limited number of IP addresses available for Internet purposes, most home router/firewalls use network address translation (NAT) to map a single, public, DHCP-obtained IP address to the many private IP addresses within your network.

NAT can fool the operation of some DDNS client software. In these cases, the software can report only the true IP address of the Linux box's NIC interface. If the Linux box is being protected behind a NAT router/firewall, then the NIC reports in its data stream to the DDNS provider a private IP address that no one can reach directly via the Internet. The reported value is therefore invalid.

Some DDNS providers use more intelligent clients, such as DDclient, that can be configured to let the DDNS provider record the public IP address from which the data stream is originating. Once this is done, you'll have to also configure your router/firewall to do port forwarding to make all HTTP traffic destined for the IP address of the router/firewall to be exclusively address translated using NAT and forwarded to a single server on your home network. If your firewall is Linux based, then the examples in Chapter 14, "Linux Firewalls Using iptables," will be helpful. Many Web-based small office/home office (SOHO) firewalls have easy interfaces to configure port forwarding, please refer to your manufacturer's manual on how to do this
[编辑] DDNS Client Software - SOHO Router / Firewalls

Most new SOHO router/firewalls have built in dynamic DNS clients for one or more of the major DDNS service providers. There is usually a Dynamic DNS web menu which will prompt for the name of the service provider and your DDNS username and password. With this support, there is no need to install software on your web server.
[编辑] DDNS Client Software - Linux DDclient

One of the most commonly used clients is DDclient, which can overcome the NAT limitations of DDNS by actually logging into your SOHO firewall to determine the latest IP address information. Like most RedHat and Fedora Linux software products, DDclient is available in the RPM format. (If you need a refresher on RPMs, consult Chapter 6, "Installing Linux Software.") You can usually download the software from your DDNS provider, or you can find it at rpmfind.net. The RPM name usually starts with ddclient followed by a version number, as in ddclient-3.6.3-1.noarch.rpm.
[编辑] The /etc/ddclient.conf file

The ddclient.conf file is usually installed completely commented out, but provides many configuration examples for the most popular DDNS providers.

The most important general parameters to configure are:

  • Username: Your DDNS account's login name
    * Password: Your DDNS account's password
    * Use: The method used to determine the IP address to advertise to the DDNS server

Some important DDNS provider parameters are

  • Server: The name of the DDNS provider's main DNS server
    * Protocol: The methodology the DDNS client should use to communicate with the DDNS server
    * Your domain: The domain to which your web server will belong

You can use the ddclient command to determine the best use parameter to use in the ddclient.conf file. In this example, only the use=web option gives a valid Internet IP address and should be considered as a first option:

[root@bigboy tmp]# ddclient -daemon=0 -query
use=if, if=lo address is 127.0.0.1
use=if, if=wlan0 address is 192.168.1.100
use=web, web=dyndns address is 97.158.253.26
[root@bigboy tmp]#

Take a look at a sample configuration. This example specifies a username of my-account-login-name and a password of my-account-password using the dyndns DDNS service provider's settings to track the Web site named mysite-example.dnsalias.com.

  1. General Parameter Section

login=my-account-login-name
password=my-account-password

  1. DDNS Provider Parameters Section

server=members.dyndns.org, \
protocol=dyndns2 \
mysite-example.dnsalias.com

You can add one of the following use lines to the General Parameter Section near the top of the file to define the method that will be used to determine the correct IP address:

  • Query A Well Known Internet Server: The web method queries two well known servers run by DynDNS.org and DNSpark to determine the public Internet IP address of the web server running the DDclient software. This method is the simplest as it requires no further information and handles NAT correctly.

use=web

  • Use The IP Address Of A Specific Server NIC : You can also use this option which will query the IP address of the DDclient web server's NIC interface of your choice. This is probably most valuable for servers connected directly to the Internet, and not via NAT

use=if, if=eth0

  • Login To Your SOHO Firewall For Information: The ddclient.conf file has a list of use statements for various vendor's firewalls. If your model isn't listed, you can create your own parameters as outlined in the ddclient README file. This option is good for NAT environments where the "use=web" option isn't considered a good alternative.

After editing your configuration file you'll have to start ddclient as shown in the next section.
[编辑] How to Get DDclient Started

You can configure DDclient to start at boot time using the chkconfig command:

[root@bigboy tmp]# chkconfig ddclient on

You can start, stop, and restart DDclient after boot time using the DDclient initialization script as in:

[root@bigboy tmp]# service ddclient start
[root@bigboy tmp]# service ddclient stop
[root@bigboy tmp]# service ddclient restart

Remember to restart the ddclient process every time you make a change to the ddclient.conf file for the changes to take effect on the running process.

You can test whether the ddclient process is running with the pgrep command, you should get a response of plain old process ID numbers:

[root@bigboy tmp]# pgrep ddclient

[编辑] Finding DDclient Help

The DDclient read-me and ddclient.conf files are good sources of information for doing custom configurations and troubleshooting. You can find the read-me file by using DDclient RPMs or the locate command.

Use the rpm command to get a list of installed DDclient files, one of which is the read-me file

[root@bigboy tmp]# rpm -ql ddclient
...
/usr/doc/ddclient-3.6.3/README
...
[root@bigboy tmp]#

Alternately, you can use the locate command to find all the DDclient files:

[root@bigboy tmp]# locate ddclient | grep READ
/usr/doc/ddclient-3.6.3/README
/usr/doc/ddclient-3.6.3/README.cisco
[root@bigboy tmp]#

If the command doesn't work, try updating your locate database with the locate -u command followed by the locate ddclient command once more:

[root@bigboy tmp]# locate -u

[编辑] Testing Your Dynamic DNS

You can test your dynamic DNS by:

  • Looking at the status page of your DNS provider and making sure the IP address that matches your www site is the same as your router/firewall's public IP address.
    * Using the "host www.my-site.com" command from your Linux command prompt to determine whether you are getting a valid response. If you failed to add your host record, you will get an error message like:

[root@bigboy tmp]# host www.my-site.com

Server: 127.0.0.1
Address: 127.0.0.1#53

    • server can't find www.my-site.com: NXDOMAIN

This error could be because your domain hasn't propagated fully throughout the Internet. You can test to make sure everything is okay by forcing NS lookup to query the name servers directly. The example below queries the miniDNS name server ns1.minidns.net:

[root@bigboy tmp]# host www.my-site.com ns1.minidns.net
www.my-site.com has address 97.158.253.26
[root@bigboy tmp]#

[编辑] Conclusion

Always remember that dynamic DNS works, but it is frequently unreliable as residential class broadband data circuits are not monitored, maintained, or managed as closely as business class lines. It is a good starting place to help you become familiar with Web hosting, but as your Web site becomes busier and more financially important to you, you may need to consider a regular data center far away from spilt coffee and the washing machine that always trips the circuit breakers.