Skip to content
Snippets Groups Projects
dns.xml 16.7 KiB
Newer Older
Goik Martin's avatar
Goik Martin committed
<?xml version="1.0" encoding="UTF-8"?>
Goik Martin's avatar
Goik Martin committed
<chapter annotations="slide" version="5.1" xml:id="sdiDns"
         xmlns="http://docbook.org/ns/docbook"
Goik Martin's avatar
Goik Martin committed
         xmlns:xlink="http://www.w3.org/1999/xlink"
Goik Martin's avatar
Goik Martin committed
         xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
Goik Martin's avatar
Goik Martin committed
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:svg="http://www.w3.org/2000/svg"
         xmlns:ns="http://docbook.org/ns/transclusion"
Goik Martin's avatar
Goik Martin committed
         xmlns:m="http://www.w3.org/1998/Math/MathML"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:db="http://docbook.org/ns/docbook">
Goik Martin's avatar
Goik Martin committed
  <title><xref linkend="glo_DNS"/></title>
Goik Martin's avatar
Goik Martin committed

  <section xml:id="sdiDnsPrelim">
    <title>Preliminaries</title>

Goik Martin's avatar
Goik Martin committed
    <figure xml:id="sdiDnsLinks">
      <title>Documentation links</title>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
      <itemizedlist>
Goik Martin's avatar
Goik Martin committed
        <listitem>
          <para><link
          xlink:href="https://www.cloudflare.com/learning/dns/what-is-dns">What
          Is DNS? | How DNS Works</link></para>
        </listitem>

Goik Martin's avatar
Goik Martin committed
        <listitem>
          <para><link
          xlink:href="http://www.htmlgoodies.com/beyond/webmaster/article.php/3473261/An-Introduction-to-DNS.htm">An
          Introduction to DNS</link></para>
        </listitem>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
        <listitem>
          <para><link xlink:href="http://www.zytrax.com/books/dns">DNS for
          Rocket Scientists</link></para>
        </listitem>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
        <listitem>
          <para><link
          xlink:href="https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-ubuntu-14-04">How
          To Configure BIND as a Private Network DNS Server on
          Ubuntu</link></para>
        </listitem>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
        <listitem>
          <para><link xlink:href="https://bind9.readthedocs.io/en/latest">BIND
          9 Administrator Reference Manual</link></para>
Goik Martin's avatar
Goik Martin committed
        </listitem>
      </itemizedlist>
    </figure>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
    <figure xml:id="sdiDnsQueryCommands">
      <title><xref linkend="glo_DNS"/> query commands</title>
Goik Martin's avatar
Goik Martin committed

      <itemizedlist>
        <listitem>
Goik Martin's avatar
Goik Martin committed
          <para><command
          xlink:href="https://manpages.debian.org/buster/dnsutils/dig.1.en.html">dig</command>
          (<emphasis role="red">d</emphasis>omain <emphasis
          role="red">i</emphasis>nformation <emphasis
          role="red">g</emphasis>roper)</para>
Goik Martin's avatar
Goik Martin committed
        </listitem>

        <listitem>
Goik Martin's avatar
Goik Martin committed
          <para><command
          xlink:href="https://manpages.debian.org/buster/dnsutils/nslookup.1.en.html">nslookup</command></para>
Goik Martin's avatar
Goik Martin committed
        </listitem>
      </itemizedlist>
Goik Martin's avatar
Goik Martin committed
    </figure>

    <figure xml:id="sdiDnsForwardLookup">
      <title><xref linkend="glo_DNS"/> forward lookup</title>

      <screen>&gt; dig <emphasis role="red">learn.mi.hdm-stuttgart.de</emphasis>

; &lt;&lt;&gt;&gt; DiG 9.16.1-Ubuntu &lt;&lt;&gt;&gt; learn.mi.hdm-stuttgart.de
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 63891
...
;; ANSWER SECTION:
learn.mi.hdm-stuttgart.de. 6593	IN	A	<emphasis role="red">141.62.64.28</emphasis>

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) ...</screen>
    </figure>

    <figure xml:id="sdiDnsResultOnly">
      <title>Display A-record result only</title>

      <screen>&gt; dig <emphasis role="red">+noall +answer</emphasis> <emphasis>www.hdm-stuttgart.de</emphasis>
