Open main menu

CDOT Wiki β

Changes

OPS235 Lab 8 - CentOS7

1,686 bytes added, 12:18, 27 November 2019
no edit summary
{{Admon/caution|THIS IS AN OLD VERSION OF THE LAB|'''This is an archived version. Do not use this in your OPS235 course.'''}}
= LAB PREPARATION =
==Minimum Required Materials==
{|cellpadding="15" width="40%"#INVESTIGATION_3:_SECURING_THE_SSH_CONNECTION
|- valign="top"
|
*[http://man7.org/linux/man-pages/man1/tail.1.html tail]
*[http://linux.die.net/man/8/chkconfig chkconfig]
|
*[https://www.freebsd.org/cgi/man.cgi?query=dhcpd.conf&sektion=5&apropos=0&manpath=FreeBSD+9.0-RELEASE+and+Ports dhcpd.conf]
#:: <b><code><span style="color:#3366CC;font-size:1.2em;">rpm -q dhclient</span></code></b>
# If the package is not installed, you will get the message ''"package dhclient is not installed"'', otherwise, you will get the version information of the rpm package. Install the <b>dhclient</b> package if it was not installed.
# Check Issue the following command to see if install the dhcp server package is installed: <b><code><span style="color:#3366CC;font-size:1. If not: 2em;">yum install the dhcp server package.</span></code></b># Enter the command to list all the files installed from the DHCP server package by issuing the command: <b><code><span style="color:#3366CC;font-size:1.2em;">rpm -qla dhclientdhcp</span></code></b># What file appears to be a sample (example) configuration filefor dhcpd.conf?# Copy the sample '''dhcpd.conf.example''' file to the '''/etc/dhcp''' directory making sure it is named: '''/etc/dhcp/dhcpd.conf'''
'''Answer Part 1 observations / questions in your lab log book.'''
== Part 2: Configuring the DHCP Server==
[[Image:dhcp-config.png|thumb|right|600px500px|The '''dhcpd.config''' file allows the Linux system administrator to customize the DCHP server. Generally in this file are '''global settings''' (options that apply throughout entire network) and '''subnet declarations''' (options that apply only to that subnet). Whenever changes are made to this file, the '''DCHP service needs to be restarted''' to allow new settings to take effect.<br><br>'''NOTE: Any errors in this file (such as typos or missing semi-colons) can cause the DHCP server not to restart!''' ]]
# Remain in your '''centos3''' VM for this section.
# Click on the following link to access the online manual page for the following DHCP items to gain an understanding:<ul><li>[http://linux.die.net/man/8/dhcpd dhcpd]</li><li>[https://www.freebsd.org/cgi/man.cgi?query=dhcpd.conf&sektion=5&apropos=0&manpath=FreeBSD+9.0-RELEASE+and+Ports dhcpd.conf]</li><li>[http://linux.die.net/man/5/dhcp-options dhcpd-options]</li><li>[http://linux.die.net/man/5/dhcpd.leases dhcpd.leases]<br><br></li></ul># x::* broadcast-address::* default-lease-time::* max-lease-time (How is this different from "default-lease-time"?)::* domain-name::* domain-name-servers::* fixed-address::* group::* hardware::* host::* host-name::* range::* routers::* subnet::* subnet-mask<ol><li value="2"> Study the sample '''dhcpd.conf''' file to see examples of how these options are used.</li><li># Edit '''/etc/dhcp/dhcpd.conf''' and examine the top section of the file.</li><li>Insert the following global settings at the top of # Look for the comment: '''dhcpd.conf"option definitions common to all supported networks"''' file# Below that comment change the existing global options to reflect the newer values shown below:</libr><br></olbr>:: '''domain-name''' '''"ops235.org";''':: <br>'''domain-name-servers''' ; '''192.168.235.1;''':: <br><br>'''default-lease-time''' '''1200;''':: <br>'''max-lease-time''' '''3600;'''<olbr><br><li value="5"br>'''Note: ''' Any values for time are stated in seconds.</libr><libr>Save # View your editing sessions for typos (check for missing semicolons), then save and exit your editing session.</libr></olbr
'''Answer Part 2 observations / questions in your lab log book.'''
# Remain in your '''centos3''' VM for this section.
# Edit '''/etc/dhcp/dhcpd.conf''' for a second time.# View this file for existing subnet declarations. Note the syntax and the directive for '''range''' and the option for '''routers''' (gateway).# Now, and add a new subnet delcaration for your virtual network# :<br><br>The network address is : '''192.168.235.0/255.255.255.0''' and the <br>range of host addresses should be from : '''51 to 60'''# Also add a <br>default gateway (routers) for the virtual network of is: '''192.168.235.1'''<br><br>
# Save your editing session, and exit the text editor.
  <ol><li value="56">Open another terminal window (ssh into centos3 from the centos host as user root) and issue the following command:::: <br><b><code><span style="color:#3366CC;font-size:1.2em;">tail -f /var/log/messages</span></code></b><libr><br>(This will show you the last 10 lines of '''/var/log/messages''' continue to display new lines as they are added to the log.)<br><br></li>
<li>In your original terminal prompt attempt to start the '''dhcpd''' service.</li>
<li>You should see new lines being added to the messages file.</li>
<li>If your '''dhcpd''' service starts successfully, try to generate errors by editing the configuration file and introduce an error by removing a semicolon or closing curly bracket.</li>
<li>Restart your '''dhcpd''' service and observe the error messages generated. This is good practice to learn how to trouble-shoot and solve dhcpd errors.</li>
<li>Make certain that you have corrected those errors, and that your dhcpd service works properly.<li>Once the dhcpd service has is running, use the '''systemctl''' command to see if the dhcpd service is enabled. If it is not enabled, use the '''chkconfig''' command to enable the dhcpd service so it started automatically upon boot-up.</li>
</ol>
|}
# Use your '''centos2''' and '''centos3''' VMs for this section.
# On your '''centos3''' terminal window (via ssh from your c7host machine) make sure that the command <bbr><code><span style="color:#3366CC;font-size:1.2em;"b>tail -f /var/log/messages</span></code></b> is running.# On your '''centos2''' VM, change the configuration of '''eth0''' (or your interface name) to receive dynamic address configuration(i.e. via graphical application, for IVP4 tab, change ''Address'' from '''Manual''' to '''DHCP''', and '''Apply''' settings)<br>([http://zenit.senecac.on.ca/wiki/index.php/OPS235_Lab_6_-_CentOS7#Part_2:_Configuring_VM_Network_Setup_Graphically_.28system-config-network.29 Refer to Lab6, Investigation1, Part2]).<br><br>Note: if you are configuring via command line, make certain to restart the network for centos2.# Save your changes Logout and restart the your '''NetworkManagercentos2''' serviceVM.# Observe the messages that get loggedfrom the tail -f command as your centos2 VM starts. You should see output similar to the following:<br><br>
::<span style="font-family:courier;">Mar 24 13:28:24 centos3 dhcpd: DHCPDISCOVER from 52:54:00:61:00:e7 via eth2</span>
::<span style="font-family:courier;">Mar 24 13:28:25 centos3 dhcpd: DHCPOFFER on 192.168.235.51 to 52:54:00:61:00:e7 via eth2</span>
<ol>
<li value="6">On '''centos2''', confirm the IP address assignment using <b><code><span style="color:#3366CC;font-size:1.2em;">ifconfig</span></code></b></li>
<li>Has the IP Address changed? If so, how has the IP Address been assigned according to the '''dhcpd.conf''' file settings?</li>
</ol>
# Remain in your '''centos2''' and '''centos3''' VMs for this section.
# If your '''centos3''' DHCP server successfully issued the proper IP address configuration values to '''centos2''', check the file called :<br>'''/var/lib/dhcpd/dhcpd.leases''' in your <u>'''centos3''' VM</u>.# You should see the similar contents similar to:<br><br>
::<span style="font-family:courier;"> lease 192.168.235.51 {</span>
::<span style="font-family:courier;"> &nbsp; starts 3 20105 2015/0307/24 10 17:2857:2534;</span>::<span style="font-family:courier;"> &nbsp; ends 3 20105 2015/0307/24 10 18:17:48:2534;</span>::<span style="font-family:courier;"> &nbsp; cltt 3 20105 2015/0307/24 10 17:2857:2534;</span>::<span style="font-family:courier;"> &nbsp; binding state active;</span>::<span style="font-family:courier;"> &nbsp; next binding state free;</span>::<span style="font-family:courier;"> &nbsp rewind binding state free;</span>::<span style="font-family:courier; "> hardware ethernet 52:54:00:610e:007d:e7a4;</span>::<span style="font-family:courier;">} client-hostname "centos2";</span>::<brspan style="font-family:courier;">}<br/span><ol><li value="43">On the client '''centos2''' check the contents of the <codeb>/var/lib/dhclient</codeb> directory. The files in this directory is where the dhclient stores its record of leases.<br><br> '''NOTE:''' If there are no files, then in a shell as root in your centos2 VM issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">dhclient eth0</span></code></b><br>Then check to see if there is file containing lease information in that directory.<br><br></li>
</ol>
# Make certain that you are located in your '''centos3''' virtual machine.
# Create a host declaration for '''centos2'''. Make sure you record the correct <code>hardware ethernet</code> setting that corresponds to the MAC address of the interface in '''centos2'''.
# Give it the fixed-address '''192.168.235.1242'''<br><br>'''Note:''' When supplying fixed-address it is important that the address assigned is exclusive of any ranges that have been declared. Otherwise it may be possible for 2 different hosts to receive the same address.<br><br><ol><li value="45">Start your service and test the address assignment by releasing your current address on '''centos2''' and then requesting a new address. Use the following commands on '''centos2''':</li>
</ol>
::: <b><code><span style="color:#3366CC;font-size:1.2em;">ifdown eth1</span></code></b>
::: <b><code><span style="color:#3366CC;font-size:1.2em;">ifup eth1</span></code></b>
<ol><li value="46">Confirm that you received the fixed address you were supposed to.</li>
</ol>
 
'''Answer Part 2 observations / questions in your lab log book.'''
'''Arrange proof of the following on the screen:'''
<ol><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos2''' VM:<blockquote><ul><li>'''ifconfig eth0''' shows IP address '''192.168.235.42'''</li><li>DHCP client lease file</li></ul></blockquote><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos3''' VM:<blockquote><ul><li>DHCP server log file showing a lease occuring</li><li>DHCP server configuration file showing subnet and host declaration</li><li>DHCP server lease file</li></ul></blockquote></li><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''Lab8''' log-book filled out.</li></ol> 
= Preparing for = Practice For Quizzes , Tests, Midterm &amp; Final Exam ==
# What protocol and port does dhcp use?