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 you build a 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 and IP address you picked at the beginning of the term should be assigned to your server. We won't be configuring your client host (your second computer) in this project, so it should continue to use DHCP as before.
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.)
In this part, you will learn how to change hostnames, addresses, and routes. Since all networking parameters are stored in memory, any such changes will be lost after a reboot.
Before proceeding, make a copy of your current, working network setup:
IP address and mask (output of “ifconfig
”
or “ip addr
”), routing table (especially the
default route), and the contents of /etc/resolv.conf
,
/etc/hosts
, /etc/hostname
,
/etc/nsswitch.conf
, and your NIC's config file
/etc/sysconfig/network-scripts/ifcfg-nameOfNIC
.
As usual, before you modify any files you should FIRST make a copy.
You can then record the output of “diff
” to
show your changes.
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 # ip addr del your-current-IP-address dev eth0
(Of course, you use the correct address, prefix length, and device, which
may not be eth0
.)
Note you should add first, then delete.
If you delete first, the NIC has no IP address and the
default route may be deleted!
Once set, verify your NIC has the correct address. What command(s) can 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 IP address assignments in your system journal. (Consider putting that information in a table near the beginning of the journal, say near the partition map.)
route -n
” command, or the newer
“ip route
” command.
(While the newer Linux command does more and can show more, for this simple
use I prefer the output format of the older command.)
What is your current (working) gateway
(default route) IP address?
# ip route add default via 10.142.255.2 dev eth0 # ip route del default via 10.142.255.1 dev eth0
You now have no Internet access! Take a look at your routing table to see the change you made. However, you still have a route to the local network, so you can access other computers (and printers) in the room. Run some commands to verify networking only works locally. What commands did you run, and what were the results?
10.142.255.1
).
This step is done using the same commands as in the previous step.
Once set, verify your system's routing table (make sure
the default route shows and is correct).
What commands 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.)
hostname
command.
(Don't use the new Linux command hostnamectl
, as it will update
files with your changes unless you use the right options.)
Use the name you picked previously and documented in the class wiki.
Note: the domain name is “GCAW.ORG
”.
What was the exact command line you used to set your system's hostname?
/etc/resolv.conf
file.
This file is generated automatically when using DHCP.
What are the IP addresses of the
DNS servers used?
What is the default domain name?
Now examine the “hosts
” line from the file
/etc/nsswitch.conf
.
Explain in your own words what that line
means.
(Hint: Read the man page for that file.)
traceroute YborStudent.hccfl.edu
”.
This should show several hops, the first of which should be the
classroom gateway.
If you don't get the expected output, verify your IP
address, prefix (netmask), and default route again.
If necessary, you can start over by restarting networking
(use "systemctl restart NetworkManager.service
").
This should reactivate your DHCP configuration.
(Or you can simply reboot.)
At this point your hostname, routing, and your IP
address are all 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.
The files used vary by system; here we will configure your Fedora system,
using the NetworkManager
service installed by default.
Perform the following steps:
/etc/hostname
.
(The Linux command hostnamectl
will update that file automatically
if you use it.)
Contrary to Red Hat documentation, that file should not contain
a fully-qualified DNS name.
Rather it should contain the host name without the domain name (so no
periods).
With Red Hat-like systems, the name service looks up the fully
qualified domain name or
FQDN
from the hostname you specify, in the file /etc/hosts
.
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).
Next, you need to add some entries to the /etc/hosts
file.
The format of that file can be found in the man pages.
Do not change or remove the entries already present
(for localhost)!
The domain name for our class is “gcaw.org
”.
For a hostname of siegfried
and an IP
address of 172.16.0.10
the /etc/hosts
entry you need to add should look like this:
172.16.0.10 siegfried.gcaw.org siegfried
In addition to an entry for your own host, you need to add entries for
all the host names for the whole class, including your instructor's.
The IP addresses and host names can be found on the class
wiki site.
To avoid any DNS lookup problems, you can also add an entry
for the gateway router.
(As mentioned above, I generally use a name such as
“HCC-gateway
” for the router.)
What is the final contents of your updated
/etc/hosts
file?
What file(s) on Solaris are updated to contain the host's hostname and domain name?
/etc/hosts
file
before trying DNS.
(Your 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 (if any)?
What is the output of the command
“grep hosts /etc/nsswitch.conf
”?/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-written 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)?
gcaw.org
”.
Optionally you can specify a second search domain name of
hccfl.edu
, to allow commands such as
“ssh ua00@YborStudent
” to work.
The nameserver IP addresses to use are the same ones used
when set by DHCP.
It is possible you may want 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 gcaw.org hccfl.edu
nameserver 10.142.2.6 ⟵ not the real IP address!
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, updated
resolv.conf
file, so you can easily restore it later
(if needed).
ping
command to ping hosts by
name.
What is the results of each of the following
commands:
ping -vc 1 wpserver ping -vc 1 wpserver.gcaw.org ping -vc 1 your-hostname ping -vc 1 your-hostname.gcaw.org ping -vc 1 www ping -vc 1 www.hccfl.edu
search
directive in the resolv.conf
file?
How did you find this out?
/etc/hosts
file).
You must now make your changes permanent by updating the various
configuration files.
The files used vary by system; here we will configure your Fedora system,
using the NetworkManager
service installed by default.
Red Hat-based systems (including Fedora) have always used the same
files to configure each NIC.
The files are kept in the directory /etc/sysconfig/network-scripts
and are named for the NIC.
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
dhpc
to none
.
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?
/etc/resolv.conf
already, that file may
get over-written so you should enter those values here as well.)
What is the output of running diff
on your modified file?
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:
/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 (except
maybe a statement that unauthorized use prohibited).
/var/ftp/welcome.msg
.
This file too should only contain the hostname, something
like “Welcome to the hostname Anonymous FTP
Server!”.
/etc/motd
is a related file that is displayed to users just
after a successful login, and often contains an acceptable use policy
(AUP) statement.
All such files should display the correct name of your host.
/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:
gcaw-net 172.22.25.0 hcc-net 10.41.0.0 loopback 127.0.0.0
Test your static IP setup by restarting networking.
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; sometimes, the uplink cable is pulled out!)
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.
The part of your system journal showing each and every
change made as a result of completing this project, as well as the
answers to the questions asked.
(And if you made changes to files other than the ones asked about, show
the diff
output showing those changes.)
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.