]> granicus.if.org Git - apache/blob - docs/manual/dns-caveats.html.en
update transformation - en
[apache] / docs / manual / dns-caveats.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>Issues Regarding DNS and Apache - Apache HTTP Server</title>
9 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.1</p>
16 <img alt="" src="./images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
18 <div id="path">
19 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="./">Version 2.1</a></div><div id="page-content"><div id="preamble"><h1>Issues Regarding DNS and Apache</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="./en/dns-caveats.html" hreflang="en" title="English">&nbsp;en&nbsp;</a> | <a href="./ja/dns-caveats.html" hreflang="ja" title="Japanese">&nbsp;ja&nbsp;</a> | <a href="./ko/dns-caveats.html" hreflang="ko" title="Korean">&nbsp;ko&nbsp;</a></p>
22 </div>
23
24     <p>This page could be summarized with the statement: don't require Apache 
25     to use DNS for any parsing of the configuration files. If Apache has to 
26     use DNS to parse the configuration files then your server may be subject 
27     to reliability problems (it might not boot), or denial and theft of 
28     service attacks (including users able to steal hits from other users).</p>
29   </div>
30 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#example">A Simple Example</a></li>
31 <li><img alt="" src="./images/down.gif" /> <a href="#denial">Denial of Service</a></li>
32 <li><img alt="" src="./images/down.gif" /> <a href="#main">The "main server" Address</a></li>
33 <li><img alt="" src="./images/down.gif" /> <a href="#tips">Tips to Avoid These Problems</a></li>
34 <li><img alt="" src="./images/down.gif" /> <a href="#appendix">Appendix: Future Directions</a></li>
35 </ul></div>
36 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
37 <div class="section">
38 <h2><a name="example" id="example">A Simple Example</a></h2>
39     
40     
41     <div class="example"><p><code>
42       &lt;VirtualHost www.abc.dom&gt; <br />
43       ServerAdmin webgirl@abc.dom <br />
44       DocumentRoot /www/abc <br />
45       &lt;/VirtualHost&gt;
46     </code></p></div>
47     
48     <p>In order for Apache to function properly it absolutely needs
49     to have two pieces of information about each virtual host: the
50     <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code>
51     and at least one IP address that the server responds to. This
52     example does not include the IP address, so Apache must use DNS
53     to find the address of <code>www.abc.dom</code>. If for some
54     reason DNS is not available at the time your server is parsing
55     its config file, then this virtual host <strong>will not be
56     configured</strong>. It won't be able to respond to any hits to
57     this virtual host (prior to Apache version 1.2 the server would
58     not even boot).</p>
59     
60     <p>Suppose that <code>www.abc.dom</code> has address 10.0.0.1.
61     Then consider this configuration snippet:</p>
62     
63     <div class="example"><p><code>
64       &lt;VirtualHost 10.0.0.1&gt; <br />
65       ServerAdmin webgirl@abc.dom <br />
66       DocumentRoot /www/abc <br />
67       &lt;/VirtualHost&gt;
68     </code></p></div>
69     
70     <p>Now Apache needs to use reverse DNS to find the
71     <code>ServerName</code> for this virtualhost. If that reverse
72     lookup fails then it will partially disable the virtualhost
73     (prior to Apache version 1.2 the server would not even boot).
74     If the virtual host is name-based then it will effectively be
75     totally disabled, but if it is IP-based then it will mostly
76     work. However if Apache should ever have to generate a full URL
77     for the server which includes the server name then it will fail
78     to generate a valid URL.</p>
79     
80     <p>Here is a snippet that avoids both of these problems.</p>
81     
82     <div class="example"><p><code>
83       &lt;VirtualHost 10.0.0.1&gt; <br />
84       ServerName www.abc.dom <br />
85       ServerAdmin webgirl@abc.dom <br />
86       DocumentRoot /www/abc <br />
87       &lt;/VirtualHost&gt;
88     </code></p></div>
89   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
90 <div class="section">
91 <h2><a name="denial" id="denial">Denial of Service</a></h2>
92     
93     
94     <p>There are (at least) two forms that denial of service can
95     come in. If you are running a version of Apache prior to
96     version 1.2 then your server will not even boot if one of the
97     two DNS lookups mentioned above fails for any of your virtual
98     hosts. In some cases this DNS lookup may not even be under your
99     control. For example, if <code>abc.dom</code> is one of your
100     customers and they control their own DNS then they can force
101     your (pre-1.2) server to fail while booting simply by deleting
102     the <code>www.abc.dom</code> record.</p>
103     
104     <p>Another form is far more insidious. Consider this
105     configuration snippet:</p>
106     
107     <div class="example"><p><code>
108       &lt;VirtualHost www.abc.dom&gt; <br />
109       &nbsp;&nbsp;ServerAdmin webgirl@abc.dom <br />
110       &nbsp;&nbsp;DocumentRoot /www/abc <br />
111       &lt;/VirtualHost&gt; <br />
112       <br />
113       &lt;VirtualHost www.def.dom&gt; <br />
114       &nbsp;&nbsp;ServerAdmin webguy@def.dom <br />
115       &nbsp;&nbsp;DocumentRoot /www/def <br />
116       &lt;/VirtualHost&gt;
117     </code></p></div>
118     
119     <p>Suppose that you've assigned 10.0.0.1 to
120     <code>www.abc.dom</code> and 10.0.0.2 to
121     <code>www.def.dom</code>. Furthermore, suppose that
122     <code>def.dom</code> has control of their own DNS. With this
123     config you have put <code>def.dom</code> into a position where
124     they can steal all traffic destined to <code>abc.dom</code>. To
125     do so, all they have to do is set <code>www.def.dom</code> to
126     10.0.0.1. Since they control their own DNS you can't stop them
127     from pointing the <code>www.def.dom</code> record wherever they
128     wish.</p>
129     
130     <p>Requests coming in to 10.0.0.1 (including all those where
131     users typed in URLs of the form
132     <code>http://www.abc.dom/whatever</code>) will all be served by
133     the <code>def.dom</code> virtual host. To better understand why
134     this happens requires a more in-depth discussion of how Apache
135     matches up incoming requests with the virtual host that will
136     serve it. A rough document describing this <a href="vhosts/details.html">is available</a>.</p>
137   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
138 <div class="section">
139 <h2><a name="main" id="main">The "main server" Address</a></h2>
140     
141     
142     <p>The addition of <a href="vhosts/name-based.html">name-based
143     virtual host support</a> in Apache 1.1 requires Apache to know
144     the IP address(es) of the host that httpd is running on. To get
145     this address it uses either the global 
146     <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code>
147     (if present) or calls the C function <code>gethostname</code>
148     (which should return the same as typing "hostname" at the
149     command prompt). Then it performs a DNS lookup on this address.
150     At present there is no way to avoid this lookup.</p>
151     
152     <p>If you fear that this lookup might fail because your DNS
153     server is down then you can insert the hostname in
154     <code>/etc/hosts</code> (where you probably already have it so
155     that the machine can boot properly). Then ensure that your
156     machine is configured to use <code>/etc/hosts</code> in the
157     event that DNS fails. Depending on what OS you are using this
158     might be accomplished by editing <code>/etc/resolv.conf</code>,
159     or maybe <code>/etc/nsswitch.conf</code>.</p>
160     
161     <p>If your server doesn't have to perform DNS for any other
162     reason then you might be able to get away with running Apache
163     with the <code>HOSTRESORDER</code> environment variable set to
164     "local". This all depends on what OS and resolver libraries you
165     are using. It also affects CGIs unless you use 
166     <code class="module"><a href="./mod/mod_env.html">mod_env</a></code> to control the environment. It's best 
167     to consult the man pages or FAQs for your OS.</p>
168   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
169 <div class="section">
170 <h2><a name="tips" id="tips">Tips to Avoid These Problems</a></h2>
171     
172     
173     <ul>
174       <li>
175         use IP addresses in 
176         <code class="directive"><a href="./mod/core.html#virtualhost">VirtualHost</a></code>
177       </li>
178     
179       <li>
180         use IP addresses in 
181         <code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code>
182       </li>
183     
184       <li>
185         ensure all virtual hosts have an explicit
186         <code class="directive"><a href="./mod/core.html#servername">ServerName</a></code>
187       </li>
188     
189       <li>create a <code>&lt;VirtualHost _default_:*&gt;</code>
190       server that has no pages to serve</li>
191     </ul>
192   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
193 <div class="section">
194 <h2><a name="appendix" id="appendix">Appendix: Future Directions</a></h2>
195     
196     
197     <p>The situation regarding DNS is highly undesirable. For
198     Apache 1.2 we've attempted to make the server at least continue
199     booting in the event of failed DNS, but it might not be the
200     best we can do. In any event requiring the use of explicit IP
201     addresses in configuration files is highly undesirable in
202     today's Internet where renumbering is a necessity.</p>
203     
204     <p>A possible work around to the theft of service attack
205     described above would be to perform a reverse DNS lookup on the
206     ip address returned by the forward lookup and compare the two
207     names. In the event of a mismatch the virtualhost would be
208     disabled. This would require reverse DNS to be configured
209     properly (which is something that most admins are familiar with
210     because of the common use of "double-reverse" DNS lookups by
211     FTP servers and TCP wrappers).</p>
212     
213     <p>In any event it doesn't seem possible to reliably boot a
214     virtual-hosted web server when DNS has failed unless IP
215     addresses are used. Partial solutions such as disabling
216     portions of the configuration might be worse than not booting
217     at all depending on what the webserver is supposed to
218     accomplish.</p>
219     
220     <p>As HTTP/1.1 is deployed and browsers and proxies start
221     issuing the <code>Host</code> header it will become possible to
222     avoid the use of IP-based virtual hosts entirely. In this event
223     a webserver has no requirement to do DNS lookups during
224     configuration. But as of March 1997 these features have not
225     been deployed widely enough to be put into use on critical
226     webservers.</p>
227   </div></div>
228 <div class="bottomlang">
229 <p><span>Available Languages: </span><a href="./en/dns-caveats.html" hreflang="en" title="English">&nbsp;en&nbsp;</a> | <a href="./ja/dns-caveats.html" hreflang="ja" title="Japanese">&nbsp;ja&nbsp;</a> | <a href="./ko/dns-caveats.html" hreflang="ko" title="Korean">&nbsp;ko&nbsp;</a></p>
230 </div><div id="footer">
231 <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
232 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
233 </body></html>