1703N/A - Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") 0N/A - Copyright (C) 2000-2003 Internet Software Consortium. 0N/A - Permission to use, copy, modify, and/or distribute this software for any 0N/A - purpose with or without fee is hereby granted, provided that the above 0N/A - copyright notice and this permission notice appear in all copies. 0N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 0N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 0N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 0N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 0N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 0N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 0N/A - PERFORMANCE OF THIS SOFTWARE. 1472N/A<
meta http-
equiv="Content-Type" content="text/html; charset=ISO-8859-1">
1472N/A<
title>Chapter�7.�BIND 9 Security Considerations</
title>
1472N/A<
meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
0N/A<
link rel="up" href="Bv9ARM.html" title="BIND 9 Administrator Reference Manual">
0N/A<
body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
0N/A<
div class="navheader">
0N/A<
table width="100%" summary="Navigation header">
0N/A<
tr><
th colspan="3" align="center">Chapter�7.�<
acronym class="acronym">BIND</
acronym> 9 Security Considerations</
th></
tr>
0N/A<
td width="20%" align="left">
0N/A<
th width="60%" align="center">�</
th>
0N/A<
div class="chapter">
0N/A<
div class="titlepage"><
div><
div><
h1 class="title">
0N/A<
a name="Bv9ARM.ch07"></
a>Chapter�7.�<
acronym class="acronym">BIND</
acronym> 9 Security Considerations</
h1></
div></
div></
div>
1703N/A<
p><
b>Table of Contents</
b></
p>
0N/A<
dt><
span class="section"><
a href="Bv9ARM.ch07.html#Access_Control_Lists">Access Control Lists</
a></
span></
dt>
0N/A<
dt><
span class="section"><
a href="Bv9ARM.ch07.html#chroot_and_setuid"><
span class="command"><
strong>Chroot</
strong></
span> and <
span class="command"><
strong>Setuid</
strong></
span></
a></
span></
dt>
0N/A<
dt><
span class="section"><
a href="Bv9ARM.ch07.html#chroot">The <
span class="command"><
strong>chroot</
strong></
span> Environment</
a></
span></
dt>
0N/A<
dt><
span class="section"><
a href="Bv9ARM.ch07.html#setuid">Using the <
span class="command"><
strong>setuid</
strong></
span> Function</
a></
span></
dt>
91N/A<
dt><
span class="section"><
a href="Bv9ARM.ch07.html#dynamic_update_security">Dynamic Update Security</
a></
span></
dt>
0N/A<
div class="section">
0N/A<
div class="titlepage"><
div><
div><
h2 class="title" style="clear: both">
0N/A<
a name="Access_Control_Lists"></
a>Access Control Lists</
h2></
div></
div></
div>
0N/A Access Control Lists (ACLs) are address match lists that
0N/A you can set up and nickname for future use in
0N/A <
span class="command"><
strong>allow-notify</
strong></
span>, <
span class="command"><
strong>allow-query</
strong></
span>,
0N/A <
span class="command"><
strong>allow-query-on</
strong></
span>, <
span class="command"><
strong>allow-recursion</
strong></
span>,
0N/A <
span class="command"><
strong>blackhole</
strong></
span>, <
span class="command"><
strong>allow-transfer</
strong></
span>,
0N/A <
span class="command"><
strong>match-clients</
strong></
span>, etc.
0N/A Using ACLs allows you to have finer control over who can access
0N/A your name server, without cluttering up your config files with huge
0N/A lists of IP addresses.
0N/A It is a <
span class="emphasis"><
em>good idea</
em></
span> to use ACLs, and to
0N/A control access to your server. Limiting access to your server by
0N/A outside parties can help prevent spoofing and denial of service
0N/A (DoS) attacks against your server.
0N/A ACLs match clients on the basis of up to three characteristics:
0N/A 1) The client's IP address; 2) the TSIG or SIG(0) key that was
0N/A used to sign the request, if any; and 3) an address prefix
0N/A encoded in an EDNS Client Subnet option, if any.
0N/A Here is an example of ACLs based on client addresses:
0N/A<
pre class="programlisting">
0N/A// Set up an ACL named "bogusnets" that will block
0N/A// RFC1918 space and some reserved space, which is
0N/A// commonly used in spoofing attacks.
0N/A// Set up an ACL called our-nets. Replace this with the
0N/A allow-query { our-nets; };
0N/A allow-recursion { our-nets; };
0N/A blackhole { bogusnets; };
0N/A allow-query { any; };
0N/A address, but recursive queries only from the networks specified
0N/A in "our-nets", and no queries at all from the networks
0N/A specified in "bogusnets".
0N/A In addition to network addresses and prefixes, which are
0N/A matched against the source address of the DNS request, ACLs
0N/A may include <
code class="option">key</
code> elements, which specify the
0N/A name of a TSIG or SIG(0) key, or <
code class="option">ecs</
code>
0N/A elements, which specify a network prefix but are only matched
0N/A if that prefix matches an EDNS client subnet option included
0N/A The EDNS Client Subnet (ECS) option is used by a recursive
0N/A resolver to inform an authoritative name server of the network
0N/A address block from which the original query was received, enabling
0N/A authoritative servers to give different answers to the same
0N/A resolver for different resolver clients. An ACL containing
0N/A an element of the form
0N/A <
span class="command"><
strong>ecs <
em class="replaceable"><
code>prefix</
code></
em></
strong></
span>
0N/A will match if a request arrives in containing an ECS option
0N/A encoding an address within that prefix. If the request has no
0N/A ECS option, then "ecs" elements are simply ignored. Addresses
0N/A in ACLs that are not prefixed with "ecs" are matched only
0N/A against the source address.
0N/A When <
acronym class="acronym">BIND</
acronym> 9 is built with GeoIP support,
0N/A ACLs can also be used for geographic access restrictions.
0N/A This is done by specifying an ACL element of the form:
0N/A <
span class="command"><
strong>geoip [<
span class="optional">db <
em class="replaceable"><
code>database</
code></
em></
span>] <
em class="replaceable"><
code>field</
code></
em> <
em class="replaceable"><
code>value</
code></
em></
strong></
span>
0N/A The <
em class="replaceable"><
code>field</
code></
em> indicates which field
0N/A to search for a match. Available fields are "country",
0N/A "region", "city", "continent", "postal" (postal code),
0N/A "metro" (metro code), "area" (area code), "tz" (timezone),
0N/A "isp", "org", "asnum", "domain" and "netspeed".
0N/A <
em class="replaceable"><
code>value</
code></
em> is the value to search
0N/A for within the database. A string may be quoted if it
0N/A contains spaces or other special characters. If this is
0N/A an "asnum" search, then the leading "ASNNNN" string can be
0N/A used, otherwise the full description must be used (
e.g. 0N/A "ASNNNN Example Company Name"). If this is a "country"
0N/A search and the string is two characters long, then it must
0N/A be a standard ISO-3166-1 two-letter country code, and if it
91N/A is three characters long then it must be an ISO-3166-1
0N/A three-letter country code; otherwise it is the full name
0N/A of the country. Similarly, if this is a "region" search
0N/A and the string is two characters long, then it must be a
0N/A standard two-letter state or province abbreviation;
0N/A otherwise it is the full name of the state or province.
0N/A The <
em class="replaceable"><
code>database</
code></
em> field indicates which
0N/A GeoIP database to search for a match. In most cases this is
0N/A unnecessary, because most search fields can only be found in
0N/A a single database. However, searches for country can be
0N/A answered from the "city", "region", or "country" databases,
0N/A and searches for region (
i.e., state or province) can be
0N/A answered from the "city" or "region" databases. For these
0N/A search types, specifying a <
em class="replaceable"><
code>database</
code></
em>
0N/A will force the query to be answered from that database and no
0N/A other. If <
em class="replaceable"><
code>database</
code></
em> is not
0N/A specified, then these queries will be answered from the "city",
0N/A database if it is installed, or the "region" database if it is
0N/A installed, or the "country" database, in that order.
0N/A By default, if a DNS query includes an EDNS Client Subnet (ECS)
0N/A option which encodes a non-zero address prefix, then GeoIP ACLs
0N/A will be matched against that address prefix. Otherwise, they
0N/A are matched against the source address of the query. To
0N/A prevent GeoIP ACLs from matching against ECS options, set
0N/A the <
span class="command"><
strong>geoip-use-ecs</
strong></
span> to <
code class="literal">no</
code>.
0N/A Some example GeoIP ACLs:
0N/A<
pre class="programlisting">geoip country US;
0N/Ageoip db country country Canada;
0N/Ageoip db region region WA;
0N/Ageoip city "San Francisco";
0N/Ageoip region Oklahoma;
0N/Ageoip org "Internet Systems Consortium";
0N/A ACLs use a "first-match" logic rather than "best-match":
0N/A if an address prefix matches an ACL element, then that ACL
0N/A is considered to have matched even if a later element would
0N/A have matched more specifically. For example, the ACL
91N/A <
span class="command"><
strong> { 10/8; !10.0.0.1; }</
strong></
span> would actually
0N/A match a query from 10.0.0.1, because the first element
0N/A indicated that the query should be accepted, and the second
91N/A element is ignored.
0N/A When using "nested" ACLs (that is, ACLs included or referenced
0N/A within other ACLs), a negative match of a nested ACL will
91N/A the containing ACL to continue looking for matches. This
0N/A enables complex ACLs to be constructed, in which multiple
0N/A client characteristics can be checked at the same time. For
0N/A example, to construct an ACL which allows queries only when
91N/A it originates from a particular network <
span class="emphasis"><
em>and</
em></
span>
0N/A only when it is signed with a particular key, use:
0N/A<
pre class="programlisting">
91N/Aallow-query { !{ !10/8; any; }; key example; };
0N/A Within the nested ACL, any address that is
0N/A <
span class="emphasis"><
em>not</
em></
span> in the 10/8 network prefix will
0N/A be rejected, and this will terminate processing of the
0N/A ACL. Any address that <
span class="emphasis"><
em>is</
em></
span> in the 10/8
0N/A network prefix will be accepted, but this causes a negative
0N/A match of the nested ACL, so the containing ACL continues
0N/A processing. The query will then be accepted if it is signed
0N/A by the key "example", and rejected otherwise. The ACL, then,
0N/A will only matches when <
span class="emphasis"><
em>both</
em></
span> conditions
0N/A<
div class="section">
0N/A<
div class="titlepage"><
div><
div><
h2 class="title" style="clear: both">
0N/A<
a name="chroot_and_setuid"></
a><
span class="command"><
strong>Chroot</
strong></
span> and <
span class="command"><
strong>Setuid</
strong></
span>
0N/A</
h2></
div></
div></
div>
0N/A On UNIX servers, it is possible to run <
acronym class="acronym">BIND</
acronym>
0N/A in a <
span class="emphasis"><
em>chrooted</
em></
span> environment (using
0N/A the <
span class="command"><
strong>chroot()</
strong></
span> function) by specifying
0N/A the <
code class="option">-t</
code> option for <
span class="command"><
strong>named</
strong></
span>.
0N/A This can help improve system security by placing
0N/A <
acronym class="acronym">BIND</
acronym> in a "sandbox", which will limit
0N/A the damage done if a server is compromised.
0N/A Another useful feature in the UNIX version of <
acronym class="acronym">BIND</
acronym> is the
0N/A ability to run the daemon as an unprivileged user ( <
code class="option">-u</
code> <
em class="replaceable"><
code>user</
code></
em> ).
0N/A We suggest running as an unprivileged user when using the <
span class="command"><
strong>chroot</
strong></
span> feature.
0N/A Here is an example command line to load <
acronym class="acronym">BIND</
acronym> in a <
span class="command"><
strong>chroot</
strong></
span> sandbox,
0N/A <
span class="command"><
strong>/
var/
named</
strong></
span>, and to run <
span class="command"><
strong>named</
strong></
span> <
span class="command"><
strong>setuid</
strong></
span> to
0N/A<
div class="section">
0N/A<
div class="titlepage"><
div><
div><
h3 class="title">
0N/A<
a name="chroot"></
a>The <
span class="command"><
strong>chroot</
strong></
span> Environment</
h3></
div></
div></
div>
0N/A In order for a <
span class="command"><
strong>chroot</
strong></
span> environment
0N/A to work properly in a particular directory (for example,
0N/A <
code class="filename">/
var/
named</
code>), you will need to set
0N/A up an environment that includes everything
0N/A <
acronym class="acronym">BIND</
acronym> needs to run. From
91N/A <
acronym class="acronym">BIND</
acronym>'s point of view,
0N/A <
code class="filename">/
var/
named</
code> is the root of the
0N/A filesystem. You will need to adjust the values of
0N/A options like <
span class="command"><
strong>directory</
strong></
span> and
0N/A <
span class="command"><
strong>pid-file</
strong></
span> to account for this.
0N/A Unlike with earlier versions of BIND, you typically will
0N/A <
span class="emphasis"><
em>not</
em></
span> need to compile <
span class="command"><
strong>named</
strong></
span>
0N/A statically nor install shared libraries under the new root.
0N/A However, depending on your operating system, you may need
0N/A to set up things like
0N/A<
div class="section">
0N/A<
div class="titlepage"><
div><
div><
h3 class="title">
0N/A<
a name="setuid"></
a>Using the <
span class="command"><
strong>setuid</
strong></
span> Function</
h3></
div></
div></
div>
0N/A Prior to running the <
span class="command"><
strong>named</
strong></
span> daemon,
0N/A the <
span class="command"><
strong>touch</
strong></
span> utility (to change file
modification times) or the <
span class="command"><
strong>chown</
strong></
span>
set the user id
and/
or group id) on files
to which you want <
acronym class="acronym">BIND</
acronym>
<
div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<
h3 class="title">Note</
h3>
If the <
span class="command"><
strong>named</
strong></
span> daemon is running as an
unprivileged user, it will not be able to bind to new restricted
ports if the server is reloaded.
<
div class="titlepage"><
div><
div><
h2 class="title" style="clear: both">
<
a name="dynamic_update_security"></
a>Dynamic Update Security</
h2></
div></
div></
div>
update facility should be strictly limited. In earlier versions of
<
acronym class="acronym">BIND</
acronym>, the only way to do this was
address of the host requesting the update, by listing an IP address
network prefix in the <
span class="command"><
strong>allow-update</
strong></
span>
This method is insecure since the source address of the update UDP
is easily forged. Also note that if the IP addresses allowed by the
<
span class="command"><
strong>allow-update</
strong></
span> option include the
server which performs forwarding of dynamic updates, the master can
trivially attacked by sending the update to the slave, which will
forward it to the master with its own source IP address causing the
master to approve it without question.
For these reasons, we strongly recommend that updates be
cryptographically authenticated by means of transaction signatures
(TSIG). That is, the <
span class="command"><
strong>allow-update</
strong></
span>
list only TSIG key names, not IP addresses or network
prefixes. Alternatively, the new <
span class="command"><
strong>update-policy</
strong></
span>
Some sites choose to keep all dynamically-updated DNS data
in a subdomain and delegate that subdomain to a separate zone. This
way, the top-level zone containing critical data such as the IP
of public web and mail servers need not allow dynamic update at
<
table width="100%" summary="Navigation footer">
<
td width="40%" align="left">
<
td width="20%" align="center">�</
td>
<
td width="40%" align="right">�<
a accesskey="n" href="Bv9ARM.ch08.html">Next</
a>
<
td width="40%" align="left" valign="top">Chapter�6.�<
acronym class="acronym">BIND</
acronym> 9 Configuration Reference�</
td>
<
td width="20%" align="center"><
a accesskey="h" href="Bv9ARM.html">Home</
a></
td>
<
td width="40%" align="right" valign="top">�Chapter�8.�Troubleshooting</
td>