Open main menu

CDOT Wiki β

Changes

OPS245 Lab 6

1,652 bytes added, 9 March
no edit summary
{{Admon/caution|DO NOT USE THIS VERSION OF THE COURSE. This page will no longer be updated.|'''Debian version here:''' https://seneca-ictoer.github.io/OPS245
<br>'''CentOS version here:''' https://seneca-ictoer.github.io/OPS245-C7<br>'''Andrew's version here:''' http://wiki.littlesvr.ca/wiki/OPS245_Lab_6}}
=LAB PREPARATION=
[[Image:my-network.png|thumb|right|350px|Setting up networks is an essential operation for a system administrator. Maintaining network connectivity and securing the network are also essential operations. In this lab, we will '''configure a private virtual network using static IP addresses''' (eg. wired workstation connections). We will learn how to setup a DHCP network (eg. for notebook, table and smartphones) in lab 8.]]
# Use '''local hostname resolution''' to resolve simple server names with their corresponding IP Addresses
# Use common networking utilities to associate network services with port numbers for troubleshooting purposes
<!-- # Use '''shell scripts with arrays''' to store network configuration data-->
# Proceed with changes, and click '''Finish'''.
<ol>
<li value="1314">We will now reconfigure each of our VMs to use our new virtual network '''network1'''
<ol type="a">
<li value="1">Let's start with our '''centos1 VM'''. Double-click on your '''centos1''' VM, but instead of running the VM, click on the '''view''' menu, and select: '''Details'''<br />(Note: the Virtual Machine window will appear - do not start virtual machine)</li>
#: IP Address: '''192.168.245.11'''
#: Subnet Mask: '''255.255.255.0'''
#: Default Gateway: The IP address of '''virbr1''' on your centos host(c7host).
# Click on the '''DNS''' field and add The IP address (''virbr1''' on your centos host) as the primary DNS server.
# When finished, check your settings, and then click the '''Apply''' button.
[[Image:network-scripts.png|thumb|right|250px|Although you can use the '''ifconfig''' command to temporarily create a static IP address connection to a network, you need to add the network settings in the '''/etc/sysconfig/network-scripts''' directory to automatically connect to the network upon Linux system boot-up.]]
=== Part 3: Configuring VM Network Setup via Command Line ('''centos3centos2''' and '''centos2centos3''') ===
The centos2 and centos3 and centos2 VMs are '''text-based only''' systems, thus we cannot use a graphical tool to configure centos3 to connect to our private network. Therefore we will learn how to perform this task by using command-line tools.
:'''Perform the following steps:'''
#::DEVICE=eth0
#::IPADDR=192.168.245.13
#::NETMASKPREFIX=255.255.255.024
#::GATEWAY=192.168.245.1
#::HWADDR=xx:xx:xx:xx:xx:xx <-- '''# Use YOUR centos3 VM's MAC ADDRESS!!!
<li>Configure the centos2 VM (in the '''View''' -> '''Details''' menu of Virtual Machine Manager) to configure the NIC interface to '''network1''', click '''Apply''', and switch your centos2 VM view from details to '''console'''.</li>
<li>Start your '''centos2''' VM, login, and issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">ip address show</span></code></b> and write down the '''MAC address''' for your eth0 network interface.</li>
<li>Edit the '''/etc/sysconfig/network-scripts/ifcfg-eth0''' file using the IPADDR: '''192.168.245.12''' , and the same '''NETMASKPREFIX''', '''GATEWAY''', '''DNS1''' and '''MAC address''' information for you centos2 VM (i.e. recorded previously).</li>
<li>Save changes, re-issue the '''ifdown''' and '''ifup''' commands, and then issue the '''ip address''' and '''ping''' commands to verify that you can connect to other VMs on your network.</li>
</ol>
<!-- ===Part 3: Using Arrays to Collect VM Network Information===
{|width="40%" align="right" cellpadding="10"
|- valign="top"
+<br>
<br>
sudo -u $SUDO_USER /bin/firefox /tmp/network-info.$$.html<br>
<br>
</code>
<br><br>
<ol><li value="7">Give this shell script execute permissions and run this shell script.</li><li>Run the shell script. What do you notice from the report that the shell script generated?</li><li>Then use wget command to download another variation of the network-info.bash shell script using the awk command to separate the variables and values into separate columns:<br><b><code><span style="color:#3366CC;font-size:1.2em;">https://ict.senecacollege.ca/~ops235peter.callaghan/ops245/labs/network-info-2.bash</span></code></b><br></li></ol>
-->
'''Answer INVESTIGATION 2 observations / questions in your lab log book.'''
 
=INVESTIGATION 3: USING PYTHON TO MODIFY FILES=
 
In this investigation you will write a python script that will allow a user to interactively configure a network interface's configuration file. Before beginning, '''make a backup of your ifcfg files'''. '''Store the python script in ~/bin/''' on c7host.
Write a script called '''netconfig.py''' that will prompt the user for the following values, and write their answers into an ifcfg file stored in the '''Answer INVESTIGATION 2 observations / questions in your lab log book.etc/sysconfig/network-scripts'''directory. #The name of the interface#The interface's MAC address#Whether the interface should automatically turn on when the machine boots.#Whether the interface should get a static or DHCP address::Note: Only prompt the user for the following values if they chose a static address.::*The static ip address::*The network prefix::*The default gateway::*The primary DNS server Note that your script should make use of loops and try-except statements to make sure the user provided semi-reasonable data. You are not expected to create the regular expressions necessary to confirm the format of the IP address, but should be able handle simpler issues like forcing the user to give the interface a name (since you will need it for the filename), determining if it will start automatically, and the address type. Remember to test your script to make sure it works.
= LAB 6 SIGN-OFF (SHOW INSTRUCTOR) =
# Switch to your '''c7host''' VM.
# Change to your user's '''bin''' directory.
# Issue the Linux command: <b><code><span style="color:#3366CC;font-size:1.2em;">wget https://ictraw.senecacollegegithubusercontent.cacom/~peter.callaghanOPS245/ops245labs/labsmain/lab6-check.bash</span></code></b>
# Give the '''lab6-check.bash''' file execute permissions (for the file owner).
# Run the shell script and if there are any warnings, make fixes and re-run shell script until you receive "congratulations" message.
#Arrange proof of the following on the screen:<br><blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos2''' VM:<blockquote><ul><li>'''ssh''' from '''centos2''' to '''c7host''' VM.</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span>'''c7host''' machine<blockquote><ul><li>Output from running the '''network-info.bash''' shell script</li><li>Run the '''lab6-check.bash''' script in front of your instructor (must have all <b><code><span style="color:#66cc00;border:thin solid black;font-size:1.2em;">&nbsp;OK&nbsp;</span></code></b> messages)</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''Lab6''' log-book filled out.#Upload a screen of the proof from the previous step, along with the file generated by '''lab6-check.bash''', your log book, and your network-info'''netconfig.bash py''' script to blackboard.
= Practice For Quizzes, Tests, Midterm &amp; Final Exam =
# What is a port?
# What command will set your IP configuration to 192.168.55.22/255.255.255.0 24 ?
# What is the difference between UDP and TCP?
# What port number is used for DHCP servers?