www.hdm-stuttgart.de.	3600	IN	A	141.62.1.53
www.hdm-stuttgart.de.	3600	IN	A	141.62.1.59</screen>
    </figure>

    <figure xml:id="sdiDnsImportantRecordTypes">
      <title>Important record types</title>

      <informaltable border="1">
        <tr>
          <th>Record</th>

          <th>Explanation</th>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/a-records">A</link></td>

          <td valign="top">IPV4 Host address</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/aaaa-records">AAAA</link></td>

          <td valign="top">IPv6 host address</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/alias-records">ALIAS</link></td>

          <td valign="top">Auto resolved alias</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/cname-records">CNAME</link></td>

          <td valign="top">Canonical name for an alias</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/mx-records">MX</link></td>

          <td valign="top">Mail eXchange</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/ns-records">NS</link></td>

          <td valign="top">Name Server</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/ptr-records">PTR</link></td>

          <td valign="top">Pointer</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/soa-records">SOA</link></td>

          <td valign="top">Start Of Authority</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/srv-records">SRV</link></td>

          <td valign="top">location of service</td>
        </tr>

        <tr>
          <td valign="top"><link
          xlink:href="https://simpledns.plus/help/txt-records">TXT</link></td>

          <td valign="top">Descriptive text</td>
        </tr>
      </informaltable>
    </figure>

    <figure xml:id="sdiDnsQueryNs">
      <title>Name Servers: Query type <code>NS</code></title>

      <screen>dig +noall +answer <emphasis role="red">-t NS</emphasis> hdm-stuttgart.de
hdm-stuttgart.de.	3600	IN	NS	iz-net-4.hdm-stuttgart.de.
hdm-stuttgart.de.	3600	IN	NS	dns3.belwue.de.
hdm-stuttgart.de.	3600	IN	NS	iz-net-3.hdm-stuttgart.de.
hdm-stuttgart.de.	3600	IN	NS	dns1.belwue.de.
hdm-stuttgart.de.	3600	IN	NS	iz-net-2.hdm-stuttgart.de.</screen>
    </figure>
  </section>

  <section xml:id="sdiDnsExercises">
    <title>Exercises</title>

    <section xml:id="sdiDnsUseDig">
      <title>Querying <xref linkend="glo_DNS"/> data.</title>

      <para>Use the <command>dig</command> command to query <code>A</code> /
      <code>CNAME</code> / <code>MX</code> / <code>NS</code> records from
      various machines / domains of your choice. Then execute reverse lookups
      as well.</para>
    </section>

    <section xml:id="sdiBindInstall">
Goik Martin's avatar
Goik Martin committed
      <title>Installing and configuring <xref
      linkend="glo_Soft_Bind"/></title>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
      <para>You may follow:</para>

      <itemizedlist>
        <listitem>
          <para><link
          xlink:href="https://www.linuxbabe.com/debian/authoritative-dns-server-debian-10-buster-bind9">Set
          Up BIND Authoritative DNS Server on Debian</link></para>
        </listitem>

        <listitem>
          <para><link
          xlink:href="https://cloudinfrastructureservices.co.uk/how-to-install-bind-dns-on-debian-11-server-setup-configure">How
          to Install Bind DNS on Debian 11 Server</link></para>
        </listitem>

        <listitem>
          <para><link
          xlink:href="https://www.zytrax.com/books/dns/ch8/soa.html">Start of
          Authority Resource Record</link></para>
        </listitem>
      </itemizedlist>

Goik Martin's avatar
Goik Martin committed
      <para>Install the <productname>bind9</productname> server package on
Goik Martin's avatar
Goik Martin committed
      your first <quote>A</quote> virtual machine. The MI department has
      already set up a <xref linkend="glo_DNS"/> service for
Goik Martin's avatar
Goik Martin committed
      <code>mi.hdm-stuttgart.de</code>. But regarding upcoming exercises we
Goik Martin's avatar
Goik Martin committed
      want to be able configuring private host aliases.</para>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
      <para>If you are a member of <abbrev>e.g.</abbrev> group 7 <code>then
      sdi04a.mi.hdm-stuttgart.de </code>will host your <xref
      linkend="glo_DNS"/> server. Create a complete new zone
      <code>g7.sdi.mi.hdm-stuttgart.de</code> containing both your machines
      <code>sdia.g7.sdi.mi.hdm-stuttgart.de</code> and
      <code>sdib.g7.sdi.mi.hdm-stuttgart.de</code> address records. Your <xref
