| 1 |
<!-- Debian Network Administartor's Manual - DNS/BIND -->
|
| 2 |
|
| 3 |
<chapt id="bind">
|
| 4 |
<heading>DNS/BIND</heading>
|
| 5 |
<p>
|
| 6 |
author: Ivan E. Moore II <email>rkrusty@debian.org</email>
|
| 7 |
|
| 8 |
<p>
|
| 9 |
Welcome. The purpose of this section is to help you setup BIND on Debian. The
|
| 10 |
document will start you out from ground zero to an actually working fully
|
| 11 |
functional BIND system. As requested by some people, I will include
|
| 12 |
instructions on how to setup a working DNS Domain from both a Primary Server
|
| 13 |
standpoint and a Secondary Server standpoint.
|
| 14 |
<p>
|
| 15 |
I am also going to just focus on BIND 9.x since that is the latest version
|
| 16 |
being used by Debian. If you are using BIND 4.x I would recommend you to
|
| 17 |
upgrade.
|
| 18 |
<p>
|
| 19 |
Please note that most people do not need BIND installed on their system. In
|
| 20 |
fact pretty much only servers really need it. From time to time exploits
|
| 21 |
come out that will do anywhere from denial of service attacks to actual
|
| 22 |
root compromises. Most DNS servers are setup improperly and lead to this. If
|
| 23 |
you are setting up a home system you most likely do not need BIND installed.
|
| 24 |
Please think it over before you proceed.
|
| 25 |
<p>
|
| 26 |
NOTE: Version 8.2.1 of bind and higher have a different layout. All bind
|
| 27 |
related configuration files are now in /etc/bind. These include the zone
|
| 28 |
files.
|
| 29 |
<p>
|
| 30 |
Please see <ref id="bindhelp"> for advanced help with BIND.
|
| 31 |
|
| 32 |
<sect id="bindnecessary">Obtaining the necessary files
|
| 33 |
|
| 34 |
<p>
|
| 35 |
Fist off you need to install the proper files. Go into dselect and install the
|
| 36 |
following files:
|
| 37 |
<p>
|
| 38 |
<example>
|
| 39 |
Required Files:
|
| 40 |
|
| 41 |
bind9
|
| 42 |
dnsutils
|
| 43 |
|
| 44 |
Optional Files:
|
| 45 |
|
| 46 |
bind9-doc
|
| 47 |
bind9-host
|
| 48 |
libbind-dev
|
| 49 |
dns-browse
|
| 50 |
libnet-dns-perl
|
| 51 |
nslint
|
| 52 |
dhcp-dns
|
| 53 |
dnscvsutil
|
| 54 |
</example>
|
| 55 |
<p>
|
| 56 |
If you use apt-get, then just run this command:
|
| 57 |
<p>
|
| 58 |
<example>
|
| 59 |
apt-get install bind9 bind9-doc dnsutils
|
| 60 |
</example>
|
| 61 |
|
| 62 |
<sect id="bindconfig">Configuring BIND
|
| 63 |
|
| 64 |
<sect1>bindconfig
|
| 65 |
<p>
|
| 66 |
If you have already installed bind and answered the questions during install you
|
| 67 |
can go back and reconfigure the base BIND system by typing bindconfig. This
|
| 68 |
program does just the generic basic settings. bindconfig is what dpkg runs
|
| 69 |
when it installs BIND so what I'm about to cover is exactly what you'll go
|
| 70 |
through when you first install BIND. This is what it looks like.
|
| 71 |
<p>
|
| 72 |
This program doesn't exist in bind versions 8.2.1 and higher. It may show up
|
| 73 |
again sometime, but for now ignore these steps if your using these versions.
|
| 74 |
<p>
|
| 75 |
<sect2>Step 1 (Ignore this step if installing for the first time via dselect
|
| 76 |
or apt-get)
|
| 77 |
<p>
|
| 78 |
<example>
|
| 79 |
snowcrash:/var/named# bindconfig
|
| 80 |
|
| 81 |
It appears that you already have an /etc/named.conf file, suggesting
|
| 82 |
that you have already configured BIND version 8.X at least once. If
|
| 83 |
you proceed, a copy of this file will be saved, but no customizations
|
| 84 |
that you have made to it will be included in the new configuration.
|
| 85 |
|
| 86 |
If this means nothing to you, go ahead and proceed with the remainder
|
| 87 |
of the configuration process. If you have customized /etc/named.conf,
|
| 88 |
you probably want to stop now to preserve your customizations.
|
| 89 |
|
| 90 |
Proceed to configure BIND, ignoring existing /etc/named.conf? [N]
|
| 91 |
</example>
|
| 92 |
|
| 93 |
<sect2>Step 2
|
| 94 |
<p>
|
| 95 |
|
| 96 |
<example>
|
| 97 |
BIND Configuration
|
| 98 |
------------------
|
| 99 |
By answering the following questions, you can configure BIND for your system.
|
| 100 |
If your system has already been configured, the default values will allow you
|
| 101 |
to verify your existing configuration.
|
| 102 |
|
| 103 |
Press [ENTER]
|
| 104 |
</example>
|
| 105 |
|
| 106 |
<sect2>Step 3
|
| 107 |
<p>
|
| 108 |
<example>
|
| 109 |
Forwarder Hosts
|
| 110 |
---------------
|
| 111 |
If you are close to a well-connected host or set of hosts which accept
|
| 112 |
recursive DNS queries, it would be to your advantage to use them as forwarders
|
| 113 |
in order to reduce traffic over links to outside servers.
|
| 114 |
|
| 115 |
Your DNS server will send all queries not in its cache to the forwarders
|
| 116 |
first. Each forwarder will be asked in turn until an answer is returned or the
|
| 117 |
list is exhausted. If no answer is forthcoming from a forwarder, the server
|
| 118 |
will continue as it would have without the forwarders.
|
| 119 |
|
| 120 |
To answer this question, separate each address with a space, or answer `none'
|
| 121 |
to eliminate all forwarder hosts.
|
| 122 |
|
| 123 |
Forwarder IP addresses? []
|
| 124 |
</example>
|
| 125 |
<p>
|
| 126 |
This option allows you to forward any DNS requests to another DNS server. The
|
| 127 |
reason you might want to do this is if your inside a firewall and cannot
|
| 128 |
directly reach the outside world. You can point your server to do all it's
|
| 129 |
lookups from specific servers inside your network which can reach the outside
|
| 130 |
world.
|
| 131 |
|
| 132 |
|
| 133 |
<sect2>Step 4
|
| 134 |
<p>
|
| 135 |
<example>
|
| 136 |
Localhost Entries
|
| 137 |
-----------------
|
| 138 |
With this option, BIND will contain entries for the `localhost' pseudo-host
|
| 139 |
and its reverse mapping (127.0.0.1). This is recommended.
|
| 140 |
|
| 141 |
Enable localhost entries? [Y]
|
| 142 |
</example>
|
| 143 |
<p>
|
| 144 |
You want this. This allows mapping to and from your localhost which is
|
| 145 |
127.0.0.1.
|
| 146 |
|
| 147 |
|
| 148 |
<sect2>Step 5
|
| 149 |
<p>
|
| 150 |
<example>
|
| 151 |
Configuration Complete
|
| 152 |
----------------------
|
| 153 |
Advanced configuration, such as sortlists, xfrnets, limits, and other options
|
| 154 |
can be accomplished by manually editing the /var/named/boot.options
|
| 155 |
configuration file and reloading your nameserver. You may wish to refer to
|
| 156 |
the named(8) man page or review the documentation in /usr/doc/net/named to
|
| 157 |
assist in further customization.
|
| 158 |
|
| 159 |
This automatic configuration does not manipulate zone files; you should ensure
|
| 160 |
the proper boot entries are made in /var/named/boot.zones for each primary and
|
| 161 |
secondary zone you are serving. If you leave this file empty, your server will
|
| 162 |
act conveniently as a caching-only name server.
|
| 163 |
|
| 164 |
Saving old /var/named/boot.options to /var/named/boot.options.old ...
|
| 165 |
Reading boot.zones ...
|
| 166 |
Reading boot.options ...
|
| 167 |
Rotated `/etc/named.conf' at Mon Dec 7 06:34:58 EST 1998.
|
| 168 |
Reload named now with the new configuration? [Y]
|
| 169 |
</example>
|
| 170 |
<p>
|
| 171 |
All your basic configuration is now complete. Go ahead and say yes to this so
|
| 172 |
that bind will be restarted.
|
| 173 |
<p>
|
| 174 |
<sect1>resolv.conf
|
| 175 |
<p>
|
| 176 |
/etc/resolv.conf is where Linux looks to find out how it should perform DNS
|
| 177 |
lookups. The format is as follows:
|
| 178 |
<p>
|
| 179 |
<example>
|
| 180 |
domain yourdomain.com
|
| 181 |
search yourdomain.com otherdomains.com
|
| 182 |
nameserver 192.168.100.1
|
| 183 |
nameserver 127.0.0.1
|
| 184 |
</example>
|
| 185 |
<p>
|
| 186 |
Pretty straight forward. The first line tells it what domain you are in. This
|
| 187 |
can be omitted if you want, but I would recommend using it. The second line is
|
| 188 |
a search pattern. This too can be omitted, but I would also recommend using it.
|
| 189 |
Without it you could not do a lookup of a hostname without typing out it's fully
|
| 190 |
qualified domain name. ie.. you couldn't lookup beavis. You'd have to lookup
|
| 191 |
beavis.otherdomain.com. (Unless you specified this information in your
|
| 192 |
/etc/hosts file)
|
| 193 |
<p>
|
| 194 |
The "nameserver" lines tell it a search order for DNS servers. Now since we
|
| 195 |
are setting up BIND on your system you will need to change this file. You'll
|
| 196 |
want it to look more like the following:
|
| 197 |
<p>
|
| 198 |
<example>
|
| 199 |
domain yourdomain.com
|
| 200 |
search yourdomain.com
|
| 201 |
nameserver 127.0.0.1
|
| 202 |
nameserver x.x.x.x
|
| 203 |
</example>
|
| 204 |
<p>
|
| 205 |
Replace "yourdomain.com" with whatever domain you are using and replace the
|
| 206 |
"x.x.x.x" with a backup DNS server that you can use. (This way if your's
|
| 207 |
fails you still can perform lookups).
|
| 208 |
<p>
|
| 209 |
|
| 210 |
Save this file and you should be done. What this gives you so far is the
|
| 211 |
ability to lookup DNS information for the Internet.
|
| 212 |
|
| 213 |
<p>
|
| 214 |
|
| 215 |
Please refer to <ref id="bindprimary"> for information on setting up a
|
| 216 |
working DNS Domain.
|
| 217 |
|
| 218 |
<p>
|
| 219 |
|
| 220 |
<sect id="bindadvance">Advanced Configuration
|
| 221 |
|
| 222 |
<sect1>named.conf
|
| 223 |
|
| 224 |
<p>
|
| 225 |
named.conf is where you get to tell BIND what where and how. It is the main
|
| 226 |
configuration file for BIND. Prior to BIND 8.x this file was called named.boot.
|
| 227 |
Below is the stock named.conf file you get after installing BIND for the first
|
| 228 |
time.
|
| 229 |
<p>
|
| 230 |
<example>
|
| 231 |
|
| 232 |
// generated by named-bootconf.pl
|
| 233 |
|
| 234 |
options {
|
| 235 |
directory "/var/named";
|
| 236 |
/*
|
| 237 |
* If there is a firewall between you and nameservers you want
|
| 238 |
* to talk to, you might need to uncomment the query-source
|
| 239 |
* directive below. Previous versions of BIND always asked
|
| 240 |
* questions using port 53, but BIND 8.1 uses an unprivileged
|
| 241 |
* port by default.
|
| 242 |
*/
|
| 243 |
// query-source address * port 53;
|
| 244 |
};
|
| 245 |
|
| 246 |
//
|
| 247 |
// Boot file for name server
|
| 248 |
//
|
| 249 |
// type domain source file
|
| 250 |
zone "." {
|
| 251 |
type hint;
|
| 252 |
file "named.root";
|
| 253 |
};
|
| 254 |
|
| 255 |
// Zone boot information and daemon options are kept in other files
|
| 256 |
// (autoincluded from boot.zones)
|
| 257 |
//
|
| 258 |
// Name server zone boot file
|
| 259 |
// See named(8) for syntax and further information
|
| 260 |
//
|
| 261 |
// type domain source file
|
| 262 |
// (autoincluded from boot.options)
|
| 263 |
//
|
| 264 |
// Options for name server
|
| 265 |
// Use `bindconfig' to automatically configure this file
|
| 266 |
//
|
| 267 |
// type domain source file
|
| 268 |
zone "localhost" {
|
| 269 |
type master;
|
| 270 |
file "named.local";
|
| 271 |
};
|
| 272 |
|
| 273 |
zone "127.in-addr.arpa" {
|
| 274 |
type master;
|
| 275 |
file "named.rev-local";
|
| 276 |
};
|
| 277 |
|
| 278 |
// Custom configurations below (will be preserved)
|
| 279 |
|
| 280 |
|
| 281 |
</example>
|
| 282 |
<p>
|
| 283 |
|
| 284 |
The named.conf file is highly configurable. From just looking at it you can
|
| 285 |
see how to add a new domain. To add a new domain you just add the following
|
| 286 |
at the bottom of your named.conf file:
|
| 287 |
<p>
|
| 288 |
<example>
|
| 289 |
zone "newdomain.com" {
|
| 290 |
type master;
|
| 291 |
file "newdomain.db";
|
| 292 |
};
|
| 293 |
|
| 294 |
zone "100.168.192.in-addr.arpa" {
|
| 295 |
type master;
|
| 296 |
file "192.rev";
|
| 297 |
};
|
| 298 |
</example>
|
| 299 |
<p>
|
| 300 |
Just replace "newdomain.com" with the name of the domain you are going to
|
| 301 |
perform DNS for and replace the "100.168.192.in-addr.arpa" with the proper
|
| 302 |
subnet you will perform reverse DNS for. Note the name of this reverse lookup
|
| 303 |
zone: it is the numeric IP address of the net in reverse order, followed by
|
| 304 |
<prgn>.in-addr.arpa</prgn>. For more information on how this works please
|
| 305 |
refer to the BIND documentation located in /usr/share/doc. (if you installed
|
| 306 |
bind-doc or bind9-doc)
|
| 307 |
<p>
|
| 308 |
the "type" in the above example specifies whether your will be a master or
|
| 309 |
slave for that domain. type master means your DNS server will not rely on
|
| 310 |
anyone else for information on that domain. Other systems can be setup to
|
| 311 |
perform zone-transfers of that domain. zone-transfers means basically
|
| 312 |
transferring the information to another DNS server so that server can be used
|
| 313 |
to perform DNS lookups. If you are going to pull information from another
|
| 314 |
server you will need to use type slave instead.
|
| 315 |
<p>
|
| 316 |
|
| 317 |
The "file" in the above example specifies the actual file name where the
|
| 318 |
information is stored or will be stored. These files will be (or should be)
|
| 319 |
located in /var/named by default. (unless you change the "directory"
|
| 320 |
statement in /etc/named.conf.)
|
| 321 |
<p>
|
| 322 |
By default BIND is not setup with much security and anyone can pull your
|
| 323 |
information remotely. To control who can perform zone-transfers and thus pull
|
| 324 |
information from your server add this line to your named.conf file:
|
| 325 |
|
| 326 |
<p>
|
| 327 |
<example>
|
| 328 |
|
| 329 |
allow-transfer "192.168.100.1"; /* this line */
|
| 330 |
</example>
|
| 331 |
<p>
|
| 332 |
This line would go into the options section like so:
|
| 333 |
<p>
|
| 334 |
<example>
|
| 335 |
options {
|
| 336 |
directory "/var/named";
|
| 337 |
allow-transfer "192.168.100.1";
|
| 338 |
};
|
| 339 |
|
| 340 |
</example>
|
| 341 |
<p>
|
| 342 |
Replace the 192.168.100.1 with the IP addresses of those servers you want to
|
| 343 |
be able to perform zone-transfers from your site. NOTE: This does not mean
|
| 344 |
that people not listed here will not be able to perform nslookups from your
|
| 345 |
server. It just means that they have to know what they are looking for. They
|
| 346 |
will have to know a hostname or ip address in order to do a lookup. They will
|
| 347 |
not be able to just pull all the data stored in your database files.
|
| 348 |
|
| 349 |
<p>
|
| 350 |
|
| 351 |
<sect1>zone files
|
| 352 |
<p>
|
| 353 |
The zone files (or database files) are the heart of your BIND system. This is
|
| 354 |
where all the information is stored on what hostname goes with what ip address.
|
| 355 |
<p>
|
| 356 |
<sect2>domain zone files
|
| 357 |
<p>
|
| 358 |
Here is an example for a domain file for yourdomain.com. Please note this is
|
| 359 |
a very generic example and there are more features to it. Please refer to the
|
| 360 |
BIND documentation for help with these features.
|
| 361 |
<p>
|
| 362 |
<example>
|
| 363 |
;
|
| 364 |
; BIND data file for yourdomain.com
|
| 365 |
;
|
| 366 |
@ IN SOA yourdomain.com. root.yourdomain.com. (
|
| 367 |
1 ; Serial
|
| 368 |
604800 ; Refresh
|
| 369 |
86400 ; Retry
|
| 370 |
2419200 ; Expire
|
| 371 |
604800 ) ; Default TTL
|
| 372 |
|
| 373 |
IN NS dns.yourdomain.com.
|
| 374 |
IN MX 10 mail.yourdomain.com.
|
| 375 |
|
| 376 |
www IN A 192.168.100.5
|
| 377 |
dns IN A 192.168.100.10
|
| 378 |
mail IN A 192.168.100.20
|
| 379 |
|
| 380 |
</example>
|
| 381 |
<p>
|
| 382 |
Any line starting with a ; is a comment line and is ignored by BIND. The
|
| 383 |
first 6 lines are configuration lines for the zone. These lines tell it what
|
| 384 |
the zone is (yourdomain.com) who is responsible for it (root.yourdomain.com
|
| 385 |
which is equivalent to root@yourdomain.com) and a few other things. These other
|
| 386 |
things include a serial number used for keeping track of when it's updated, how
|
| 387 |
often to refresh the database, how often to retry a zone transfer, when the zone
|
| 388 |
information will expire and a default time to live. *IMPORTANT* Whenever you
|
| 389 |
make changes to the zone file, you MUST increment the serial number. If you do
|
| 390 |
not do this, prolems can occur, especially if you are a primary server supplying
|
| 391 |
information to secondary sites. Most of this information is only used if you
|
| 392 |
have both master and slave systems
|
| 393 |
<p>
|
| 394 |
The next two lines tell it who the primary DNS server is and who should get
|
| 395 |
the mail for this domain. You can have multiple listings of each of these.
|
| 396 |
To add more dns servers just repeat exactly what is listed changing the
|
| 397 |
dns.yourdomain.com with another dns server. To add another mail server you
|
| 398 |
do the same thing except you have an extra field. The "10" in the MX line
|
| 399 |
states a priority, lower number being first. What this means is if you have 2
|
| 400 |
MX listings, one is 10 and one is 20, it will try to deliver the mail to the
|
| 401 |
MX listing with the 10 priority and if it fails it will then go to the MX
|
| 402 |
listing with the 20 priority.
|
| 403 |
<p>
|
| 404 |
The rest of the zone file lists all your hosts and ips. For more information
|
| 405 |
other features and configuration of this information check the BIND
|
| 406 |
documentation.
|
| 407 |
<p>
|
| 408 |
<sect2>Reverse Files
|
| 409 |
<p>
|
| 410 |
The reverse lookup files are almost identical to the domain files with only
|
| 411 |
minor changes. Here is an example of a reverse lookup file.
|
| 412 |
<p>
|
| 413 |
<example>
|
| 414 |
;
|
| 415 |
; BIND reverse data file for 192.168.100.0
|
| 416 |
;
|
| 417 |
@ IN SOA yourdomain.com. root.yourdomain.com. (
|
| 418 |
1 ; Serial
|
| 419 |
604800 ; Refresh
|
| 420 |
86400 ; Retry
|
| 421 |
2419200 ; Expire
|
| 422 |
604800 ) ; Default TTL
|
| 423 |
;
|
| 424 |
IN NS dns.yourdomain.com.
|
| 425 |
|
| 426 |
5 IN PTR www.yourdomain.com.
|
| 427 |
10 IN PTR dns.yourdomain.com.
|
| 428 |
20 IN PTR mail.yourdomain.com.
|
| 429 |
|
| 430 |
</example>
|
| 431 |
<p>
|
| 432 |
The first section of this file is exactly the same as the first section of the
|
| 433 |
domain zone files. The bottom section is where it is different. This time
|
| 434 |
we are listing the last part of the IP address first and then the hostname
|
| 435 |
last.
|
| 436 |
<p>
|
| 437 |
There are 2 things you must notice here. You have to use the fully qualified
|
| 438 |
domain name here and you must put a "." at the end of it. These 2 things are
|
| 439 |
important to the file and weird things will happen if you don't do it this way.
|
| 440 |
Another possibility is to use "$ORIGIN", which is a domain name that is appended
|
| 441 |
automatically to all names not ending in a dot. The origin can be changed in
|
| 442 |
the db file with $ORIGIN. Do not forget the ending dot from $ORIGIN!
|
| 443 |
<example>
|
| 444 |
$ORIGIN yourdomain.com.
|
| 445 |
</example>
|
| 446 |
[Paul Albitz, Cricket Liu: DNS and BIND, O'Reilly & Accosiates, Inc, 1st Edition July 1994, page 136]
|
| 447 |
|
| 448 |
<p>
|
| 449 |
|
| 450 |
<sect id="bindprimary">Setting up a Primary DNS Server
|
| 451 |
|
| 452 |
<p>The Primary DNS Server is where the master copies of your DNS files are
|
| 453 |
located. It can be either a standalone system or other servers (Secondary)
|
| 454 |
can work off of it by performing zone transfers. A zone transfer is just
|
| 455 |
that, transfering of zone files from one system to another. This is how a
|
| 456 |
Primary server distributes it's zone information to other servers.
|
| 457 |
|
| 458 |
<p>This section will cover setting up your Debian system as a Primary DNS
|
| 459 |
server. I'll go through creating a fake domain and configuring BIND to work
|
| 460 |
with that domain.
|
| 461 |
|
| 462 |
<p>
|
| 463 |
|
| 464 |
<sect1>Preparation
|
| 465 |
|
| 466 |
<p>What we are going to do here is create a new domain. For our purposes
|
| 467 |
we will use foo.org. In this section, we will setup your Debian system to be
|
| 468 |
a Primary server for foo.org.
|
| 469 |
|
| 470 |
<p>To give you a better understanding on how all this works, I'll use the
|
| 471 |
following servers with their corresponding IP's for the examples.
|
| 472 |
|
| 473 |
<p>
|
| 474 |
<example>
|
| 475 |
|
| 476 |
www.foo.org = 192.168.100.10
|
| 477 |
news.foo.org = 192.168.100.20
|
| 478 |
mail.foo.org = 192.168.100.30
|
| 479 |
dns.foo.org = 192.168.100.40
|
| 480 |
dns2.foo.org = 192.168.100.50
|
| 481 |
|
| 482 |
</example>
|
| 483 |
|
| 484 |
<p>Using these for our example, dns.foo.org will represent your Debian
|
| 485 |
server. dns2.foo.org will be used in <ref id="bindsecondary">. You will
|
| 486 |
also see that we are using the 192.168.100.x subnet. For our examples here,
|
| 487 |
we'll be master to this subnet as well.
|
| 488 |
|
| 489 |
<p>
|
| 490 |
|
| 491 |
<sect1>Configuring BIND for your new DNS Domain
|
| 492 |
|
| 493 |
<p>Now to configure BIND. As shown in <ref id="bindadvance">, configuring
|
| 494 |
BIND is rather simple. Again, I'm not going to cover any advanced
|
| 495 |
configuration, but if you do wish help with it please check the
|
| 496 |
<url id="http://www.tdyc.com/archive/dns/index.html" name="BIND 8.0 Online
|
| 497 |
Documentation">.
|
| 498 |
|
| 499 |
<p>
|
| 500 |
|
| 501 |
<sect2>zone files
|
| 502 |
|
| 503 |
<p>First we need to create 2 files. One for your foo.org domain and one
|
| 504 |
for your 192.168.100.x subnet. We'll start with the foo.org domain file.
|
| 505 |
You need to create a file called <prgn>foo.db</prgn> in <prgn>/var/named</prgn>.
|
| 506 |
(This file cand be called whatever you want but I'm using this for the example).
|
| 507 |
The file should look somewhat like this:
|
| 508 |
|
| 509 |
<p>
|
| 510 |
|
| 511 |
<example>
|
| 512 |
|
| 513 |
;
|
| 514 |
; BIND data file for foo.db
|
| 515 |
; /var/named/foo.db
|
| 516 |
;
|
| 517 |
@ IN SOA foo.org. root.foo.org. (
|
| 518 |
1998121401 ; Serial
|
| 519 |
604800 ; Refresh
|
| 520 |
86400 ; Retry
|
| 521 |
2419200 ; Expire
|
| 522 |
604800 ) ; Default TTL
|
| 523 |
|
| 524 |
IN NS dns.foo.org.
|
| 525 |
|
| 526 |
IN MX 10 mail.foo.org.
|
| 527 |
|
| 528 |
www IN A 192.168.100.10
|
| 529 |
news IN A 192.168.100.20
|
| 530 |
mail IN A 192.168.100.30
|
| 531 |
dns IN A 192.168.100.40
|
| 532 |
dns2 IN A 192.168.100.50
|
| 533 |
|
| 534 |
</example>
|
| 535 |
|
| 536 |
<p>Notice in the above example that I use 1998121401 as the Serial. I
|
| 537 |
do this for the main reason of keeping track of when the file was last modified.
|
| 538 |
It tells me that the file was last modified 12-14-1998 and it was the first
|
| 539 |
time (01) it was modified that day. You don't have to do this but you do need
|
| 540 |
to make sure you increment the Serial each time you modify it. (Especially if
|
| 541 |
you have Secondaries)
|
| 542 |
|
| 543 |
<p>Now you need to create your 192.168.100.x subnet file. So create a
|
| 544 |
file called <prgn>192.168.100.db</prgn> in <prgn>/var/named</prgn>. It needs
|
| 545 |
to look somewhat like this:
|
| 546 |
|
| 547 |
<p>
|
| 548 |
|
| 549 |
<example>
|
| 550 |
|
| 551 |
;
|
| 552 |
; BIND reverse data file for 192.168.100.0
|
| 553 |
; /var/named/192.168.100.db
|
| 554 |
;
|
| 555 |
@ IN SOA foo.org. root.foo.org. (
|
| 556 |
1998121401 ; Serial
|
| 557 |
604800 ; Refresh
|
| 558 |
86400 ; Retry
|
| 559 |
2419200 ; Expire
|
| 560 |
604800 ) ; Default TTL
|
| 561 |
|
| 562 |
IN NS dns.foo.org.
|
| 563 |
|
| 564 |
10 IN PTR www.foo.org.
|
| 565 |
20 IN PTR news.foo.org.
|
| 566 |
30 IN PTR mail.foo.org.
|
| 567 |
40 IN PTR dns.foo.org.
|
| 568 |
50 IN PTR dns2.foo.org.
|
| 569 |
|
| 570 |
</example>
|
| 571 |
|
| 572 |
<p>Please note the (.) at the end of each hostname (eg. www.foo.org.) The period MUST be there otherwise your zone will not be read correctly by BIND.
|
| 573 |
|
| 574 |
<p>
|
| 575 |
|
| 576 |
<sect2>named.conf
|
| 577 |
|
| 578 |
<p>Now we need to add your new domain to the BIND configuration file.
|
| 579 |
So go ahead and edit your <prgn>/etc/named.conf</prgn> file and add the
|
| 580 |
following lines at the bottom.
|
| 581 |
|
| 582 |
<p>
|
| 583 |
|
| 584 |
<example>
|
| 585 |
|
| 586 |
zone "foo.org" {
|
| 587 |
type master;
|
| 588 |
file "foo.db";
|
| 589 |
};
|
| 590 |
|
| 591 |
zone "100.168.192.in-addr.arpa" {
|
| 592 |
type master;
|
| 593 |
file "192.168.100.rev";
|
| 594 |
};
|
| 595 |
|
| 596 |
</example>
|
| 597 |
|
| 598 |
<p>Now save that file and your done. All you have to do now is do a
|
| 599 |
<prgn>/etc/init.d/bind reload</prgn> and test it out. For help with testing
|
| 600 |
out BIND, please check <ref id="bindtest">.
|
| 601 |
|
| 602 |
<p>
|
| 603 |
|
| 604 |
</sect>
|
| 605 |
|
| 606 |
<sect id="bindsecondary">Setting up a Secondary DNS Server
|
| 607 |
|
| 608 |
<p>A Secondary DNS Server is basically just a backup server. I does not hold
|
| 609 |
the master versions of the zone information but rather it holds copies of them.
|
| 610 |
Most sites use Secondary servers in remote locations or to cut down on the load
|
| 611 |
on the Primary server. The Secondary server performs zone transfers at said
|
| 612 |
times making sure it has the newest versions of the zone information.
|
| 613 |
|
| 614 |
<p>
|
| 615 |
|
| 616 |
<sect1>Preparation
|
| 617 |
|
| 618 |
<p>The big difference in setting up a Primary server and a Secondary
|
| 619 |
server is that your zone files are already built. The only changes you have
|
| 620 |
to make is telling BIND on both systems that this server is a Secondary and to
|
| 621 |
perform zone transfers.
|
| 622 |
|
| 623 |
<p>
|
| 624 |
|
| 625 |
<sect1>Configuring BIND as a Secondary Server for your new DNS Domain
|
| 626 |
|
| 627 |
<sect2>Changes to Primary Server
|
| 628 |
|
| 629 |
<p>First we need to make changes to your Primary server so that it knows
|
| 630 |
about your new Secondary server. On your Primary, edit your <prgn>foo.db</prgn>
|
| 631 |
domain file and add the following line to it. (note: complete file is being
|
| 632 |
shown here)
|
| 633 |
|
| 634 |
<p>
|
| 635 |
|
| 636 |
<example>
|
| 637 |
|
| 638 |
;
|
| 639 |
; BIND data file for foo.db
|
| 640 |
; /var/named/foo.db
|
| 641 |
;
|
| 642 |
@ IN SOA foo.org. root.foo.org. (
|
| 643 |
1998121401 ; Serial
|
| 644 |
604800 ; Refresh
|
| 645 |
86400 ; Retry
|
| 646 |
2419200 ; Expire
|
| 647 |
604800 ) ; Default TTL
|
| 648 |
|
| 649 |
IN NS dns.foo.org.
|
| 650 |
IN NS dns2.foo.org. ; ADD THIS LINE ***
|
| 651 |
|
| 652 |
IN MX 10 mail.foo.org.
|
| 653 |
|
| 654 |
www IN A 192.168.100.10
|
| 655 |
news IN A 192.168.100.20
|
| 656 |
mail IN A 192.168.100.30
|
| 657 |
dns IN A 192.168.100.40
|
| 658 |
dns2 IN A 192.168.100.50
|
| 659 |
|
| 660 |
</example>
|
| 661 |
|
| 662 |
<p>Now edit your <prgn>/var/named/192.168.100.db</prgn> file and do the same.
|
| 663 |
|
| 664 |
<p>
|
| 665 |
|
| 666 |
<example>
|
| 667 |
|
| 668 |
;
|
| 669 |
; BIND reverse data file for 192.168.100.0
|
| 670 |
; /var/named/192.168.100.db
|
| 671 |
;
|
| 672 |
@ IN SOA foo.org. root.foo.org. (
|
| 673 |
1998121401 ; Serial
|
| 674 |
604800 ; Refresh
|
| 675 |
86400 ; Retry
|
| 676 |
2419200 ; Expire
|
| 677 |
604800 ) ; Default TTL
|
| 678 |
|
| 679 |
IN NS dns.foo.org.
|
| 680 |
IN NS dns2.foo.org. ; ADD THIS LINE ***
|
| 681 |
|
| 682 |
10 IN PTR www.foo.org.
|
| 683 |
20 IN PTR news.foo.org.
|
| 684 |
30 IN PTR mail.foo.org.
|
| 685 |
40 IN PTR dns.foo.org.
|
| 686 |
50 IN PTR dns2.foo.org.
|
| 687 |
|
| 688 |
</example>
|
| 689 |
|
| 690 |
<p>What your doing by adding the new IN NS line is telling BIND that
|
| 691 |
dns2.foo.org is also a authorized DNS server for both foo.org and the
|
| 692 |
192.168.100.x subnet. With BIND 8.x this also tells bind that whenever a
|
| 693 |
change is made to the zone files, it needs to notify dns2.foo.org that a
|
| 694 |
change has been made so thaht dns2.foo.org can perform a zone transfer.
|
| 695 |
|
| 696 |
<p>Please note that if you have setup your Primary server to only allow
|
| 697 |
zone transfers from specific hosts, you'll need to make sure that dns2.foo.org
|
| 698 |
is included in that list. (allows-transfer option in
|
| 699 |
<prgn>/etc/named.conf</prgn>.)
|
| 700 |
|
| 701 |
<p>You can now reload your BIND on your Primary server.
|
| 702 |
(<prgn>/etc/init.d/bind reload</prgn>)
|
| 703 |
|
| 704 |
<p>
|
| 705 |
|
| 706 |
<sect2>named.conf
|
| 707 |
|
| 708 |
<p>Now on your Secondary server you need to add information to your
|
| 709 |
<prgn>/etc/named.conf</prgn> file. Add the following lines to the bottom of
|
| 710 |
<prgn>/etc/named.conf</prgn>:
|
| 711 |
|
| 712 |
<p>
|
| 713 |
|
| 714 |
<example>
|
| 715 |
|
| 716 |
zone "foo.org" {
|
| 717 |
type slave;
|
| 718 |
file "foo.db";
|
| 719 |
masters {
|
| 720 |
192.168.100.40;
|
| 721 |
};
|
| 722 |
};
|
| 723 |
|
| 724 |
zone "100.168.192.in-addr.arpa" {
|
| 725 |
type slave;
|
| 726 |
file "192.168.100.db";
|
| 727 |
masters {
|
| 728 |
192.168.100.40;
|
| 729 |
};
|
| 730 |
};
|
| 731 |
|
| 732 |
</example>
|
| 733 |
|
| 734 |
<p>The above tells BIND that your server is a slave (Secondary) for
|
| 735 |
foo.org and the 192.168.100.x subnet. It also tells BIND that it needs to
|
| 736 |
obtain the zone information (foo.db and 192.168.100.db) from 192.168.100.40
|
| 737 |
which is dns.foo.org.
|
| 738 |
|
| 739 |
<p>
|
| 740 |
|
| 741 |
<sect2>zone files
|
| 742 |
|
| 743 |
<p>Because this is a Secondary Server, there is no need to do anything
|
| 744 |
with zone files. BONUS! As long as you have everything setup right on your
|
| 745 |
Primary and your named.conf file is configured properly, everything will work
|
| 746 |
properly.
|
| 747 |
|
| 748 |
<p>You are done. Reload your BIND and test it out.
|
| 749 |
<prgn>/etc/init.d/bind reload</prgn>
|
| 750 |
|
| 751 |
<p>
|
| 752 |
|
| 753 |
<sect2>Information
|
| 754 |
|
| 755 |
<p>Now. Each time the Primary site's zone files are modified and the
|
| 756 |
Serial # is incremented, BIND will send out a notify to all Secondaries (any
|
| 757 |
server in the zone file with a IN NS statement) stating a change has been made.
|
| 758 |
BIND on each of these servers will then check it's own zone files to see if it
|
| 759 |
has the same version or not. If the version that the Primary has notified it
|
| 760 |
about is newer then it will perform a zone transfer and obtain the newer
|
| 761 |
version.
|
| 762 |
|
| 763 |
<p>If everything is setup properly, you will never need to make any
|
| 764 |
changes to your Secondary server except to upgrade BIND itself. All changes
|
| 765 |
from here on out should be made on the Primary server. The exception is if a
|
| 766 |
new zone is added on the primary, you need to add it to the secondaries also
|
| 767 |
if you want them to be secondary to the new zone.
|
| 768 |
|
| 769 |
<p>
|
| 770 |
|
| 771 |
</sect>
|
| 772 |
|
| 773 |
<sect id="bindtest">Testing
|
| 774 |
|
| 775 |
<p>
|
| 776 |
Testing is the easy part. If you followed the directions listed here
|
| 777 |
everything should work fine. The first thing you need to do before we can
|
| 778 |
properly test is to reload the database.<p>
|
| 779 |
<example>
|
| 780 |
/etc/init.d/bind reload
|
| 781 |
</example>
|
| 782 |
<p>
|
| 783 |
Then you need to go ahead and load up nslookup and run some queries
|
| 784 |
<p>
|
| 785 |
<example>
|
| 786 |
snowcrash:~# nslookup
|
| 787 |
Default Server: localhost
|
| 788 |
Address: 127.0.0.1
|
| 789 |
|
| 790 |
>
|
| 791 |
</example>
|
| 792 |
<p>First off when you run nslookup it should look like the above example
|
| 793 |
unless you have created your own domain and are using an ip address other
|
| 794 |
than 127.0.0.1. You should be able to type in www.debian.org and it should
|
| 795 |
think for a few and return with www.debian.org's ip address.
|
| 796 |
|
| 797 |
<p>
|
| 798 |
If you are following the instructions here for setting up a new domain,
|
| 799 |
your nslookup should look more like this:
|
| 800 |
|
| 801 |
<p>
|
| 802 |
<example>
|
| 803 |
snowcrash:~# nslookup
|
| 804 |
Default Server: dns.foo.org
|
| 805 |
Address: 192.168.100.40
|
| 806 |
|
| 807 |
>
|
| 808 |
</example>
|
| 809 |
|
| 810 |
<p>
|
| 811 |
You should be able to now lookup each of the hosts we added to your
|
| 812 |
zone files. (www.foo.org, mail.foo.org, etc...)
|
| 813 |
|
| 814 |
<sect id="bindhelp">Obtaining Help With BIND
|
| 815 |
<p>
|
| 816 |
The following sites are good sources of help for BIND.
|
| 817 |
|
| 818 |
<list>
|
| 819 |
<item><url id="http://www.isc.org/bind.html" name="ISC's BIND Site">
|
| 820 |
<item><url id="http://www.tdyc.com/archive/dns/index.html" name="BIND Documentation Online">
|
| 821 |
<item><url id="http://www.tdyc.com/archive/LDP/HOWTO/DNS-HOWTO.html" name="LINUX DNS HOWTO">
|
| 822 |
</list>
|
| 823 |
|
| 824 |
</chapt>
|
| 825 |
<!-- Keep this comment at the end of the file
|
| 826 |
Local variables:
|
| 827 |
mode: sgml
|
| 828 |
sgml-omittag:t
|
| 829 |
sgml-shorttag:t
|
| 830 |
sgml-minimize-attributes:nil
|
| 831 |
sgml-always-quote-attributes:t
|
| 832 |
sgml-indent-step:2
|
| 833 |
sgml-indent-data:t
|
| 834 |
sgml-parent-document:"network-administrator.sgml chapt sect"
|
| 835 |
sgml-exposed-tags:nil
|
| 836 |
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
| 837 |
sgml-local-ecat-files:nil
|
| 838 |
End:
|
| 839 |
-->
|
| 840 |
|