Sei sulla pagina 1di 6

Setting up BIND on CentOS 5.

5
This is part of an x10hosting directed series of tutorials that I am writing. It continues the last post I wrote for this series. It could be used in practice, though it's stability or security can't be guaranteed if you have already configured BI ! or haven't followed the previous tutorial. This is probably the longest of all the tutorials and almost absolutely the hardest, hence it's length. This tutorial will teach the "inux beginner to configure BI ! ! # daemon to be able to answer re$uests for their domains names on their x10 %&#. 't the end of the tutorial the user will have( "earned how to set configure a BI ! server. "earned how to add domains, )* records, subdomains, etc. Been familiari+ed with the "inux directory structure and file system. &rovided with lots of lin,s for more information on everything that's being discussed (&

'lso, this tutorial assumes that( 1. -ave no prior experience with the "inux command line. .. /ou have followed the tutorial located here. 0. /ou have registered a domain with x10hosting 1irst I will start by briefly describing what BI ! is. I guess it's best said $uoting the pro2ect's home page( 3riginally &osted by BIND home page BI ! is by far the most widely used ! # software on the Internet. It provides a robust and stable platform on top of which organi+ations can build distributed computing systems with the ,nowledge that those systems are fully compliant with published ! # standards. That being said, if you didn't understand half of that I will explain in a bit more simpler terms. BI ! is a ! # server which allows your %&# to answer re$uests made to your domain name. It is used widely across the internet, and the last little bit means it's really good at what it does. If you didn't register your domain with x10 you will have to adapt this tutorial to your needs. I will write in notes where adaptation will be needed. 1or this tutorial, I will be using example.com as my 14! , or domain name. I will also be using 15..167.1.100 as my %&#'s I&. /ou can use and change the following files to meet your needs.

#o we have our basic "')& set up wor,ing and we ,now this because we visited our server's I& from a browser. But if I wanted to visit my domain, example.com, it comes up as not found in the browser because my %&# isn't set up to answer re$uests for that domain. 8e are going to set up a basic BI ! configuration, or commonly ,nown as named 9pronounced :named:, or :name;d:<, which stands for name daemon. 1irst thing we'll have to do is to edit a couple files using vim. 1irst file is named.conf. This is your main BI ! configuration file. If you search google for this, you will find a lot of stuff that you really don't need to ,now to get your %&# answering calls and it can turn out $uite confusing. #o the goal here is to ,eep it simple and explain everything. I will briefly explain the file system structure here in order to lessen confusion, and, perhaps, answer any $uestions. /ou can s,ip this by scrolling down to the next paragraph. The "inux file system isn't built li,e windows, instead of using forward slashes 9=< between directories, it uses a bac, slash 9><. 3n "inux there are no drive letters 9?(=, !(=, etc.< instead, your root directory is 2ust >. ' good rule of thumb when wor,ing from the command line on your %&# is to thin, of the first > when you are changing directories, or editing files as :?(=: if you're a windows user. -ere is more reading on this. #o, logged in as our privileged user 92oe<, we open up the file >etc>named.conf ?ode(
sudo vim /etc/named.conf

