CTS 2333 (Unix/Linux Networking) Project #3
Static IP and Hostname Configuration

 

Due: by the start of class on the date shown on the syllabus

Description:

Each student has been assigned two hosts, one server and one client host.  In this project you will learn how to configure one of your hosts (we'll call it the server host, and your other system the client host) with static IP addresses, hostnames, and other networking parameters.  This setup will be used for the rest of the course.

Make sure you keep an accurate system journal of any and all changes you make to your system!  You will need to turn this in, along with the answers to the questions asked below.

For your static IP address to actually work you must set other network parameters, including a default gateway.  Other steps include setting a hostname and configuring the resolver (DNS libraries) with the IP address of your nameserver and your default domain name.  Until we build a new nameserver you will need to update your /etc/hosts file with the names and IP addresses of all the hosts used in our classroom.  You can create this file from the information found at the Networking class wiki site, the Networking Class Host Name List.

The hostname you picked at the begining of the term should be assigned to your server We won't be configuring your client host in this project, so it should continue to use DHCP as before.

Since version 11, Fedora doesn't enable the network service by default.  Instead the NetworkManager service is enabled.  This service doesn't support static IP configuration through Fedora 15 (even though it says it does; see bugzilla.redhat.com/show_bug.cgi?id=698199).

Before beginning this project you must disable NetworkManager and enable instead network.  Once you do this, you may (or may not) need to configure the network service for DHCP before networking will operate correctly.  You can use any GUI or other method to do this.

For Fedora 15, you use systemctl disable NetworkManager.service, then enable the older service with systemctl enable network.service.  You may need to install system-config-network with yum.  In addition, you can (and probably should) add NM_CONTROLLED=no to your ifcfg-<name-of-interface> file.

If you need help with this step, ask your instructor.

Directions:

Answer the following questions and perform the following tasks.  (For the answers to Solaris questions consult the man pages and the Solaris on-line documentation.)

Part I — Creating a Static IP Setup

  1. From the command line (and without modifying any files) configure the NIC on your server with the static IP address assigned to you in class.  This step requires the use of the ifconfig command, or the ip addr add address/prefix-length dev interface  command.  Here's an example using the new Linux ip command:
    # ip addr add 10.20.30.40/24 dev eth0
    

    (Of course you use the correct address, prefix length, and device, which may not be eth0.)  Once set, verify your NIC has the correct address.  What command do you use to verify the address assigned to a NIC?

    Make sure to keep track of all IP address assignments!  This is typically a separate document from any one system's journal.  This document should be kept current and include a last revised date.  However, with only two hosts to keep track of, you can just record the IPM address assignments in your system journal.  (Consider putting that information in a table near the begining of the journal, say near the partition map.)

  2. From the command line update your default route (or gateway).  This will be the same as your current gateway address as assigned by DHCPWhat is your current (working) gateway (default route) IP address?  You must set your default route to the IP address of the HCC-gateway host as shown in the table below.  This step is done using the route command or the new Linux ip command:
    # ip route add 0/0 via address
    

    (Of course you should use the correct gateway address.)  Once set, verify your system's routing table (make sure the default route shows and is correct).  What command do you use to verify the default route?

    When checking the routing table, you make notice a long delay when displaying the default route.  This may happen when the network gateway doesn't have a DNS entry, and your system by default attempts to lookup the name for the gateway's IP address.  What is the option for the command to display the routing table, to cause it not to lookup DNS names?  (One way to fix this, is to add a name for the gateway IP address in the DNS system, or in /etc/hosts.  I often add a name such as HCC-gateway for this.)

  3. From the command line assign your host a new hostname, using the hostname command.  To set the domain name in Red Hat compatible Linuxes you must make sure your name service can lookup the fully qualified domain name or FQDN from the hostname.  For the default setup this means you must add an entry to /etc/hosts that contains the static IP address of your host, its FQDN, and its hostname.

    The domain name for our class is "kaos.coop".  (Check here for information about KAOS.coop.)  For a hostname of siegfried and an IP address of 172.16.0.10 the /etc/hosts entry should be:

        172.16.0.10  siegfried.kaos.coop  siegfried
    

    What was the exact command line you used to set your system's hostname?

  4. Test your static IP setup.  Try the command traceroute 169.139.223.139.  This should show several hops, the first of which should be the class gateway.  If you don't get the expected output verify your IP address and default route again.  If necessary you can start over by restarting networking (use "/etc/rc.d/init.d/network restart").  This will reactivate your DHCP configuration.

Part II — Making the Static IP Setup Permanent

Once your static IP and routing configuration is working it is time to make the changes permanent.  This requires you to modify files on your host (besides the /etc/hosts file, which you've already modified).  Perform the following steps:

  1. Configure your resolver library.  This is the name to IP-address lookup service.  To avoid any DNS lookup problems, update your /etc/hosts file with entries for the gateway router and for the other student servers (and the instructor's host as well).  Don't forget to keep the entry for your own host added earlier.  Remember all entries (but at least your own) should contain both the hostname and the FQDN.
    1. Update your /etc/hosts file with the information from the class wiki site's Networking Class Host Name List.
    2. Configure the resolver to use the hosts file before trying DNS.  (You system is likely already setup this way.)  Examine and update if necessary /etc/nsswitch.conf (the hosts entry).  What changes did you need to make?  What is the output of the command grep hosts /etc/nsswitch.conf?
    3. Now that the resolver is set to use DNS, you must update the /etc/resolv.conf file to include the correct default domain name(s) and DNS (nameserver) IP address(es).  This file was managed and routinely over-writen by DHCP (and PPP), but now you must edit it manually.  What is the current contents of the /etc/resolv.conf file (as created by DHCP)?
    4. The default domain name to use for our class is kaos.coop.  The nameserver IP address to use is 10.142.2.6.  Optionally you can specify a second default domain name of hccfl.edu, to allow commands such as "ssh ua00@yborstudent" to work.  It is possible you may need to set some options, for example you may find it necessary to change the default DNS timeout from 5 seconds to a larger value.  See the resolv.conf man page for more information.

      The resolve.conf file might look like this:

      /etc/resolv.conf

          search kaos.coop hccfl.edu
          nameserver 10.142.2.6
      

      Notes:
      The DHCP version of resolv.conf is probably correct.  Use the DNS (nameserver) IP addresses you see there when making your own version of this file.
      When DHCP modifies the /etc/resolv.conf file, it first makes a copy of this file.  When the interface is brought down, the old resolv.conf file is restored.  So, after your next reboot any changes to this file may be lost!  This is a one-time thing; once you set your interface to static IP, the DHCP client won't over-write resolv.conf again.  Make a copy of your correct resolv.conf file, so you can easily restore it later (if needed).

    5. Test your resolver setup.  Try using the ping command to ping hosts by name.  What is the results of each of the following commands?:
      ping -v wpserver
      ping -v wpserver.kaos.coop
      ping -v your-hostname
      ping -v your-hostname.kaos.coop
      ping -v www
      ping -v www.hccfl.edu
      
    6. How many domains can be listed on the search directive in the resolv.conf file?  How did you find this out?
  2. At this point the resolver, routing, and your IP address are are set up and tested for a static configuration.  However if you restart networking (or reboot), all your work will be lost.  You must now make your changes permanent by updating the various configuration files.  These differ by system; here we will configure your Fedora system, using the network service (and not the newer but buggy NetworkManager service).  What is the configuration file's absolute pathname that holds the network configuration for your NIC (e.g., eth0)?

    The descriptions of the various configuration files you need to edit are found in the file:
    /usr/share/doc/initscripts*/sysconfig.txt

  3. Turn off DHCP and set for static configuration.  Edit the NIC's configuration file and change the boot protocol from dhpc to noneWhat is the exact entry you modified for this?
  4. Next add an entry for the IP address and netmask to use for this NICWhat are the exact two lines you modified (or added) for this?
  5. Configure your default gateway.  Edit the file /etc/sysconfig/network and add (or change) an entry for the following:
    GATEWAY=address  #IP address of gateway
    

    In Red Hat compatible Linuxes since version 7.2, the default gateway can be set in a manner similar to that used on Solaris, by creating the file /etc/default-route.  This file should just contain the IP address of your gateway.  What file should contain your gateway IP address on Solaris?

  6. Configure your hostname. 

    The whole concept of a hostname is confusing!  Before DNS or even Ethernet, a computer could be given a name, sometimes called the hostname or the nodename.  With DNS and NICs, a name is associated with each IP address assigned to each NIC on some computer.  This too is called the hostname.  So what is "the" hostname on a host with multiple IP addresses?  It is not well defined but is usually configured by the administrator to be one of the DNS hostnames.  Some systems will set the hostname by a reverse DNS lookup on the first NIC found with an IP address assigned (the first or last address).

    For Red Hat compatible Linux systems you should edit the file /etc/sysconfig/network and add (or change) an entry for HOSTNAME=YourHostname.  This should NOT be the FQDN name.  The hostname and FQDN should still be set in the /etc/hosts file.

    What file(s) on Solaris are updated to contain the host's hostname and domain name?

  7. What are the new contents of the files you changed in the previous four steps?

At this point your system is now configured with a static IP address, and the change will persist even if you restart networking or reboot.  However there are additional configuration steps you may wish to do:

  1. Update the greetings files with the hostname.  The file /etc/issue and /etc/issue.net contain system identification information that is displayed before a login prompt.  The default value contains information that is more useful to hackers than legitimate users.  You should update these files to contain a greeting which contains your system's hostname and no other information.  Another greeting file is used with the anonymous FTP server.  On Red Hat compatible Linuxes since 7.2, the default file is /var/ftp/welcome.msg.  This file too should only contain the hostname, something like "Welcome to the hostname Anonymous FTP Server!".
  2. Some other related files should be created or updated.  /etc/motd is displayed to users just after a successful login and often contains an acceptable use policy (AUP) statement.

    The file /etc/networks allows you to assign names for IP network numbers.  This file is optional but if present will allow you to use the names in commands such as route and ifconfig.  A sample networks file might look like this:

    /etc/networks

       kaos-net   172.22.25.0
       hcc-net    10.41.0.0
       loopback   127.0.0.0
    
  3. Suppose one day your DNS stops working.  This is likely because the network administrator has updated the nameserver IP addresses to use.  No doubt if you were running DHCP you would automatically get the new DNS IP addresses.  How can you determine the new networking parameters (such as the DNS server IP address(es) to use)?  List two different ways.

Test your static IP setup by restarting networking.  Use the command "/etc/rc.d/init.d/network restart" and verify everything is correctly configured by using the hostname, ifconfig, route, traceroute, and ping commands as before.

If things are not working, carefully check all the steps you did by comparing the system journal with these directions.  Also make sure the classroom is plugged into the campus network.  If you are unable to get things to work, you can attempt to use a GUI network setup tool.  You can also run the dhclient command to temporarily restore the DHCP configuration.

To be turned in:

You can send as email to (preferred).  If email is a problem for some reason, you may turn in a hard-copy.  In this case the pages should be readable, dated, and stapled together.  Your name should appear on the first page. 

Don't turn in your whole journal, you will need to add to it every day in class!  It is common in fact to keep the journal as a text file on the system (with a paper backup of course).

Please see your syllabus for more information about submitting projects.