Open main menu

CDOT Wiki β

Changes

OPS235 Lab 6 - CentOS7 - SSD

20 bytes removed, 02:52, 12 June 2016
no edit summary
In this lab, you will learn the basics of networking by using your '''Virtual Machines''' and your '''centos1c7host''' machine. You will first set up a virtual private network among those machines. In addition, you will learn to set up '''network names''' (to associate with server's IP Addresses), '''associate network services with port numbers''' for troubleshooting purposes, and setup '''firewall policies''' via the '''iptables''' command.
<u>Main Objectives</u>
# Configure a private (virtual) network for your '''VMs''' and your '''centos1c7host''' machine
# Configure network interfaces for your Virtual Machines using both '''graphical''' and '''command-line''' utilities.
# Use '''local hostname resolution''' to resolve simple server names with their corresponding IP Addresses
=INVESTIGATION 1: CONFIGURING A VIRTUAL PRIVATE NETWORK=
For the remainder of this course, we will focus on networking involving our VMs and our centos1 c7host machine. This lab will focus on setting up a virtual private network ('''VPN'''), connecting our VMs and centos1 c7host machine to the VPN, and configuring our VPN to make more convenient to use, troubleshoot and protect. '''Lab 7''' will focus more on configuring SSH and making access to the VPN more secure. Finally, '''lab 8''' will focus on configuring the network for fixed workstations, mobile devices, or both at the same time.
There are several reasons for creating '''VPNs'''. The main reason is to '''safely connect servers together''' (i.e. to safely limit but allow share information among computer network users). This allows for a secure connection of computers yet controlling access to and monitoring (protecting) access to permitted users (discussed in more depth in lab7).
==Part 1: Configuring a Private Network (Via Virtual Machine Manager) ==
[[Image:network-config-centos.png|thumb|600px|right|This diagram shows the current network configuration of your '''centos1c7host''' machine in relation to your '''Virtual Machines'''. In this section, you will be learning to change the default network settings for both your '''centos1c7host''' machine and '''VMs''' to belong to a '''virtual network''' using fixed IP Addresses. ]]
If we are going to setup a private network, we must do 2 major operations: First, '''define a new private network in the Virtual Manager application'''; and second, '''configure each of our VMs to connect to this new private network'''. In Part 1, we will be perform the first operation. In parts 2, 3, and 4, we will be performing the second operation for all VMS (graphical and command-line).
# Perform this section in your '''centos1c7host''' machine.<br><br>'''NOTE:''' Before configuring our network we want to '''turn off dynamic network configuration for our Virtual Machines''' by turning off the '''"default"''' virtual network. We will then define our virtual private network. Follow the steps in order to perform these operations. <br><br>
# Make certain that <u>'''ALL'''</u> virtual machines are powered off.
# In the Virtual Machine Manager dialog box, Select '''Edit'''-> '''Connection Details'''.
# In the '''centos1 c7host Connection Details''' dialog box, select the '''Virtual Networks''' tab
# Disable the default configuration from starting at boot by '''<u>deselecting</u>''' '''Autostart (on boot)''' check-box and click the '''Apply''' button.
# Then Stop the default network configuration by clicking on the '''stop''' button at the bottom left-side of the dialog box.
[[Image:new_network_dialog.png|right|thumb|250px|Although the private network has been setup via the '''Virtual Machine Manager''', each virtual machine requires to change its own network setting individually (either '''graphically''' or by '''command line''').]]
# On your '''centos1c7host''' machine, run <b>ifconfig</b> and make note of the IP address assigned to the '''virbr1''' (i.e. "Virtual Bridge) interface. This will be the default gateway and DNS server for your VMs.
# Start your '''centos2''' VM and login.
# Within your centos2 VM, click '''Applications''' menu, then select '''System Tools''', and then '''Settings'''.
# When finished, check your settings, and then click the '''Apply''' button.
# Open a terminal and issue the '''ifconfig''' command to confirm the IP ADDRESS settings change.
# Verify that '''centos2'''VM is now connected to the VPN by issuing the following command from your '''centos1c7host''' machine:<br><b><code><span style="color:#3366CC;font-size:1.2em;">ping 192.168.235.11</span></code></b>
'''Answer Part 2 observations / questions in your lab log book.'''
# Save and exit the network configuration tool.
# You may have to restart the network using the correct command.
# Verify the configuration by pinging the VMs and centos1 c7host using their IP addresses.
# We will now create an '''Incremental Backup'''. Run the following Linux command as root:
#: <b><code><span style="color:#3366CC;font-size:1.2em;">find /etc -newer /tmp/timestamp &gt; /root/netcfg.lst</span></code></b>
#: <b><code><span style="color:#3366CC;font-size:1.2em;">ifconfig</span></code></b>
#:<b><code><span style="color:#3366CC;font-size:1.2em;">route -n</span></code></b>
#: <b><code><span style="color:#3366CC;font-size:1.2em;">ping</span></code></b> (your other VM's and centos1c7host)
#: <b><code><span style="color:#3366CC;font-size:1.2em;">ssh</span></code></b> ( to your Seneca's Matrix account to test your DNS)
# Restart the <code>centos4</code> VM, or just wait a few minutes.
# Login and test your configuration again. What happened?
# While we can configure network settings from the command line those settings are not persistent. To configure persistent network configurations we need to edit the configuration files.
# Change to the '''/etc/sysconfig/network-scripts''' directory<br>[[Image:new-network-config.png|thumb|300px|right|This diagram should show the newer network configuration of your '''centos1c7host''' machine in relation to your '''Virtual Machines'''.]]
# List the contents of this directory. You should see 2 different types of files, network config scripts and network configuration files.
# Look for the configuration file for your original interface, it should be named '''ifcfg-eth0'''
After setting up a private network, it can be hard to try to remember IP addresses. In this section, we will setup your network to associate easy-to-remember server names with IP ADDRESSES.
# Complete this investigation on '''all of your VMs''' and the '''centos1c7host''' machine.# Use the <b><code><span style="color:#3366CC;font-size:1.2em;">hostname</span></code></b> and <b><code><span style="color:#3366CC;font-size:1.2em;">ifconfig</span></code></b> commands on your centos1 c7host machine and all of your 3 VM's to gather the information needed to configure the '''/etc/hosts''' file on all of your Linux systems.
# Edit the '''/etc/hosts''' file on <u>each</u> of the '''virtual machines and host machine'''. Add the following contents to the <u>bottom</u> of the '''/etc/hosts''' file:<br><br>
#::192.168.235.1 centos1c7host
#::192.168.235.11 centos2
#::192.168.235.12 centos3
When our CentOS system provides any services on a network, those services are accessible through a port number. All network services are configured to be accessed on a particular port number. By examining which ports are active on our system we can know what services (and points of attack) are available on our system. The ability to examine this information is important for troubleshooting network services and securing our systems. One great tool for this is the '''netstat''' command.
# Perform this section on your '''centos1c7host''' machine.
# On the centos host '''ping''' each of your VM's
# Examine the contents of the ARP cache by using the command: <b><code><span style="color:#3366CC;font-size:1.2em;">arp</span></code></b>
# For the remainder of this section, use your '''centos1c7host''' machine.
# As root on the CentOS host enter the following commands at the prompt:
#: <b><code><span style="color:#3366CC;font-size:1.2em;">iptables -L</span></code></b>
<li>This entry in the OUTPUT policy will therefore log all packets being sent out of the machine.</li>
<li>Try to access the Internet again. Because the policies have been set to DROP, you should be unsuccessful. However, every packet of data that your PC attempted to send out was logged. Let's have a look at the log file and analyze the data:<br><b><code><span style="color:#3366CC;font-size:1.2em;">tail /var/log/messages</span></code></b></li>
<li>This command shows us the last 10 lines of the file. While there are many things being logged to this file, the last thing we did was try to access the Internet so we should be able to see the data we need. Look for a line that looks similar to the following:<br /><blockquote><code>Jun 24 12:41:26 centos1 c7host kernel: IN= OUT=lo SRC=127.0.0.1 DST=127.0.0.1 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=16442 DF PROTO=TCP SPT=57151 DPT=5902 WINDOW=1024 RES=0x00 ACK URGP=0</code></blockquote></li>
<li>Your IP, host names and date will be different, but the one thing that should be the same is the DPT=80 value.</li>
<li>When your computer tried to send OUT a request to connect to the Internet using the WWW, the computer used a destination port of 80. This is the standard port for the WWW. Because we have set the default policy to DROP it drops these packets. The problem is we are dropping all packets. What if we just want to drop the WWW packets?</li>
# Give the '''lab6-check.bash''' file execute permissions (for the file owner).
# Run the shell script and if 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> '''centos3''' VM:<blockquote><ul><li>Contents of '''/tmp/lab6''' directory.</li><li>'''ssh''' from centos3 to the CentOS host</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''<u>All</u> VMs''':<blockquote><ul><li>'''ifconfig''' information</li><li>Contents of '''/etc/hosts''' file</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span>'''centos1c7host''' machine<blockquote><ul><li>'''arp''' cache information</li><li>Contents of '''/etc/hosts''' file</li><li>Proof of backup</li><li>A list of your '''iptables''' rules</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''Lab6''' log-book filled out.
= Practice For Quizzes, Tests, Midterm &amp; Final Exam =
13,420
edits