This should bring up a new file. If you see anything on your screen, except a bunch of @'s and something li,e( ::>etc>named.conf: A ew 1ileB: at the bottom, you should reconsider editing this file. /ou should not have any problem if you've followed the last tutorial. I will show you a basic named.conf file and explain it a bit in more detail after. -ere is the file( ?ode(
options { directory "/var/named"; version "Nope."; };

Cach section's directives are contained within 'D' and 'E'. Cach directive is terminated with 'F'. options { ; The directives passed in this section are the main options for BI !. directory "/var/named"; ; This tells BI ! where to loo, for configuration and other files. 8e will leave it at the default, >var>named. version "Nope."; ; This is a version statement for a bit of security, all that happens is when version re$uests are sent to BI ! it will return : ope.: instead of the version. This is to

avoid exploiting any potential wea,nesses. ow we will add in our site's entry to this file. 8hen we're done, our named.conf file should loo, li,e this( ?ode(
options { directory "/var/named"; version "Nope."; }; zone "example.com" in { type master; file "example.com" };

I will describe what we added to this does as I did above. one "e!amp"e.com" in { ; This tells us the the +one we are answering for. This must be an 14! , not a subdomain, this includes your domain without the :www.:, as it is a subdomain as well. type master; ; This tells that this is a master +one and everything is on this server. #i"e "e!amp"e.com" ; This is the file name in which we will find our configuration for this domain. I li,e to 2ust name it as the domain to ma,e life easier, but you can name it anything you li,e, really. ote that this file will need to be in the >var>named directory, or whatever was specified above. Good stuff. ow before we go adding in the configuration for our site we must register the name servers in the x10hosting client area. I have wrote a tutorial on how to do this here. ow we have the name servers that we want to use 9ns1.example.com and ns..example.com< pointing to our %&#'s I& 915..167.1.100<. 8e can now insert the ! # record in the >var>named directory. This is how we're going to do it. ?ode(
vim /var/named/example.com

1or our example.com we'll want to have a file that loo,s li,e the one below, I will explain it more in parts and attach the exact file in it's completeness. ?ode(
$TTL 8 !"" ;

This is is the Time To "ive statement. It tells ! # ?aching servers how long this record should stay in the cache. The value following it is in seconds, this record stays alive for .H

hours. /ou could also write this as( ?ode(


$TTL #!$;

ext is( ?ode(


% &N '() ns#.example.com. admin.example.com. * #"+"" #8"+ ; 'erial +"8"" ; ,efres$ - "" ; ,etry "!8"" ; .xpire 8 !"" ; /inimum

This is the #tart of 'uthority record. Basically all you need to ,now at this point is that you don't need to change the numbers you see 9#erial, Iefresh, etc.<. 8hat you can change is :ns..example.com: and :admin.example.com:. These are one of your nameservers that you registered with x10hosting, and the administrator's 9your< email, respectively. 1or the email, you must replace the J with a period. I'm not too sure why and nobody really isF meaning that if you have trouble understanding ! # not to fret as it really is the hardest part of this series and many people have lost sleep over configuring ! #. )oving on... ?ode(
example.com. &N example.com. &N N' N' ns+.example.com. ns#.example.com.

These are the two name servers you registered in this article. They follow the syntax ?ode(
domain.tld. &N N' nameserver+.domain.tld.

The :I : 2ust has to be there if this is a site's ! # record. It is telling the internet that this is all I the record for this site. otice the periods after every domain and subdomain entry. !omains and subdomains with dots after them are absolute domains 914! < and those without are relative 9&4! <. /ou can read about both here. ext #ection ?ode(
example.com. ns+.example.com. ns#.example.com. mail.example.com. 222.example.com. ftp.example.com. &N &N &N &N &N &N ) ) ) ) ) ) +1#.+ +1#.+ +1#.+ +1#.+ +1#.+ +1#.+ 8.+.+"" 8.+.+"" 8.+.+"" 8.+.+"" 8.+.+"" 8.+.+""

The above is 2ust a list of domains that your %&# will answer to. /ou don't need to enter

any of these except the 14! , example.com. The others are for giving services their own subdomain. 9ftp, www, mail< and completeness 9nameservers<. ?ode(
example.com. &N /3 +" mail.example.com.

This last bit of code is the )* record, or the mail record. It will tell other mail servers where to send mail. 8e will set ours to mail.example.com for example.com.

$he rest o# it.


I had to wait for this to be approved, so I will finish it in this reply. I will note that in the part where you name your sub;domains 9www.example.com, etc.< this is where you must add any other sub;domains that you wish to have. 1or example, if I wanted to add 'info.example.com' and 'testing.example.com' to my ! # record I would simply 2ust add them to the end of that section, li,e so( ?ode(
;4$at 2e already $ave. example.com. ns+.example.com. ns#.example.com. mail.example.com. 222.example.com. ftp.example.com. ;4$at 2e are addin5. info.example.com. testin5.example.com. &N &N &N &N &N &N ) ) ) ) ) ) +1#.+ +1#.+ +1#.+ +1#.+ +1#.+ +1#.+ 8.+.+"" 8.+.+"" 8.+.+"" 8.+.+"" 8.+.+"" 8.+.+""

&N ) &N )

+1#.+ 8.+.+"" +1#.+ 8.+.+""

'ny other 14! s that you wish to add should be done the same way we added example.com to our ! # records. There you are, pretty straightforward. #o now that we've got our example.com configuration file complete and all the sub; domains we want are added, we can exit and save the file 9press 'esc', and type '(x'< and start the BI ! service. To do this we type( ?ode(
service named start

/ou should see something li,e the following( ?ode(


'tartin5 named6 7 (8 9

If it says A1'I"C!B instead of A 3K B it should give you a brief reason as to why it failed. If you followed this tutorial to the word, it should start up 2ust fine. If named has started up successfully you can now open your browser and type in your domain name. If you've followed the tutorials, you should see an 'pache test page on your domain. If nothing comes up, you can try a few things to see if it's your computer that is causing it. /ou can try pressing the refresh button, or you could try flushing your ! #. That's all for this tutorial. In my next I will go through the steps needed to configure 'pache to start hosting your sites, or sites. If you find anything in error or false or have anything to add, please message me and let me ,now and I will ma,e the necessary changes. I will also post the lin,s to those articles when I have written them.

Potrebbero piacerti anche