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