mirror of
https://github.com/Zeckmathederg/glfs.git
synced 2025-01-27 18:02:12 +08:00
ae9c5281f1
git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@1941 af4574ff-66df-0310-9fd7-8a98e5e911e0
186 lines
7.3 KiB
XML
186 lines
7.3 KiB
XML
<sect2>
|
|
<title>Configuring
|
|
<application><acronym>BIND</acronym></application></title>
|
|
|
|
<sect3><title>Config files</title>
|
|
<para><filename>named.conf</filename>, <filename>root.hints</filename>,
|
|
<filename>127.0.0</filename>, <filename>rndc.conf</filename></para>
|
|
</sect3>
|
|
|
|
<sect3><title>Configuration Information</title>
|
|
|
|
<para>We will configure
|
|
<application><acronym>BIND</acronym></application> to run in a chroot
|
|
jail as an unprivileged user (named). This configuration is more secure
|
|
in that a <acronym>DNS</acronym> compromise can only affect a few files
|
|
in the named user's <envar>HOME</envar> directory.</para>
|
|
|
|
<para>First we create the unprivileged user and group named:</para>
|
|
|
|
<screen><userinput><command>groupadd -g 200 named &&
|
|
useradd -m -g named -u 200 -s /bin/false named</command></userinput></screen>
|
|
|
|
<para>Then we set up some files, directories and devices needed by
|
|
<application><acronym>BIND</acronym></application>:</para>
|
|
|
|
<screen><userinput><command>cd /home/named &&
|
|
mkdir -p dev etc/namedb/slave var/run &&
|
|
mknod /home/named/dev/null c 1 3 &&
|
|
mknod /home/named/dev/random c 1 8 &&
|
|
chmod 666 /home/named/dev/{null,random} &&
|
|
mkdir /home/named/etc/namedb/pz &&
|
|
cp /etc/localtime /home/named/etc</command></userinput></screen>
|
|
|
|
<para>Create the <filename>named.conf</filename> file from which named
|
|
will read the location of zone files, root name servers and secure
|
|
<acronym>DNS</acronym> keys:</para>
|
|
|
|
<screen><userinput><command>cat > /home/named/etc/named.conf << "EOF"</command>
|
|
options {
|
|
directory "/etc/namedb";
|
|
pid-file "/var/run/named.pid";
|
|
statistics-file "/var/run/named.stats";
|
|
|
|
};
|
|
controls {
|
|
inet 127.0.0.1 allow { localhost; } keys { rndc_key; };
|
|
};
|
|
key "rndc_key" {
|
|
algorithm hmac-md5;
|
|
secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
|
|
};
|
|
zone "." {
|
|
type hint;
|
|
file "root.hints";
|
|
};
|
|
zone "0.0.127.in-addr.arpa" {
|
|
type master;
|
|
file "pz/127.0.0";
|
|
};
|
|
<command>EOF</command></userinput></screen>
|
|
|
|
<para>Create a zone file with the following contents:</para>
|
|
|
|
<screen><userinput><command>cat > /home/named/etc/namedb/pz/127.0.0 << "EOF"</command>
|
|
$TTL 3D
|
|
@ IN SOA ns.local.domain. hostmaster.local.domain. (
|
|
1 ; Serial
|
|
8H ; Refresh
|
|
2H ; Retry
|
|
4W ; Expire
|
|
1D) ; Minimum TTL
|
|
NS ns.local.domain.
|
|
1 PTR localhost.
|
|
<command>EOF</command></userinput></screen>
|
|
|
|
<para>Create the <filename>root.hints</filename> file with the following
|
|
commands:</para>
|
|
|
|
<note><para>Caution must be used to insure no leading spaces in this
|
|
file.</para></note>
|
|
|
|
<screen><userinput><command>cat > /home/named/etc/namedb/root.hints << "EOF"</command>
|
|
. 6D IN NS A.ROOT-SERVERS.NET.
|
|
. 6D IN NS B.ROOT-SERVERS.NET.
|
|
. 6D IN NS C.ROOT-SERVERS.NET.
|
|
. 6D IN NS D.ROOT-SERVERS.NET.
|
|
. 6D IN NS E.ROOT-SERVERS.NET.
|
|
. 6D IN NS F.ROOT-SERVERS.NET.
|
|
. 6D IN NS G.ROOT-SERVERS.NET.
|
|
. 6D IN NS H.ROOT-SERVERS.NET.
|
|
. 6D IN NS I.ROOT-SERVERS.NET.
|
|
. 6D IN NS J.ROOT-SERVERS.NET.
|
|
. 6D IN NS K.ROOT-SERVERS.NET.
|
|
. 6D IN NS L.ROOT-SERVERS.NET.
|
|
. 6D IN NS M.ROOT-SERVERS.NET.
|
|
A.ROOT-SERVERS.NET. 6D IN A 198.41.0.4
|
|
B.ROOT-SERVERS.NET. 6D IN A 128.9.0.107
|
|
C.ROOT-SERVERS.NET. 6D IN A 192.33.4.12
|
|
D.ROOT-SERVERS.NET. 6D IN A 128.8.10.90
|
|
E.ROOT-SERVERS.NET. 6D IN A 192.203.230.10
|
|
F.ROOT-SERVERS.NET. 6D IN A 192.5.5.241
|
|
G.ROOT-SERVERS.NET. 6D IN A 192.112.36.4
|
|
H.ROOT-SERVERS.NET. 6D IN A 128.63.2.53
|
|
I.ROOT-SERVERS.NET. 6D IN A 192.36.148.17
|
|
J.ROOT-SERVERS.NET. 6D IN A 192.58.128.30
|
|
K.ROOT-SERVERS.NET. 6D IN A 193.0.14.129
|
|
L.ROOT-SERVERS.NET. 6D IN A 198.32.64.12
|
|
M.ROOT-SERVERS.NET. 6D IN A 202.12.27.33
|
|
<command>EOF</command></userinput></screen>
|
|
|
|
<para>The <filename>root.hints</filename> file is a list of root name
|
|
servers. This file must be updated periodically with the
|
|
<command>dig</command> utility.
|
|
Consult the <application><acronym>BIND</acronym></application> 9 Administrator Reference Manual for
|
|
details.</para>
|
|
|
|
<para>Create the <filename>rndc.conf</filename> with the following commands:</para>
|
|
|
|
<screen><userinput><command>cat > /etc/rndc.conf << "EOF"</command>
|
|
key rndc_key {
|
|
algorithm "hmac-md5";
|
|
secret
|
|
"c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
|
|
};
|
|
options {
|
|
default-server localhost;
|
|
default-key rndc_key;
|
|
};
|
|
<command>EOF</command></userinput></screen>
|
|
|
|
<para>The <filename>rndc.conf</filename> file contains information for
|
|
controlling named operations with the <command>rndc</command>
|
|
utility.</para>
|
|
|
|
<para>Create or modify <filename>resolv.conf</filename> to use the new
|
|
name server with the following commands:</para>
|
|
|
|
<note><para>Replace yourdomain.com with your own valid domain
|
|
name.</para></note>
|
|
|
|
<screen><userinput><command>cp /etc/resolv.conf /etc/resolv.conf.bak &&
|
|
cat > /etc/resolv.conf << "EOF"</command>
|
|
search yourdomain.com
|
|
nameserver 127.0.0.1
|
|
<command>EOF</command></userinput></screen>
|
|
|
|
<para>Set permissions on the chroot jail with the following
|
|
command:</para>
|
|
|
|
<screen><userinput><command>chown -R named.named /home/named</command></userinput></screen>
|
|
|
|
<para>To start the DNS server at boot, install <filename>/etc/rc.d/init.d/bind</filename>
|
|
init script included in the <xref linkend="intro-important-bootscripts"/> package.</para>
|
|
|
|
<screen><userinput><command>make install-bind</command></userinput></screen>
|
|
|
|
<para>Now start <application><acronym>BIND</acronym></application> with
|
|
the new boot script:</para>
|
|
|
|
<screen><userinput><command>/etc/rc.d/init.d/bind start</command></userinput></screen>
|
|
|
|
</sect3>
|
|
|
|
<sect3><title>Testing <application><acronym>BIND</acronym></application></title>
|
|
|
|
<para>Test out the new
|
|
<application><acronym>BIND</acronym></application> 9 installation. First
|
|
query the local host address with <command>dig</command>:</para>
|
|
|
|
<screen><userinput><command>dig -x 127.0.0.1</command></userinput></screen>
|
|
|
|
<para>Now try an external name lookup, taking note of the speed
|
|
difference in repeated lookups due to the caching. Run the dig command
|
|
twice on the same address:</para>
|
|
|
|
<para><screen><userinput><command>dig beyond.linuxfromscratch.org &&
|
|
dig beyond.linuxfromscratch.org</command></userinput></screen>
|
|
You can see almost instantaneous results with the named caching lookups.
|
|
Consult <filename>bind-&bind-version;/doc/arm/Bv9ARM.html</filename>,
|
|
the <application><acronym>BIND</acronym></application> Administrator
|
|
Reference Manual for further configuration options.</para>
|
|
|
|
</sect3>
|
|
|
|
</sect2>
|