Open main menu

CDOT Wiki β

Changes

OPS335 DNS Lab

8,592 bytes removed, 02:51, 3 February 2016
Redirected page to OPS335 DNS Lab
#REDIRECT [[Category:OPS335]][[Category:OPS335 Labs]]= 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. We will not be setting up our server to do [https://en.wikipedia.org/wiki/Reverse_DNS_lookup Reverse DNS Lookups] but you are expected to understand the difference, in particular you should understand that:* Your registrar (whomever you pay for your domain, even if you run your own DNS server) is responsible for normal (forward) DNS resolution of your domain.* Your ISP (whomever you pay for your internet connection, i.e. the company that assigned a public IP to your server) is responsible for revers DNS lookups for your IP. = INVESTIGATION 1: CONFIGURING THE 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 === When you install Bind you'll get a default '/etc/named.conf'. Move this file over to a backup location, we will be writing one from scratch with the following contents, but use your own X value where applicable. <pre>options { directory "/var/named/"; allow-query {127.0.0.1; 192.168.X.0/24;}; forwarders { 142.204.1.2; };};zone "localhost" { type master; file "named.localhost";};zone "'''seneca-id'''.org" { type master; file "mydb-for-yoursenecaid-org";};</pre> You need to understand all the options in this file except the localhost zone, so that in the future (for example in a practical test) you can quickly set up a DNS server for a new zone. So look up in [http://www.zytrax.com/books/dns/ch7/statements.html the reference] these things and write down what they do: * directory* allow-query* forwarders* type* file === Zone file === Now edit '''/var/named/mydb-for-yoursenecaid-org''' and enter the following (use your own X value where applicable). <pre>$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.yoursenecaid.org.vm1 IN A 192.168.X.2</pre> Again, here's the [http://www.zytrax.com/books/dns/ch8/ reference documentation] for records in this file. Pay specific attention to: * asd Now that your DNS server (bind, a.k.a. named) is configured: # Start it with the systemctl command.# Check that it's running using:#* The ps ax command (perhaps combined with grep)#* A systemctl command#* The system log file /var/log/messages# Once you're sure the service starts and runs without errors - set it to start automatically when this virtual machine boots. == Firewall rules update == Remember you're supposed to have a working firewall on your vm1 (and every other machine, but this is the one we're concerned with now). A working firewall will block requests to ports that you didn't explicitly allow. Which means at this point your DNS server, even though it's perfetly configured, is inaccessible because iptables won't allow the requests to come in. You'll need to update the firewall on vm1 to allow incoming connections in UDP port 53 - that's the protocol and port DNS works over. Then save your rules using whatever means worked for you in the iptables labs. You can just disable the firewall but that is a poor workaround. You're expected to be able to handle configuration like this in this course. = INVESTIGATION 2: CONFIGURING THE DNS CLIENT = Now that you've setup a DNS server on vm1 - you need to configure all our VMs to use that as the default DNS server. You should know how to do that, if you forgot - go back to [[OPS335_Lab_1 | Lab 1]] to remind yourself. You can but you shouldn't set your host to use vm1 as the DNS server. DNS is a critical component of your network setup and if it's not working right - you won't even be able to look for a solution online (or get to this wiki page) on your host. Also your host is configured to be a DHCP client and it gets its DNS server assigned automatically. == Testing == The following commands should work as expected on all your VMs: <source lang="bash">host host.yoursenecaid.orghost yoursenecaid.orghost yoursenecaid.orghost yoursenecaid.orghost google.ca</source> Also on the VMs use a text browser such as lynx to access the Web. Experiment with the following commands. Use the '''dig''' command to query your DNS server for specific records (up to this point you only have NS and A records). == COMPLETING THE LAB == Upon completion of this lab you have a DNS server in your network and every virtual machine is using it to resolve internal and external hostnames. 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 vm1 running in order for any of your virtual machines to be able to use the internet. '''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;">&#x2713;</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?