|
|
(15 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | [[Category:OPS335]][[Category:OPS335 Labs]]
| + | #REDIRECT [[OPS335_Lab_3]] |
− | = DOMAIN NAME SYSTEM (DNS) =
| |
− | == Lab goal ==
| |
− | | |
− | In this lab you will configure a Linux machine to be a DNS server for the rest of the machines in your intranet. You'll '''use <u>your</u> MySeneca ID as your domain'''. The server will handle all queries for names in the '''yoursenecaid.org''' domain. The server will pass DNS queries for other names and addresses out to the Internet (i.e. to Seneca's DNS server).
| |
− | | |
− | This is the current state of our internal network when your harddrive is plugged into a lab machine. Note that if any of the listed services aren't working for you - you should fix them (especially your iptables which may block DNS traffic needed for this lab):
| |
− | | |
− | [[Image:Lab2network.png]]
| |
− | | |
− | You can see in the diagram above that when one of your VMs does a name resolution request:
| |
− | * The VM contacts the host, which is running a DNS proxy (a.k.a. stub resolver), not a full DNS server
| |
− | * The DNS proxy on the host contacts the Seneca DNS server, which was assigned to be used on the host via DHCP
| |
− | * Depending on the request - the Seneca DNS server may contact other DNS servers to get the answer to the request.
| |
− | | |
− | After you're finished with this lab - your vm1 will be running a full-featured DNS server, which is how you're going to get the '''yoursenecaid.org''' domain without paying for it. Unfortunately you'll be the only one using your DNS server so noone else will be able to resolve hosts under '''yoursenecaid.org'''
| |
− | | |
− | == How DNS resolution works ==
| |
− | | |
− | We'll go over this in class, but you should also read in your own time the [https://en.wikipedia.org/wiki/Domain_Name_System#Address_resolution_mechanism Address resolution mechanism] section (including the Recursive and caching name server subsection) on Wikipedia for an overview of a DNS query. The diagram there is also quite simple and appropriate. DNS is a large topic but this is the minimum that you need to understand for this course.
| |
− | | |
− | = INVESTIGATION 1: CONFIGURING DNS SERVER =
| |
− | | |
− | We will now be installing, configuring and running a '''DNS server on our vm1'''.
| |
− | | |
− | == Preparation ==
| |
− | | |
− | First ensure that the host and domain name is set correctly on each of your four machines (host and three VMs):
| |
− | | |
− | * host.yoursenecaid.org
| |
− | * vm1.yoursenecaid.org
| |
− | * vm2.yoursenecaid.org
| |
− | * vm3.yoursenecaid.org
| |
− | | |
− | Note that these are settings that are local to each mahcine, e.g. you will still not be able to contact vm1.yoursenecaid.org from vm3. That's because currently you're using the Seneca and other public DNS servers which know nothing about yoursenecaid.org
| |
− | | |
− | This preparation step is in fact unnecessary to complete our goal for the lab (do you know why?) but it will make things look more consistent, which will make your life a little easier.
| |
− | | |
− | == Installation ==
| |
− | | |
− | Use yum to install the DNS server. We'll be using Bind, the most popular DNS server on the planet.
| |
− | | |
− | == Configuration ==
| |
− | | |
− | An [https://en.wikipedia.org/wiki/Domain_Name_System#Authoritative_name_server authoritative] Bind server has a global configuration file (named.conf) and at least one zone file for the zone it's authoritative for.
| |
− | | |
− | === /etc/named.conf ===
| |
− | | |
− | #Still on the virtual machine create a back up of the existing '/etc/named.conf', delete the existing contents and add the following, but use your own X value where applicable. ([http://www.zytrax.com/books/dns/ch7/ Here is documentation] for all the available options in named.conf, look up the ones that you're using so that you know exactly what they do.
| |
− | options {
| |
− | directory "/var/named/";
| |
− | allow-query {127.0.0.1; 192.168.X.0/24;};
| |
− | forwarders { 142.204.33.54;};
| |
− | };
| |
− | zone "localhost" {
| |
− | type master;
| |
− | file "named.localhost";
| |
− | notify NO;
| |
− | };
| |
− | zone "X.168.192.in-addr.arpa" {
| |
− | type master;
| |
− | file "mydb-for-192-168-X";
| |
− | notify NO;
| |
− | };
| |
− | zone "'''seneca-id'''.org" {
| |
− | type master;
| |
− | file "mydb-for-'''seneca-id'''-org";
| |
− | notify NO;
| |
− | };
| |
− | | |
− | <ol><li value="2">Set the filesystem permissions for the above file to 644</li><li>Now edit '''/var/named/mydb-for-'''seneca-id'''-org''' and enter the following: But use your own X value where applicable. Note: if you copy-paste this code, there should be NO leading spaces before the first column of text (and [http://www.zytrax.com/books/dns/ch8/ here's a bit of documentation] to explain what the contents of this file are).</li></ol>
| |
− | | |
− | $TTL 3D
| |
− | @ IN SOA vm1.'''seneca-id'''.org. webmaster.'''seneca-id'''.org.(
| |
− | 1 ; Serial
| |
− | 8H ; Refresh
| |
− | 2H ; Retry
| |
− | 1W ; Expire
| |
− | 1D ; Negative Cache TTL
| |
− | );
| |
− | @ IN NS vm1.'''seneca-id'''.org.
| |
− | vm1 IN A 192.168.X.2
| |
− | | |
− | <ol><li value="4">Next, edit /var/named/mydb-for-192-168-X and enter the following:</li></ol>
| |
− | | |
− | $TTL 3D
| |
− | @ IN SOA vm1.'''seneca-id'''.org. webmaster.'''seneca-id'''.org. (
| |
− | 1 ; Serial
| |
− | 8H ; Refresh
| |
− | 2H ; Retry
| |
− | 1W ; Expire
| |
− | 1D ; Negative Cache TTL
| |
− | );
| |
− | @ IN NS vm1.'''seneca-id'''.org.
| |
− | 2 IN PTR vm1.'''seneca-id'''.org.
| |
− | | |
− | <ol><li value="5">Now set up your resolver to point to itself. Edit /etc/resolv.conf, delete what's there and enter this data instead. Remember to use your value for X:</li></ol>
| |
− | | |
− | nameserver 192.168.X.2
| |
− | search '''seneca-id'''.org
| |
− | | |
− | <ol><li value="6">Note that this is only temporary, and will go away when the machine reboots. There is another step later that will make this change permanently.</li><li>Start your DNS server with the command:<br><pre>systemctl start named.service</pre></li><li>Check that your name server is running:<br><pre>ps ax | grep named</pre> or <pre>systemctl status named.service</pre></li><li>Set the service to start automatically when this virtual machine boots.</li><li>When starting or restarting your name server view the log file (/var/log/messages) to ensure it started without error.</li><li>Try a few lookups:
| |
− | <pre>host host.'''seneca-id'''.org
| |
− | host vm1.'''seneca-id'''.org
| |
− | host vm2.'''seneca-id'''.org
| |
− | host vm3.'''seneca-id'''.org
| |
− | host cbc.ca</pre>
| |
− | </li></ol>
| |
− | | |
− | | |
− | <ol><li value="12">Now try a few reverse lookups:
| |
− | <pre>
| |
− | host 192.168.X.1
| |
− | host 192.168.X.2
| |
− | host 192.168.X.3
| |
− | host 192.168.X.4
| |
− | </pre>
| |
− | </li></ol>
| |
− | | |
− | | |
− | | |
− | <ol><li value="13">You'll notice that only the queries for vm1 worked. That's because you only have the resource records for vm1. Go back to the zone files and add the appropriate records for your other machines.</li><li>Once you have done so, restart the service and try querying for those records again</li><li>Modify your firewall to allow the other machines to query your new DNS server.</li></ol>
| |
− | | |
− | | |
− | '''Record troubleshooting checklist for INVESTIGATION 1 in your OPS335 lab log-book'''
| |
− | | |
− | ==INVESTIGATION 2: CONFIGURING DNS (CLIENT SIDE - Centos7 Host Machine)==
| |
− | | |
− | Now that we have setup a DNS server on your virtual machine (vm1), we will now switch to the host machine, and define the name server that is running on vm1 in order to resolve the seneca-id domain name to the appropriate IP address.
| |
− | | |
− | | |
− | '''Perform the following steps on your Centos host:'''
| |
− | | |
− | <ol><li value="1">Edit the '''/etc/resolv.conf''' file and enter the following:
| |
− | <pre>nameserver 192.168.X.2
| |
− | domain '''seneca-id'''.org</pre>
| |
− | </li>
| |
− | <li>Now try the commands:
| |
− | <pre>
| |
− | host host.'''seneca-id'''.org
| |
− | host vm1.'''seneca-id'''.org
| |
− | host vm2.'''seneca-id'''.org
| |
− | host vm3.'''seneca-id'''.org
| |
− | host yahoo.ca
| |
− | </pre>
| |
− | <pre>
| |
− | host 192.168.X.1
| |
− | host 192.168.X.2
| |
− | host 192.168.X.3
| |
− | host 192.168.X.4
| |
− | </pre>
| |
− | </li></ol>
| |
− | <ol><li value="4">Now configure your other virtual machines to also use VM 1 as their DNS server.</li><li>Also on the VMs use a text browser such as lynx to access the Web.<br><br>(NOTE: you do not need to authenticate yourself through SeneNet on this machine, as they connects through the host which is already authenticated)</li><li>On all machines in your network, experiment with the following commands. Be sure to use several different command options to learn and understand how they work:<br><br>
| |
− | <pre>
| |
− | host
| |
− | dig
| |
− | nslookup
| |
− | </pre>
| |
− | </li></ol>
| |
− | | |
− | | |
− | | |
− | {{Admon/important| These final steps are important!| Failure to complete this will cause problems with future labs.}}
| |
− | | |
− | | |
− | <ol><li value="7">Finally, ensure each machine is using the static IP address and hostname that matches what the DNS server now claims they use. Double check that this address, and the ability to search using your DNS server, persist after reboot.</li><li>On each machine add the entry to your interface configuration file that will cause it to permanently use your VM 1 as its primary DNS server.</li><li>If you have made any changes to the /etc/hosts file, undo them. Your machines must be relying on your DNS server.</li><li>Ensure that your machines can ping and SSH to each other by IP address and by name (hostname only, and hostname with domain).</li><li>Modify the ifcfg file on your host so that it will still get a DHCP address, but ignore the DNS information given to it by the DHCP server in favour of the domain and DNS information you provide it.</li></ol>
| |
− | | |
− | | |
− | '''Record troubleshooting checklist for INVESTIGATION 2 in your OPS335 lab log-book'''
| |
− | | |
− | | |
− | == COMPLETING THE LAB ==
| |
− | [[Image:lab1_signoff.png|thumb|right|300px|Students should be prepared with '''all required commands (system information) displayed in a terminal (or multiple terminals) prior to calling the instructor for signoff'''.]]
| |
− | | |
− | Upon completion of this lab you have a DNS server in your network and every machine is using it to resolve internal and external hostnames and ip addresses.
| |
− | | |
− | You have now gained experience with some common configuration settings for named, as well as common resource records.
| |
− | | |
− | Note: Due to the changes made in this lab, you will now need your VM 1 running in order for you host to be able to contact any other machines.
| |
− | | |
− | '''Arrange evidence (command output) for each of these items on your screen, then ask your instructor to review them and sign off on the lab's completion:'''
| |
− | | |
− | ::<span style="color:green;font-size:1.5em;">✓</span>x.
| |
− | | |
− | | |
− | | |
− | ==EXPLORATION QUESTIONS==
| |
− | #What iptables rules apply to DNS?
| |
− | #Under what circumstances does DNS use TCP vs UDP?
| |
− | #What is a zone file and what is it used for?
| |
− | #Name the zone files used in this lab, and their purpose.
| |
− | #What file did you edit to set a static IP address?
| |
− | #What parameter did you set in that file to tell the machine to refer to your own DNS server?
| |
− | #What is the purpose of /etc/resolv.conf?
| |
− | #What is meant by the term "negative cache"?
| |
− | #What are MX records used for?
| |
− | #What security features are available for DNS?
| |