Goik Martin's avatar
Goik Martin committed
      linkend="glo_DNS"/> server should provide at least the following
Goik Martin's avatar
Goik Martin committed
      data:</para>

      <glosslist>
        <glossentry>
Goik Martin's avatar
Goik Martin committed
          <glossterm>Your g7.sdi.mi.hdm-stuttgart.de domain's primary
Goik Martin's avatar
Goik Martin committed
          nameserver</glossterm>
Goik Martin's avatar
Goik Martin committed

          <glossdef>
            <para>Primary name server for domain
Goik Martin's avatar
Goik Martin committed
            <code>g7.sdi.mi.hdm-stuttgart.de</code>.</para>
Goik Martin's avatar
Goik Martin committed
          </glossdef>
        </glossentry>

        <glossentry>
Goik Martin's avatar
Goik Martin committed
          <glossterm>vm1.g7.sdi.mi.hdm-stuttgart.de</glossterm>
Goik Martin's avatar
Goik Martin committed

          <glossdef>
Goik Martin's avatar
Goik Martin committed
            <para>Your first machine's host name.</para>
Goik Martin's avatar
Goik Martin committed
          </glossdef>
        </glossentry>

        <glossentry>
Goik Martin's avatar
Goik Martin committed
          <glossterm>vm2.g7.sdi.mi.hdm-stuttgart.de</glossterm>
Goik Martin's avatar
Goik Martin committed

          <glossdef>
Goik Martin's avatar
Goik Martin committed
            <para>Your second machine's host name.</para>
Goik Martin's avatar
Goik Martin committed
          </glossdef>
        </glossentry>

        <glossentry>
Goik Martin's avatar
Goik Martin committed
          <glossterm>www.g7.sdi.mi.hdm-stuttgart.de and
          cloud.g7.sdi.mi.hdm-stuttgart.de</glossterm>
Goik Martin's avatar
Goik Martin committed

          <glossdef>
Goik Martin's avatar
Goik Martin committed
            <para>(<code>CNAME</code>) aliases to
            <code>vm1.g7.sdi.mi.hdm-stuttgart.de</code> or
            <code>vm2.g7.sdi.mi.hdm-stuttgart.de</code>.</para>
Goik Martin's avatar
Goik Martin committed
          </glossdef>
        </glossentry>
      </glosslist>

Goik Martin's avatar
Goik Martin committed
      <para>All host names (albeit not yet existing) should point to your
Goik Martin's avatar
Goik Martin committed
      virtual machines' IP. This requires setting up a forward zone
Goik Martin's avatar
Goik Martin committed
      file.</para>
Goik Martin's avatar
Goik Martin committed

      <tip>
        <orderedlist>
          <listitem>
            <para>The <command>named-checkzone</command> command helps you to
            check for your two zone files' correctness</para>
          </listitem>

          <listitem>
            <para>The <command>named-checkconf</command> command checks for
            your configuration's overall correctness.</para>
          </listitem>

          <listitem>
            <para>You may use the <command>nslookup</command> command to query
            your <xref linkend="glo_DNS"/> server. The <option>set
            type=ns</option> option allows to query for the domain's primary
            name server.</para>
          </listitem>
        </orderedlist>
      </tip>
Goik Martin's avatar
Goik Martin committed

      <itemizedlist>
        <listitem>
          <para><code>ns</code> (Nameserver)</para>
        </listitem>

        <listitem>
Goik Martin's avatar
Goik Martin committed
          <para><code>www</code> (Future webserver, see <xref
Goik Martin's avatar
Goik Martin committed
          linkend="sdiApache"/>).</para>
        </listitem>
      </itemizedlist>

      <para>Test your configuration using <code>dig</code> <option>@&lt;your
      host-IP&gt;</option> <option>...</option> . You should be able to
Goik Martin's avatar
Goik Martin committed
      resolve e.g. <code>www.g7.sdi.mi.hdm-stuttgart.de</code> to your local
Goik Martin's avatar
Goik Martin committed
      host's IP address.</para>
