Changes

Jump to: navigation, search

OPS335 Lab 3

41 bytes added, 14:46, 14 February 2020
Testing
== OBJECTIVE & PREPARATION==
In this lab, you will configure a Linux machine to be a DNS server for the rest of the machines in your Intranet. You will '''use <u>your</u> MySeneca ID (the one based on your name, not your student number) as your domain'''. The server will handle all queries for names in the '''yoursenecaid.ops''' domain. The server will also pass DNS queries for other names and addresses out to the Internet (i.e. to Seneca's DNS server).
=== Online Resources===
After you have completed this lab, your '''vm1host''' VM will be running a full-featured DNS server (which is how you're going to get the '''yoursenecaid.ops''' domain without paying for it). Unfortunately, you will be the only one using your DNS server so no-one else will be able to resolve hosts under '''yoursenecaid.ops'''
=== How DNS resolution works ===
We will review in class how the Domain Name Service works. You should also read in your own time the [https://en.wikipedia.org/wiki/Domain_Name_System#Address_resolution_mechanism the DNS article on Wikipedia] for an overview of a DNS query - especially the Address resolution mechanism] section (including the '''Recursive''' and '''caching name server''' subsections) on '''Wikipedia for an overview of a DNS query'''. The diagram shown in the WIKI is also quite simple and easy to understand. Domain Name Service is a LARGE topic but this lab provides the basic principles and essentials for this course and DNS set-up for other courses. 
= INVESTIGATION 1: CONFIGURING THE DNS SERVER =
We will now be '''installing, configuring and running a DNS server on our vm1host'''. In most networks, the gateway would '''not''' also be a DNS server,but if we placed ours on a separate virtual machine we would need that VM to always be running in order for the other VMs to retrieve updates, install software, or even communicate with each other.
== Preparation ==
First, ensure that the '''host''' and '''vms''' are running, and (on that none of your machines have entries for the host only) set or any of the '''domain name''' of each of your four machines via '''VMs in /etc/hosts''': * '''host.yoursenecaid.ops'''* '''vm1.yoursenecaid.ops'''* '''vm2.yoursenecaid.ops'''* '''vm3.yoursenecaid.ops'''  You should notice that these host and domain names are settings that are <u>local</u> to each machine. What In previous courses you did may have relied on the host does not affect the VMs and contents of /etc/hosts but you will still not be able to contact '''vm1.yoursenecaid.ops''' from '''vm3'''. That occurs since use them in this course so that you are currently using the '''Seneca''' and other public can see how vital a properly functioning DNS servers which know nothing about domain name: ''yoursenecaid.ops'' This preparation step server is actually unnecessary for this lab's purpose (do you know why it is unnecessary?). On the other hand, by performing the above operations, it will make things appear more consistent, and may make your life a little easier.
== Installation ==
Install Bind on your '''vm1host''' machine.
== Configuration ==
=== /etc/named.conf ===
When you install Bind you'll get a default '''/etc/named.conf'''. Copy this file over to a backup location and empty the original (If you have SELinux enabled - do not delete or move it the file as that will cause SELinux not to trust it). We will be writing one from scratch with only the following contents, but use your own X XX value where applicable.
<pre>
options {
directory "/var/named/";
allow-query {127.0.0.1; 192.168.XXX.0/24;}; #forwarders { 142208.20467.1222.2222; };# This one works at home forwarders { 10.102.100.21; }; # This one works at Seneca
};
zone "localhost" {
* '''type'''
* '''file'''
 
Note: If you are using a drive an a removable bay, you will need to set the forwarders address differently. Pick any one of the DNS servers that are provided through DHCP.
=== Zone file ===
Now edit '''/var/named/mydb-for-yoursenecaid-orgops''' and enter the following (use your own X XX value and domain where applicable).
<pre>
$TTL 3D
@ IN SOA vm1host.yoursenecaid.ops. hostmaster.yoursenecaid.ops.( 2016010301 2018042901 ; Serial
8H ; Refresh
2H ; Retry
1D ; Negative Cache TTL
);
@ IN NS vm1host.yoursenecaid.ops.vm1 host IN A 192.168.XXX.21
</pre>
# Check that the ''named'' service is running using the '''ps ax''' command (perhaps combined with '''grep'''), and separately, the '''systemctl''' command (if necessary), or check the '''/var/log/messages''' file for troubleshooting purposes.
# Once you are certain that the ''named'' service had started and runs without errors, then set it to '''start automatically''' (i.e. enable the named service) when this virtual machine boots.
# You also need to set it self '''vm1(127.0.0.1)''' as the primary domain name server ('''DNS1''') for your '''vm1host''' machine to your '''vm1 host machine's ifcfg file'''<br /># If your host's external facing interface (ens33) is on DHCP, you will need to also add PEERDNS=NO to ifcfg file to prevent DHCP server from assigning the original DNS server (i.e. 192.168.40.2 which is used as forwarder instead by the DNS server you are setting up) <br /><br />'''NOTE:''' You should know how to do that, but if you forgot the procedure, refer to [http://zenit.senecac.on.ca/wiki/index.php/OPS335_Lab_1#Making_Persistent_.28Permanent.29_Network_Setting_Changes Lab 1].<br><br># Now that you know the service works, '''add the resource records necessary for it to provide forward lookups of the other machines in your virtual network''' (hint: You should only need three morerecords) and restart the service.
== Firewall rules update ==
Remember that you are supposed to have a working firewall on your '''vm1host''' (and every other machine), but we will focus on our vm1 '''host''' machine for now. A <u>working</u> firewall will block requests to ports that you didn't explicitly allow. This means that at this point, your DNS server, even though it's perfectly configured, is <u>'''inaccessible'''</u> to any other machine because iptables won't allow the requests to come in (the machine can communicate with itself using the rule that allows all traffic on the '''lo''' interface).
'''Perform the Following Steps:'''
# Note: Since you are going to save your firewall at the end of this step, you may wish to '''stop libvirtd''' and '''restart iptables''' now in order to avoid saving the rules the libvirtd automatically adds to your INPUT, FORWARD, and POSTROUTING chains.# You will need to update the firewall on '''vm1host''' to allow <u>incoming</u> connections to '''port 53 for both UDP and TCP''' (i.e. the protocol and port that DNS uses).# After you have updated your firewall, then save your iptables rules using whatever means worked for .# <b>Once you in the iptables labs rules are saved, restart libvirtd to ensure NAT and add it to a shell scriptforwarding rules are re-added.</b>
'''NOTE:''' You could just disable the firewall '''but that is a poor workaround!''' You are expected to be able to handle configuration (such as this) at this point in this course.
'''Record steps, commands, and your observations in INVESTIGATION 1 in your OPS335 lab log-book'''
 
= INVESTIGATION 2: CONFIGURING THE DNS CLIENT =
Before proceeding, we need to set the primary DNS server (DNS1 ) in your '''ifcfg-eth0''' (or ''ifcfg-en0'') file for your network interface cards for your virtual machines. Also it is a good idea to install the '''bind-utils''' package on those other VMs as well in order to perform queries on your vm1 host domain name server.
'''Perform the following Steps:'''
#Only install Install the '''bind-utils''' package for your '''vm2''' and '''vm3''' virtual machines.#You will need to configure your '''vm2''' and '''vm3''' VMs to use vm1your host's IPADDR as the '''default DNS server''' (DNS1) in your '''ifcfg-eth0''' (or ''ifcfg-en0'') file for your network interface card.<br>You should know how to do that, but if you forgot the procedure, refer to [http://zenit.senecac.on.ca/wiki/index.php/OPS335_Lab_1#Making_Persistent_.28Permanent.29_Network_Setting_Changes Lab 1].# You should Modify the hostname of '''NOTeach machine''' set your Host Machine (host and all three VMs) to use '''vm1''' as match what the DNS server. DNS says it 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 pageincluding the domain) on your host. Also your host is configured to This will be a DHCP client and it gets its DNS server assigned automaticallyimportant for services we configure in later labs.
== Testing ==
<ol><li>Issue the following commands to verify that you set-up your DNS server correctly on all of your VMs and google and your host machine:
<source lang="bash">
host vm1.yoursenecaid.ops
host vm2.yoursenecaid.ops
<li>Also try the following commands:
<source lang="bash">
host vm1
host vm2
{{Admon/important |Host Command Doesn't Work|Your machines do not know what domain to automatically add to the end of hostnames (or believe they are still in the seneca domain). The '''SEARCH''' (or DOMAIN) parameter in the '''ifcfg-eth0''' file is used to specify your own domain (eg. '''yoursenecaid.ops''' ).<br><br>}}
<li> Add the '''SEARCH''' (or DOMAIN) parameter for your '''ifcfg-eth0''' file as shown above for your '''vm1host''' machine.</li><li> Issue the '''host ''' command for all vm names and host name to make certain that is works.</li>
<li>Also on all of the VMs, install and use a text-based browser called '''lynx''' to access the Web, and test-out to see if it works by issuing the command '''lynx''' with the URL as an argument.</li><li>Experiment with the following commands:<br>
<source lang="bash">
nslookup
dig</source>Use the '''dig''' command to query your DNS server for specific records (up to this point you only have NS, A, and SOA records).</li></ol>
 
 
{{Admon/important |Run vm1 (for DNS server) for Future labs|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.}}
 
'''Record steps, commands, and your observations in INVESTIGATION 2 in your OPS335 lab log-book'''
= INVESTIGATION 3: CONFIGURING THE DNS SERVER FOR REVERSE LOOKUPS =
As it stands now, your server will only handle forward resolution (converting names into addresses), but it is also common to need sometimes necessary to convert addresses back into human readable names. In some situations an For public IP addresses only your ISP will can provide this service for you, but most organizations at least need to handle their . For private networks you can set it up for your own internal addressesorganisation. You also But even if you're setting up reverse DNS on the public internet - you need to understand what information the ISP would require.
Issue the following commands on any of your VMs (once again replacing X XX with your network octet):
<source lang="bash">host 192.168.XXX.1host 192.168.XXX.2host 192.168.XXX.3host 192.168.XXX.4</source>
Each one should have failed because there is currently nothing that will handle this reverse lookup for you. This requires another zone on your server.
Add the following entry to your '''/etc/named.conf''' (once again replacing X XX with your own octet):
<pre>
zone "XXX.168.192.in-addr.arpa." {
type master;
file "mydb-for-192.168.XXX";
};
</pre>
<pre>
$TTL 3D
@ IN SOA vm1host.yoursenecaid.ops. hostmaster.yoursenecaid.ops.( 2016010301 2018042901 ; Serial
8H ; Refresh
2H ; Retry
1D ; Negative Cache TTL
);
@ IN NS vm1host.yoursenecaid.ops.2 1 IN PTR vm1host.yoursenecaid.ops.
</pre>
<ol><li>Refer to the [http://www.zytrax.com/books/dns/ch8/ ptr.html reference documentation] for '''PTR''' records.</li>
<li>Add the extra records needed to complete this zone (again, you should only need three more).</li>
<li>Restart the service and test these records to make sure they work.</li>
You have now gained experience with some common configuration settings for named, as well as common resource records.
As a final step'''Depending on your professor you will either be asked to submit the lab in class, modify or online. Follow the hostname appropriate set of each machine to match what the DNS server says it is instructions below.''' ===Online Submission (including Ahad Mammadov's Classes only)===Follow the domain). This will be important instructions for services we configure in later labslab 3 on blackboard.
===Andrew'''Depending on your professor you will either be asked to submit the lab in class, or online. Follow the appropriate set of instructions below.'''s sections===
===Online Submission (Peter CallaghanYou may choose to:* Submit screenshots of your work on Blackboard, in which case you don's Classes only)===t need to come to the lab.Follow * Or come to the instructions for lab 3 on moodle, show me your work, and talk to me about it. I want to hear what you've learned and answer any questions you have.
===In Class Submission===You'''Arrange evidence (command output) for each ll get the same grade regardless of these items on how you choose to submit your screen, then ask your instructor to review them and sign off on the lab's completion:'''work.
Expected results of this lab are:::<span style="color:green;font-size:1.5em;">&#x2713;</span>Comment out the hostname resolution (/etc/hosts) files for ALL vms, and use '''host''' command to query from a VM, the IPADDR for:<br><blockquote>'''host.yoursenecaid.ops''' , '''vm1.yoursenecaid.ops''' , '''vm2.yoursenecaid.ops''' , and '''vm3.yoursenecaid.ops'''<br/blockquote>::<span style="color:green;font-size:1.5em;">&#x2713;</span>'''nslookup''' information ('''A''', '''NS''', '''MX''' records) for :<br><blockquote>'''host.yoursenecaid.ops''' , '''vm1.yoursenecaid.ops''' , '''vm2.yoursenecaid.ops''' , '''vm3.yoursenecaid.ops'''.</blockquote>::<span style="color:green;font-size:1.5em;">&#x2713;</span>'''dig +trace''' for :<br><blockquote>'''host.yoursenecaid.ops''' , '''vm1.yoursenecaid.ops''' , '''vm2.yoursenecaid.ops''' , '''vm3.yoursenecaid.ops'''.</blockquote>::<span style="color:green;font-size:1.5em;">&#x2713;</span>Download the labcheck3.bash checking bash shell script by issuing the command:<br><br>and run '''wget httphttps://matrixict.senecac.onsenecacollege.ca/~peterandrew.callaghansmith/files/OPS335ops335/labcheck3.bash'''<br><br>set execute permission and run the shell script on your '''host''' machine. ::*For '''Peter's classes''', follow his Online Submission instructions in Moodle.::*For '''Murray's classes''', run command (piping to the '''more''' command) and show output to instructor.
::<span style="color:green;font-size:1.5em;">&#x2713;</span>Completed Lab3 log-book notes.
#What parameter did you set in that file to tell the machine to refer to your own DNS server?
#What is the purpose of the '''/etc/resolv.conf''' file?
#What is meant by the term "negative cache"?
#What are type '''A''' records used for?
#What security features are available for DNS?
572
edits

Navigation menu