NAD710 Lab 4

From CDOT Wiki
Jump to: navigation, search

NAD710 - Introduction to Networks - Using Linux

Objective

  • Use the system-config-network (GUI program) tool to perform network configuration to:
    • Set static IP addresses
    • Set static Network Routes
    • Modify Network device name
    • Set DNS servers and search path
    • Specify static computer hostname to IP address mappings
  • Investigate and identify files being used by those GUI system configuration tools for storing the configuration values. The following shell commands could be very helpful for this purpose:
    • find
    • xargs
    • tar

Background Information

To perform network configuration on Fedora Core, your have a few choices:

  • Use command line tools: ifconfig, route or ip - any changes will not survive a reboot
  • Use the system-config-network, a GUI program - any changes have to be written to onre or more file in the /etc directory
  • Use the NetworkManger to perform automatic network configuration - this is mainly for mobile users with laptops

This lab goes through the process of using the system-config-network tool in performing network configuration and gives you some hints on how to locate the files that are being used by the program to store the configuration parameters.

Procedure

Preparation before launching the GUI system configuration tools

  • Create a dummy file to be used as the time reference. Files modified by the GUI system configuration program that we are going to run will have a file modification time newer than this dummy file.
   [root@fc9 nad710-lab4]# pwd
   /root/nad710-lab4
   [root@fc9 nad710-lab4]# date > timestamp
   [root@fc9 nad710-lab4]# ls -l
   total 2
   -rw-rw-r-- 1 root  root    29 2008-09-24 17:36 timestamp
   
  • Run the find command to confirm that all files and directories in the /etc directory and all its subdirectories are older than the timestamp we just created:
   [root@fc9 nad710-lab4]# find /etc -newer timestamp
   [root@fc9 nad710-lab4]#

You are ready to go if the find command produces no output as shown above.

Launch the GUI network system configuration program

From the menu bar

Click System -> Administration -> Network to launch. You will be asked to supply the root password to continue.

From a terminal window

At the command prompt, type "system-config-network" and press enter. You will be asked to supply the root password to continue.

View the Query Dialogue Box

The Network Configuration Window

The Network Configuration Window contains the following 4 tags:

The Devices tag is displayed by default. You can select or de-select each device.

The Device Tag on the Configuration Window

Highlight the network device and click the edit button to bring up the Ethernet Device Window.

The Ethernet Device Window

This window contains the following 3 tags:

The Hardware Tag on the configuration Window

The Hardware tag displays the network hardware device automatically detected by the system. Just verify that the information shown there are correct. No editing would be necessary,

The DNS Tag on the Configuration Window

The DNS tag is where you can verify or modify your "Hostname". There are four other configuration items;

  • Primary DNS
  • Secondary DNS
  • Tertiary DNS
  • DNS search path

Fill in the appropriate values for these four items. These could be the values of your local DNS server or even just sample values (e.g., 1.2.3.4) so that you know what to look for when you examine the altered files.

The Hosts Tag on the Configuration Window

The Hosts tag allow you to specify static computer hostname to IP address mapping. Click the "New" button to add new entries. If you have classmate doing the lab with you, you can enter his/her hostname and IP address here and you can ping his/her system by hostname instead of IP address after the configuration is done.

Save the changes and exit from the Network Configuration Window

Click the "File" item on the Manu bar and select "Quit" and "Save the changes".

If this is the first time you assign IP addresses to the network device, you should also activate the network device. If you are working in the lab (T2107), the network device may be already configured to automatically obtain IP address settings with dhcp. If this is the case, you must deactivate the device first, switch to manual configuration, and then activate it again for the new settings to take effect.

Where are those configuration values go?

Let's assume that all the files used to store the network configuration parameters are in the /etc directory or its subdirectories. First, we need to know what files under the /etc directory had been changed after running the network system configuration program.

What files had been changed?

We can use the following "find" command to find out all the files that had been changed after running the configuration program:

   [root@fc9 nad710-lab4]# find /etc -newer timestamp
   /etc/ppp/chap-secrets
   /etc/ppp/pap-secrets
   /etc/resolv.conf
   /etc/hosts
   /etc/wvdial.conf
   /etc/sysconfig/network-scripts/ifcfg-eth0
   /etc/sysconfig/network
   /etc/sysconfig/networking/devices/ifcfg-eth0
   /etc/sysconfig/networking/profiles/default/resolv.conf
   /etc/sysconfig/networking/profiles/default/ifcfg-eth0
   /etc/sysconfig/networking/profiles/default/network
   /etc/sysconfig/networking/profiles/default/hosts

Notice that a couple of files have the same file name but in different directories?

Copy all the files found to a safe place

It would be better to copy all the files that were found by the find command to a safer place (may be in the /tmp directory or your working directory) before poking around those files.

Notice that a couple of files have the same file name but in different directories?