Goik Martin's avatar
Goik Martin committed
    </section>

    <section xml:id="sdiDnsReverse">
      <title>Reverse lookups</title>

      <para>Define a reverse zone file to answer queries asking for an IP
      address' machine name <abbrev>i.e.</abbrev> resolving
      <code>141.62.75.104</code> to
Goik Martin's avatar
Goik Martin committed
      <code>vm1.g7.sdi.mi.hdm-stuttgart.de</code>.</para>
Goik Martin's avatar
Goik Martin committed
    </section>

    <section xml:id="sdiDnsForwarder">
      <title>Forwarders</title>

Goik Martin's avatar
Goik Martin committed
      <para>Enable recursive queries to parent name servers enabling your own
      private name server to resolve external machines like
      <code>www.w3.org</code> by delegation.</para>
Goik Martin's avatar
Goik Martin committed

      <tip>
        <para>You may have to disable <code>DNSSEC</code> in order to allow
        for recursive queries.</para>
      </tip>
    </section>

    <section xml:id="sdiBindMx">
      <title>Mail exchange record</title>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
      <para>Provide a mail exchange record pointing to
      <code>mx1.hdm-stuttgart.de</code>. Test this configuration using
      <command>dig</command> accordingly.</para>
Goik Martin's avatar
Goik Martin committed

Goik Martin's avatar
Goik Martin committed
      <para>Caveat: Configuring a client machine using your name server and
Goik Martin's avatar
Goik Martin committed
      sending a mail to <code>xy123@g7.sdi.mi.hdm-stuttgart.de</code> won't
      actually work since <code>mail.hdm-stuttgart.de</code> will reject mails
      being sent to any domain other than certain subdomain of
      <code>hdm-stuttgart.de</code>.</para>
Goik Martin's avatar
Goik Martin committed
    </section>
Goik Martin's avatar
Goik Martin committed

    <section xml:id="sdiDnsProjectNameServer">
      <title>SDI exercises related <xref linkend="glo_DNS"/> server</title>

Goik Martin's avatar
Goik Martin committed
      <para>In this part you'll transfer your current <xref
      linkend="glo_DNS"/> configuration to a dedicated MI nameserver
      <code>nssdi.mi.hdm-stuttgart.de</code>. This one being connected to the
      global <xref linkend="glo_DNS"/> system allows for publishing your
      records worldwide.</para>

      <figure xml:id="sdiDnsSubdomainPerGroup">
        <title>Subdomain per group</title>
        <itemizedlist>
          <listitem>
            <para>Dedicated lecture related <xref linkend="glo_DNS"/> server
            <code>nssdi.mi.hdm-stuttgart.de</code>.</para>
          </listitem>
          <listitem>
            <para>One subdomain per group <acronym>e.g.</acronym> <emphasis
            role="red">g7.sdi.mi.hdm-stuttgart.de</emphasis> corresponding to
            <emphasis role="red">group 7</emphasis>.</para>
          </listitem>
          <listitem>
            <para>Zone edits require a subdomain specific <code>hmac</code>
            secret key being provided as <filename>dnsupdate.sec</filename>
Goik Martin's avatar
Goik Martin committed
            file in your personal group entry below the <link
            xlink:href="https://learn.mi.hdm-stuttgart.de/ilias/goto.php?target=crs_33735">SDI
            course</link>:</para>

            <screen>hmac-sha256:mykey.<emphasis role="red">g7</emphasis>:I5sDDS3L1BU...</screen>

            <note>
              <para>The per zone secrets are being created using <link
              xlink:href="https://manpages.ubuntu.com/manpages/jammy/man8/ddns-confgen.8.html">tsig-keygen</link>.
              The value appearing here does not reflect a production
              setting.</para>
            </note>
          </listitem>
Goik Martin's avatar
Goik Martin committed
            <para>Edits become globally visible. Mind the TTL setting: A
            higher value means you'll have to wait longer until error
            corrections become visible.</para>
          </listitem>
        </itemizedlist>
      </figure>

      <figure xml:id="sdiDnsQueryZone">
        <title>Querying <xref linkend="glo_DNS"/> zone</title>

        <screen>$ export HMAC=hmac-sha256:mykey.g7:YXWSeh3l... 
$ dig @<emphasis role="red">nssdi.mi.hdm-stuttgart.de</emphasis> -y <emphasis
            role="red">$HMAC</emphasis> -t AXFR <emphasis role="red">g7.sdi.mi.hdm-stuttgart.de</emphasis> 
