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