We can not copy all these files to a single directory due to name collision, we must copy the directory structure as well. The tar command can do the magic. The following two steps should do the trick:

  Step 1
  [root@fc9 nad710-lab4]# find /etc -newer timestamp -exec tar cvf lab4-files.tar {} +;
  tar: Removing leading `/' from member names
  /etc/modprobe.conf
  /etc/ppp/chap-secrets
  /etc/ppp/pap-secrets
  /etc/resolv.conf
  /etc/hosts
  /etc/wvdial.conf
  /etc/sysconfig/network-scripts/ifcfg-eth0
  /etc/sysconfig/network
  tar: Removing leading `/' from hard link targets
  /etc/sysconfig/networking/devices/ifcfg-eth0
  /etc/sysconfig/networking/profiles/default/resolv.conf
  /etc/sysconfig/networking/profiles/default/ifcfg-eth0
  /etc/sysconfig/networking/profiles/default/network
  /etc/sysconfig/networking/profiles/default/hosts

The following pipe line command will also produce a tar ball file with the same contents:

  [root@fc9 nad710-lab4]# find /etc -newer timestamp | xargs tar cvf lab4-files.tar


Notice the message about "Removing leading / from member names"? The names of the files found by the find command are listed using absolute path. The tar ball file created by the tar command remove the leading "/" so that the member files can be retrieved and put into any directory. Before we actually retrieve the files from the tar ball file, run the following command to view and verify the contents of the tar ball:

  Step 1.5 
  [root@rh9 nad710-lab4]# tar tvf lab4-files.tar 
  -rw-r--r-- root/root         0 2008-09-24 20:26 etc/modprobe.conf
  -rw------- root/root       232 2008-09-24 20:26 etc/ppp/chap-secrets
  -rw------- root/root       231 2008-09-24 20:26 etc/ppp/pap-secrets
  -rw-r--r-- root/root       138 2008-09-24 20:26 etc/resolv.conf
  -rw-r--r-- root/root       251 2008-09-24 20:26 etc/hosts
  -rw-r--r-- root/root         0 2008-09-24 20:26 etc/wvdial.conf
  -rw-r--r-- root/root       320 2008-09-24 20:26 etc/sysconfig/network-scripts/ifcfg-eth0
  -rw-r--r-- root/root        39 2008-09-24 20:26 etc/sysconfig/network
  hrw-r--r-- root/root         0 2008-09-24 20:26 etc/sysconfig/networking/devices/ifcfg-eth0 link to   etc/sysconfig/network-scripts/ifcfg-eth0
  hrw-r--r-- root/root         0 2008-09-24 20:26 etc/sysconfig/networking/profiles/default/resolv.conf link to etc/resolv.conf
  hrw-r--r-- root/root         0 2008-09-24 20:26 etc/sysconfig/networking/profiles/default/ifcfg-eth0 link to etc/sysconfig/network-scripts/ifcfg-eth0
  -rw-r--r-- root/root         0 2008-09-24 20:26 etc/sysconfig/networking/profiles/default/network
  hrw-r--r-- root/root         0 2008-09-24 20:26 etc/sysconfig/networking/profiles/default/hosts link to   etc/hosts

To retrieve all the files from the tar ball file to the current directory, run the following command:

  Step 2
  [root@rh9 nad710-lab4]# tar xvf lab4-files.tar 
  etc/modprobe.conf
  etc/ppp/chap-secrets
  etc/ppp/pap-secrets
  etc/resolv.conf
  etc/hosts
  etc/wvdial.conf
  etc/sysconfig/network-scripts/ifcfg-eth0
  etc/sysconfig/network
  etc/sysconfig/networking/devices/ifcfg-eth0
  etc/sysconfig/networking/profiles/default/resolv.conf
  etc/sysconfig/networking/profiles/default/ifcfg-eth0
  etc/sysconfig/networking/profiles/default/network
  etc/sysconfig/networking/profiles/default/hosts

Final Investigation

Now that all the files found by the find command are in the "etc" subdirectory of the current directory, go through each file and find out where are all the network configuration parameters that you modified via the system-config-network program.

Questions

  1. Which file stores the computer's host name?
  2. Which file stores the static IP addresses?
  3. Which file stores the static hostname to IP address mappings?
  4. Which file stores the DNS servers' IP addresses?
  5. What information is stored in the /etc/sysconfig/network file?
  6. Would you be able to construct a single pipe line command using "find", "xargs", and "tar" to copy all the files (with the same directory structure) found by the "find" command to the currect directory?
  7. Pick one of the following system configuration program and determine what files are being used to store the configure parameters:
    1. system-config-firewall
    2. system-config-printer
    3. system-config-users
    4. system-config-display
    5. system-config-services
  8. How can I get the lasts modified files in the system using find command ?

Completing this Lab

  • Post your answers for this lab to NAD710 Lab 4 Answers
  • You will be graded according to your contribution. If you have nothing to add to the answer page, please comment on the lab and/or the answers and email them to your professor.