...
g7.sdi.mi.hdm-stuttgart.de. 86400 IN	SOA	nssdi.mi.hdm-stuttgart.de. goik.hdm-stuttgart.de. ...
docu.g7.sdi.mi.hdm-stuttgart.de. 5000 IN CNAME	www.g7.sdi.mi.hdm-stuttgart.de.
manual.g7.sdi.mi.hdm-stuttgart.de. 5000 IN CNAME www.g7.sdi.mi.hdm-stuttgart.de.
nextcloud.g7.sdi.mi.hdm-stuttgart.de. 5000 IN CNAME www.g7.sdi.mi.hdm-stuttgart.de.
...</screen>
      </figure>

      <figure xml:id="sdiDnsNsupdateAddRecord">
        <title>Creating an <code>A</code> record</title>

        <programlisting language="bash">export HMAC=hmac-sha256:mykey.g7:YXWSeh3l... 
Goik Martin's avatar
Goik Martin committed

goik&gt;nsupdate -y $HMAC
&gt; server nssdi.mi.hdm-stuttgart.de
Goik Martin's avatar
Goik Martin committed
&gt; update add vm2.<emphasis role="red">g7</emphasis>.sdi.mi.hdm-stuttgart.de 86400 A 141.62.75.114
Goik Martin's avatar
Goik Martin committed
&gt; send
&gt; quit
Goik Martin's avatar
Goik Martin committed
goik&gt;dig +noall +answer @nssdi.mi.hdm-stuttgart.de vm2.<emphasis role="red">g7</emphasis>.sdi.mi.hdm-stuttgart.de
vm2.<emphasis role="red">g7</emphasis>.sdi.mi.hdm-stuttgart.de. 86400	IN A	141.62.75.114</programlisting>
Goik Martin's avatar
Goik Martin committed
      <para>This entry should now be globally visible:</para>
Goik Martin's avatar
Goik Martin committed
      <programlisting language="none">&gt;dig +noall +answer  vm2.<emphasis
          role="red">g7</emphasis>.sdi.mi.hdm-stuttgart.de
Goik Martin's avatar
Goik Martin committed
vm2.<emphasis role="red">g7</emphasis>.sdi.mi.hdm-stuttgart.de. 7069 IN A	141.62.75.114</programlisting>
      <figure xml:id="sdiDnsNsupdateDeleteRecord">
        <title>Modify by delete/create</title>
        <programlisting language="bash">$ nsupdate -y $HMAC
Goik Martin's avatar
Goik Martin committed
&gt; server nssdi.mi.hdm-stuttgart.de
&gt; update delete admin.g3.sdi.mi.hdm-stuttgart.de. <emphasis role="red">3600</emphasis> IN	CNAME	www.g3.sdi.mi.hdm-stuttgart.de.
&gt; update add admin.g3.sdi.mi.hdm-stuttgart.de. <emphasis role="red">7200</emphasis> IN	CNAME	www.g3.sdi.mi.hdm-stuttgart.de.
Goik Martin's avatar
Goik Martin committed
&gt; send
&gt; quit</programlisting>
Goik Martin's avatar
Goik Martin committed

        <note>
          <para>Examples at <link
          xlink:href="https://serverless.industries/2020/09/27/dns-nsupdate-howto.en.html">DNS
          Updates with nsupdate</link></para>
        </note>
Goik Martin's avatar
Goik Martin committed

      <para>Due to caching it'll however take up to you <abbrev>SOA</abbrev>
      or record specific settings for this deletion to be reflected globally.
      The subsequent query result indicates another 7069 seconds to go before
Goik Martin's avatar
Goik Martin committed
      issuing the next update:</para>
Goik Martin's avatar
Goik Martin committed
      <programlisting language="none">goik&gt;dig +noall +answer  vm2.<emphasis
          role="red">g7</emphasis>.sdi.mi.hdm-stuttgart.de
Goik Martin's avatar
Goik Martin committed
vm2.<emphasis role="red">g7</emphasis>.sdi.mi.hdm-stuttgart.de. 7069 IN A	141.62.75.114</programlisting>
Goik Martin's avatar
Goik Martin committed
    </section>
Goik Martin's avatar
Goik Martin committed
  </section>
</chapter>