| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 3 | <head> |
|---|
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 5 | <meta http-equiv="Content-Style-Type" content="text/css" /> |
|---|
| 6 | <meta name="generator" content="pandoc" /> |
|---|
| 7 | <title></title> |
|---|
| 8 | <style type="text/css">code{white-space: pre;}</style> |
|---|
| 9 | <link href="data:text/css;charset=utf-8,%0A%0A%0A%0Adiv%23header%2C%20header%0A%7B%0A%0Aborder%2Dbottom%3A%201px%20solid%20%23aaa%3B%0Amargin%2Dbottom%3A%200%2E5em%3B%0A%7D%0A%2Etitle%20%0A%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%2Eauthor%2C%20%2Edate%20%0A%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%0Adiv%23TOC%2C%20nav%23TOC%0A%7B%0A%0Aborder%2Dbottom%3A%201px%20solid%20%23aaa%3B%0Amargin%2Dbottom%3A%200%2E5em%3B%0A%7D%0A%40media%20print%0A%7B%0Adiv%23TOC%2C%20nav%23TOC%0A%7B%0A%0Adisplay%3A%20none%3B%0A%7D%0A%7D%0A%0Ah1%2C%20h2%2C%20h3%2C%20h4%2C%20h5%2C%20h6%0A%7B%0Afont%2Dfamily%3A%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20%22Liberation%20Sans%22%2C%20Calibri%2C%20Arial%2C%20sans%2Dserif%3B%20%0A%0Apage%2Dbreak%2Dafter%3A%20avoid%3B%20%0A%7D%0A%0Adiv%20div%2C%20section%20section%20%0A%7B%0Amargin%2Dleft%3A%202em%3B%20%0A%7D%0Ap%20%7B%7D%0Ablockquote%0A%7B%20font%2Dstyle%3A%20italic%3B%0A%7D%0Ali%20%0A%7B%0A%7D%0Ali%20%3E%20p%20%0A%7B%0Amargin%2Dtop%3A%201em%3B%20%0A%7D%0Aul%20%0A%7B%0A%7D%0Aul%20li%20%0A%7B%0A%7D%0Aol%20%0A%7B%0A%7D%0Aol%20li%20%0A%7B%0A%7D%0Ahr%20%7B%7D%0A%0Asub%20%0A%7B%0A%7D%0Asup%20%0A%7B%0A%7D%0Aem%20%0A%7B%0A%7D%0Aem%20%3E%20em%20%0A%7B%0Afont%2Dstyle%3A%20normal%3B%0A%7D%0Astrong%20%0A%7B%0A%7D%0A%0Aa%20%0A%7B%0A%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0A%40media%20screen%0A%7B%0Aa%3Ahover%0A%7B%0A%0Atext%2Ddecoration%3A%20underline%3B%0A%7D%0A%7D%0A%40media%20print%0A%7B%0Aa%20%7B%0A%0Acolor%3A%20black%3B%0Abackground%3A%20transparent%3B%0A%7D%0Aa%5Bhref%5E%3D%22http%3A%2F%2F%22%5D%3Aafter%2C%20a%5Bhref%5E%3D%22https%3A%2F%2F%22%5D%3Aafter%0A%7B%0A%0Acontent%3A%20%22%20%28%22%20attr%28href%29%20%22%29%20%22%3B%0Afont%2Dsize%3A%2090%25%3B%0A%7D%0A%7D%0A%0Aimg%0A%7B%0A%0Avertical%2Dalign%3A%20middle%3B%0A%7D%0Adiv%2Efigure%20%0A%7B%0A%0Amargin%2Dleft%3A%20auto%3B%0Amargin%2Dright%3A%20auto%3B%0Atext%2Dalign%3A%20center%3B%0Afont%2Dstyle%3A%20italic%3B%0A%7D%0Ap%2Ecaption%20%0A%7B%0A%0A%7D%0A%0Apre%2C%20code%20%7B%0Abackground%2Dcolor%3A%20%23fdf7ee%3B%0A%0A%0A%0Awhite%2Dspace%3A%20pre%2Dwrap%3B%20%0Awhite%2Dspace%3A%20%2Dmoz%2Dpre%2Dwrap%20%21important%3B%20%0Awhite%2Dspace%3A%20%2Dpre%2Dwrap%3B%20%0Awhite%2Dspace%3A%20%2Do%2Dpre%2Dwrap%3B%20%0Aword%2Dwrap%3A%20break%2Dword%3B%20%0A%0A%7D%0Apre%20%0A%7B%0A%0Apadding%3A%200%2E5em%3B%20%0Aborder%2Dradius%3A%205px%3B%20%0A%0Aborder%3A%201px%20solid%20%23aaa%3B%0A%0Amargin%2Dleft%3A%200%2E5em%3B%0Amargin%2Dright%3A%200%2E5em%3B%0A%7D%0A%40media%20screen%0A%7B%0Apre%0A%7B%0A%0Awhite%2Dspace%3A%20pre%3B%0Aoverflow%3A%20auto%3B%0A%0Aborder%3A%201px%20dotted%20%23777%3B%0A%7D%0A%7D%0Acode%20%0A%7B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%0A%7B%0A%0Apadding%2Dleft%3A%202px%3B%0Apadding%2Dright%3A%202px%3B%0A%7D%0Ali%20%3E%20p%20code%20%0A%7B%0A%0Apadding%3A%202px%3B%0A%7D%0A%0Aspan%2Emath%20%0A%7B%0A%0A%7D%0Adiv%2Emath%20%0A%7B%0A%7D%0Aspan%2ELaTeX%20%0A%7B%0A%7D%20eq%20%0A%7B%0A%7D%20%0A%0Atable%0A%7B%0Aborder%2Dcollapse%3A%20collapse%3B%0Aborder%2Dspacing%3A%200%3B%20%0Aborder%2Dbottom%3A%202pt%20solid%20%23000%3B%0Aborder%2Dtop%3A%202pt%20solid%20%23000%3B%20%0A%0Amargin%2Dleft%3A%20auto%3B%0Amargin%2Dright%3A%20auto%3B%0A%7D%0Athead%20%0A%7B%0Aborder%2Dbottom%3A%201pt%20solid%20%23000%3B%0Abackground%2Dcolor%3A%20%23eee%3B%20%0A%7D%0Atr%2Eheader%20%0A%7B%0A%7D%20tbody%20%0A%7B%0A%7D%0A%0Atr%20%7B%0A%7D%0Atr%2Eodd%3Ahover%2C%20tr%2Eeven%3Ahover%20%0A%7B%0Abackground%2Dcolor%3A%20%23eee%3B%0A%7D%0A%0Atr%2Eodd%20%7B%7D%0Atr%2Eeven%20%7B%7D%0Atd%2C%20th%20%0A%7B%20vertical%2Dalign%3A%20top%3B%20%0Avertical%2Dalign%3A%20baseline%3B%20%0Apadding%2Dleft%3A%200%2E5em%3B%0Apadding%2Dright%3A%200%2E5em%3B%0Apadding%2Dtop%3A%200%2E2em%3B%0Apadding%2Dbottom%3A%200%2E2em%3B%0A%7D%0A%0A%0Ath%20%0A%7B%0Afont%2Dweight%3A%20bold%3B%20%7D%0Atfoot%20%0A%7B%0A%7D%0Acaption%20%0A%7B%0Acaption%2Dside%3A%20top%3B%0Aborder%3A%20none%3B%0Afont%2Dsize%3A%200%2E9em%3B%0Afont%2Dstyle%3A%20italic%3B%0Atext%2Dalign%3A%20center%3B%0Amargin%2Dbottom%3A%200%2E3em%3B%20%0Apadding%2Dbottom%3A%200%2E2em%3B%0A%7D%0A%0Adl%20%0A%7B%0Aborder%2Dtop%3A%202pt%20solid%20black%3B%0Apadding%2Dtop%3A%200%2E5em%3B%0Aborder%2Dbottom%3A%202pt%20solid%20black%3B%0A%7D%0Adt%20%0A%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Add%2Bdt%20%0A%7B%0Aborder%2Dtop%3A%201pt%20solid%20black%3B%0Apadding%2Dtop%3A%200%2E5em%3B%0A%7D%0Add%20%0A%7B%0Amargin%2Dbottom%3A%200%2E5em%3B%0A%7D%0Add%2Bdd%20%0A%7B%0Aborder%2Dtop%3A%201px%20solid%20black%3B%20%0A%7D%0A%0Aa%2Efootnote%2C%20a%2EfootnoteRef%20%7B%20%0Afont%2Dsize%3A%20small%3B%20vertical%2Dalign%3A%20text%2Dtop%3B%0A%7D%0Aa%5Bhref%5E%3D%22%23fnref%22%5D%2C%20a%2Ereversefootnote%20%0A%7B%0A%7D%0A%40media%20print%0A%7B%0Aa%5Bhref%5E%3D%22%23fnref%22%5D%2C%20a%2Ereversefootnote%20%0A%7B%0A%0Adisplay%3A%20none%3B%0A%7D%0A%7D%0Adiv%2Efootnotes%20%0A%7B%0A%7D%0Adiv%2Efootnotes%20li%5Bid%5E%3D%22fn%22%5D%20%0A%7B%0A%7D%0A%0A%40media%20print%0A%7B%0A%2Enoprint%0A%7B%0Adisplay%3Anone%3B%0A%7D%0A%7D%0A" rel="stylesheet" type="text/css" /> |
|---|
| 10 | </head> |
|---|
| 11 | <body> |
|---|
| 12 | <h1 id="setting-up-bind">Setting up BIND</h1> |
|---|
| 13 | <h2 id="install-the-software">Install the software</h2> |
|---|
| 14 | <pre><code>sudo apt-get install bind9 bind9utils dnsutils</code></pre> |
|---|
| 15 | <p>Let's inspect the <code>/etc/bind</code> directory:</p> |
|---|
| 16 | <pre><code>cd /etc/bind |
|---|
| 17 | ls -l</code></pre> |
|---|
| 18 | <p>You will see a number of files, including:</p> |
|---|
| 19 | <pre><code>named.conf |
|---|
| 20 | named.conf.default-zones |
|---|
| 21 | named.conf.local |
|---|
| 22 | named.conf.options</code></pre> |
|---|
| 23 | <p>Let's take a look at the <code>named.conf</code></p> |
|---|
| 24 | <pre><code>include "/etc/bind/named.conf.options"; |
|---|
| 25 | include "/etc/bind/named.conf.local"; |
|---|
| 26 | include "/etc/bind/named.conf.default-zones";</code></pre> |
|---|
| 27 | <p>As you see named.conf points to 3 include files, used respectively for:</p> |
|---|
| 28 | <ul> |
|---|
| 29 | <li>storing configuration options (.options)</li> |
|---|
| 30 | <li>define the list of zones to load (.local)</li> |
|---|
| 31 | <li>specify zones to be answered "by default" (.default-zones)</li> |
|---|
| 32 | </ul> |
|---|
| 33 | <p>Let's start by looking at options...</p> |
|---|
| 34 | <h2 id="turn-off-recursion">Turn off recursion</h2> |
|---|
| 35 | <p>Start by editing <code>/etc/bind/named.conf.options</code>.</p> |
|---|
| 36 | <p>The first thing we want to do is turn recursion OFF. As explained in class, it's not the role of an authoritative nameserver to respond to recursive queries.</p> |
|---|
| 37 | <pre><code>sudo vi /etc/bind/named.conf.options</code></pre> |
|---|
| 38 | <p>Find the line where it says</p> |
|---|
| 39 | <pre><code> dnssec-validation auto;</code></pre> |
|---|
| 40 | <p>And just below, add:</p> |
|---|
| 41 | <pre><code> recursion no;</code></pre> |
|---|
| 42 | <p>So it should now look like:</p> |
|---|
| 43 | <pre><code> dnssec-validation auto; |
|---|
| 44 | recursion no;</code></pre> |
|---|
| 45 | <p>Save, and exit, the file, then reconfigure your nameserver:</p> |
|---|
| 46 | <pre><code>sudo rndc reconfig</code></pre> |
|---|
| 47 | <p>If all goes well, if you now submit a query to your nameserver for, say, <code>www.google.com</code>, you should see <code>REFUSED</code>:</p> |
|---|
| 48 | <pre><code>dig @127.0.0.1 www.google.com</code></pre> |
|---|
| 49 | <p>Check that this is the case, correct otherwise!</p> |
|---|
| 50 | <p>Bonus: you should also modify <code>/etc/bind/named.conf.default-zones</code>, and <em>remove</em> anything below the "root.db" zone definition.</p> |
|---|
| 51 | <p>After, reconfigure your nameserver as usual.</p> |
|---|
| 52 | <h2 id="load-your-zone">Load your zone</h2> |
|---|
| 53 | <p>The next step is to load the zone that is being generated automatically.</p> |
|---|
| 54 | <p>Make sure you've created a cron job so that your zone is being generated by <code>genzone_client</code>, and you know where it is.</p> |
|---|
| 55 | <p>Edit the file <code>/etc/bind/named.conf.local</code>, and at the bottom of the file, add a statement for your zone:</p> |
|---|
| 56 | <pre><code>zone "myzone" { |
|---|
| 57 | type master; |
|---|
| 58 | file "/home/sysadm/zones/db.myzone"; |
|---|
| 59 | };</code></pre> |
|---|
| 60 | <p>DO remember to replace <code>myzone</code> with the name of your zone :)</p> |
|---|
| 61 | <p>Save the file and exit, then run:</p> |
|---|
| 62 | <pre><code>sudo rndc reconfig</code></pre> |
|---|
| 63 | <p>Check That the zone has loaded properly:</p> |
|---|
| 64 | <pre><code>dig @localhost SOA myzone</code></pre> |
|---|
| 65 | <p>If everything goes well, you should see something like:</p> |
|---|
| 66 | <pre><code>;; flags: qr aa rd; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 11 |
|---|
| 67 | ... |
|---|
| 68 | ;; ANSWER SECTION: |
|---|
| 69 | myzone. 18000 IN NS ... |
|---|
| 70 | myzone. 18000 IN NS ... |
|---|
| 71 | myzone. 18000 IN NS ... |
|---|
| 72 | myzone. 18000 IN NS ...</code></pre> |
|---|
| 73 | </body> |
|---|
| 74 | </html> |
|---|