Tải bản đầy đủ (.pdf) (30 trang)

Red Hat Linux Networking , System Administration (P8) ppsx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (779.95 KB, 30 trang )

# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
Listing 8-4 (continued)
ld.so.conf
This configuration file is used by ldconfig, which configures dynamic linker
runtime bindings. It contains a listing of directories that hold shared libraries.
Shared library files typically end with .so, whereas static library files typi-
cally end with .a, indicating they are an archive of objects.
You may need to edit this file if you’ve installed a program that has installed
a shared library to a different library directory that is not listed in the
ld.so.conf file. In this case, you get an error at runtime that the library does
not exist.
An additional troubleshooting step to take in that case is to run ldd on the
executable in question, which prints shared library dependencies. The output
would look something like this:
[root@terry root]# ldd /bin/bash
libtermcap.so.2 => /lib/libtermcap.so.2 (0x40026000)
libdl.so.2 => /lib/libdl.so.2 (0x4002a000)
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 (0x40000000)
You can see a default listing of library directories in Listing 8-5.
include ld.so.conf.d/*.conf
/usr/X11R6/lib
/usr/lib/qt-3.3/lib
/usr/lib/mysql
Listing 8-5 A typical ld.so.conf file.
logrotate.conf
logrotate.conf and the files within the logrotate.d directory deter-
mine how often your log files are rotated by the logrotate program. Log


rotation refers to the process of deleting older log files and replacing them with
more recent ones. logrotate can automatically rotate, compress, remove,
174 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 174
and mail your log files. Log files can be rotated based on size or on time, such
as daily, weekly, or monthly.
As you can see from the default logrotate.conf file shown in Listing
8-6, most of the options set for how and when to rotate the system logs are
pretty self-explanatory.
For every program that has a separate log rotation configuration file in
logrotate.d, and uses syslogd for logging, there should be a logrot
config file for all log entries in /etc/syslog.conf, as well as log files pro-
duced by external applications, such as Apache. This is because syslog needs
to save log entries for these programs in separate files so that their log files can
be rotated independently of one another.
# see “man logrotate” for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp we’ll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp

rotate 1
}
# system-specific logs may be also be configured here.
Listing 8-6 The logrotate.conf file.
Examining the /etc/sysconfig/ Directory
The following information outlines some of the files found in the /etc
/sysconfig/ directory, their functions, and their contents. This information
is not intended to be complete, as many of these files have a variety of options
used only in very specific or rare circumstances. The /usr/share/doc
/initscripts-version-number/sysconfig.txt file contains a more
Examining the System Configuration Files 175
13_599496 ch08.qxd 8/30/05 6:37 PM Page 175
authoritative listing of the files found in the /etc/sysconfig directory and
the configuration options available. Figure 8-1 shows the contents in a Fedora
Core 3 /etc/sysconfig directory.
NOTE These files are used to pass configuration information to scripts that
run when the system starts. It is possible that your system may be missing
some of the configuration files described here, or it may have more of the files
and directories, depending on whether the corresponding programs that need
the files are installed or not. Also, if the service that uses the configuration file
is not started, the configuration file will not be read.
/etc/sysconfig/apmd
The /etc/sysconfig/apmd file is used by apmd as a configuration for what
things to start, stop, change on suspend, or resume. It provides information to
the apmd during startup if apmd is set to start, depending on whether your
hardware supports Advanced Power Management (APM) or whether you
choose to use it. APM is a monitoring daemon that works with power man-
agement code within the Linux kernel. It can alert you to a low battery if you
are using Red Hat Linux on a laptop, among other things.
Figure 8-1 The contents of the /etc/sysconfig directory.

176 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 176
/etc/sysconfig/authconfig
The /etc/sysconfig/authconfig file provides settings to /usr/sbin
/authconfig, which is called from /etc/rc.sysinit for the kind of autho-
rization to be used on the host. The basic syntax for lines in this file is:
USE <service name> =<value>
Some sample lines from the file are shown here.
■■ USEMD5=value, where value is one of the following:
■■ yes — MD5 is used for authentication.
■■ no — MD5 is not used for authentication.
■■ USEKERBEROS=value, where value is one of the following:
■■ yes — Kerberos is used for authentication.
■■ no — Kerberos is not used for authentication.
■■ USELDAPAUTH=value, where value is one of the following:
■■ yes — LDAP is used for authentication.
■■ no — LDAP is not used for authentication.
/etc/sysconfig/clock
The /etc/sysconfig/clock file controls the interpretation of values read
from the system clock. Currently, the correct values are as follows:
■■ UTC=value, where value is one of the following Boolean values:
■■ true — Indicates that the hardware clock is set to Universal Time.
■■ Any other value indicates that it is set to local time.
■■ ARC=value, where value is the following:
■■ true — Indicates the ARC console’s 42-year time offset is in effect.
■■ Any other value indicates that the normal UNIX epoch is assumed
(for Alpha-based systems only).
■■ ZONE=filename — Indicates the time zone file under /usr/share
/zoneinfo that /etc/localtime is a copy of, such as: ZONE=
”America/New York”. Identifies the time zone file copied into /etc

/localtime, such as ZONE=”America/New York”. Time zone files
are stored in /usr/share/zoneinfo.
Examining the System Configuration Files 177
13_599496 ch08.qxd 8/30/05 6:37 PM Page 177
/etc/sysconfig/crond
This file contains settings for the cron daemon. You typically do not need to
make any changes to this file.
/etc/sysconfig/desktop
The /etc/sysconfig/desktop file specifies the desktop manager to be run
and is used by the /etc/X11/xinit/Xclients script, for example:
DESKTOP=”GNOME”
/etc/sysconfig/firstboot
In Fedora Core and Enterprise Linux, the first time you boot the system after
the OS installation, the /sbin/init program calls the etc/rc.d/init.d
/firstboot script. This allows the user to install additional applications and
documentation before the boot process completes. The /etc/sysconfig
/firstboot file tells the firstboot command not to run on subsequent
reboots. If you want firstboot to run the next time you boot the system,
simply remove /etc/sysconfig/firstboot and execute chkconfig
level 5 firstboot on.
/etc/sysconfig/grub
The /etc/sysconfig/grub file is used to pass arguments to GRUB at boot
time. The information passed is the drive to boot from and whether to use lba
mode.
/etc/sysconfig/harddisks
The /etc/sysconfig/harddisks file allows you to tune your hard drive(s).
CAUTION Do not make changes to this file lightly. If you change the default
values stored here, you could corrupt all of the data on your hard drive(s).
The /etc/sysconfig/harddisks file may contain the following:
■■ USE_DMA=1, where setting this to 1 enables DMA. However, with some

chipsets and hard-drive combinations, DMA can cause data corruption.
Check with your hard-drive documentation or manufacturer before
enabling this.
178 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 178
■■ Multiple_IO=16, where a setting of 16 allows for multiple sectors per
I/O interrupt. When enabled, this feature reduces operating system
overhead by 30 to 50 percent. Use with caution.
■■ EIDE_32BIT=3 enables (E)IDE 32-bit I/O support to an interface card.
■■ LOOKAHEAD=1 enables drive read-lookahead.
■■ EXTRA_PARAMS= specifies where extra parameters can be added.
/etc/sysconfig/hwconf
The /etc/sysconfig/hwconf file lists all the hardware that kudzu detected
on your system, as well as the drivers used, vendor ID, and device ID infor-
mation. The kudzu program detects and configures new and/or changed
hardware on a system. The /etc/sysconfig/hwconf file is not meant to be
manually edited. If you do edit it, devices can suddenly show up as added or
not show up if removed.
/etc/sysconfig/i18n
The /etc/sysconfig/i18n file sets the default language, for example:
LANG=”en_US”
/etc/sysconfig/init
The /etc/sysconfig/init file controls how the system will appear and
function during the boot process. The following values may be used:
■■ BOOTUP=value, where value is one of the following:
■■ BOOTUP=color means the standard color boot display, where the
success or failure of devices and services starting up is shown in dif-
ferent colors.
■■ BOOTUP=verbose means an old-style display, which provides more
information than purely a message of success or failure.

■■ Anything else means a new display, but without ANSI formatting.
■■ RES_COL=value, where value is the number of the column of the
screen to start status labels. It defaults to 60.
■■ MOVE_TO_COL=value, where value moves the cursor to the value in
the RES_COL line. It defaults to ANSI sequences output by echo -e.
Examining the System Configuration Files 179
13_599496 ch08.qxd 8/30/05 6:37 PM Page 179
■■ SETCOLOR_SUCCESS=value, where value sets the color to a color
indicating success. It defaults to ANSI sequences output by echo -e,
setting the color to green.
■■ SETCOLOR_FAILURE=value, where value sets the color to one indi-
cating failure. It defaults to ANSI sequences output by echo -e, setting
the color to red.
■■ SETCOLOR_WARNING=value, where value sets the color to one indi-
cating warning. It defaults to ANSI sequences output by echo -e, set-
ting the color to yellow.
■■ SETCOLOR_NORMAL=value, where value sets the color to “normal.”
It defaults to ANSI sequences output by echo -e.
■■ LOGLEVEL=value, where value sets the initial console logging level
for the kernel. The default is 7; 8 means everything (including debug-
ging); 1 means nothing except kernel panics. syslogd will override this
once it starts.
■■ PROMPT=value, where value is one of the following Boolean values:
■■ yes — Enables the key check for interactive mode.
■■ no — Disables the key check for interactive mode.
/etc/sysconfig/iptables
The /etc/sysconfig/iptables file stores information used by the kernel
to set up packet-filtering services at boot time or whenever the service is
started. You should not modify this file by hand unless you are familiar with
how to construct iptables rules. The simplest way to add rules is to use the

/usr/sbin/lokkit command from a terminal prompt if you aren’t running
an X server. If you are running an X server, you can type system-config-
securitylevel from a terminal prompt or select Applications ➪ System
Settings ➪ Security Level from the main menu to start the graphical applica-
tion to create your firewall. Using these applications automatically edits this
file at the end of the process.
If you wish, you can manually create rules using /sbin/iptables and
then type /sbin/service iptables save to add the rules to the /etc/
sysconfig/iptables file. Once this file exists, any firewall rules saved
there are persisted through a system reboot or a service restart.
CROSS-REFERENCE For more information on iptables, see Chapter 34.
180 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 180
/etc/sysconfig/irda
The /etc/sysconfig/irda file controls how infrared devices on your sys-
tem are configured at startup. The following values may be used:
■■ IRDA=value, where value is one of the following Boolean values:
■■ yes — irattach will be run, which periodically checks to see whether
anything is trying to connect to the infrared port, such as another
notebook computer attempting to make a network connection. For
infrared devices to work on your system, this line must be set to yes.
■■ no — irattach will not be run, preventing infrared device
communication.
■■ DEVICE=value, where value is the device (usually a serial port) that
handles infrared connections.
■■ DONGLE=value, where value specifies the type of dongle being used
for infrared communication. This setting exists for people who use ser-
ial dongles rather than real infrared ports. A dongle is a device attached
to a traditional serial port to communicate via infrared. This line is com-
mented out by default because notebooks with real infrared ports are

far more common than computers with add-on dongles.
■■ DISCOVERY=value, where value is one of the following Boolean values:
■■ yes — Starts irattach in discovery mode, meaning it actively checks
for other infrared devices. This needs to be turned on in order for
the machine to be actively looking for an infrared connection (mean-
ing the peer that does not initiate the connection).
■■ no — Does not start irattach in discovery mode.
/etc/sysconfig/kernel
The settings in this file specify whether new kernels loaded by the up2date
utility should be booted by default. You can change the setting from yes to no
to prevent the newly updated kernel from booting.
/etc/sysconfig/keyboard
The /etc/sysconfig/keyboard file controls the behavior of the keyboard.
The following values may be used:
■■ KEYBOARDTYPE=sun|pc, which is used on SPARCs only. sun means a
Sun keyboard is attached on /dev/kbd, and pc means a PS/2 keyboard
is connected to a PS/2 port.
Examining the System Configuration Files 181
13_599496 ch08.qxd 8/30/05 6:37 PM Page 181
■■ KEYTABLE=file, where file is the name of a keytable file. For exam-
ple: KEYTABLE=”us”. The files that can be used as keytables start in
/usr/lib/kbd/keymaps/i386 and branch into different keyboard
layouts from there, all labeled file.kmap.gz. The first file found
beneath /usr/lib/kbd/keymaps/i386 that matches the KEYTABLE
setting is used.
/etc/sysconfig/kudzu
The /etc/sysconfig/kuzdu is used by /etc/init.d/kudzu, and it
allows you to specify a safe probe of your system’s hardware by kudzu at boot
time. A safe probe is one that disables serial port probing.
■■ SAFE=value, where value is one of the following:

■■ yes — kuzdu does a safe probe.
■■ no — kuzdu does a normal probe.
/etc/sysconfig/mouse
The /etc/sysconfig/mouse file is used by /etc/init.d/gpm to specify
information about the available mouse. The following values may be used:
■■ FULLNAME=value, where value refers to the full name of the kind of
mouse being used.
■■ MOUSETYPE=value, where value is one of the following:
■■ microsoft — A Microsoft mouse.
■■ mouseman — A MouseMan mouse.
■■ mousesystems — A Mouse Systems mouse.
■■ ps/2 — A PS/2 mouse.
■■ msbm — A Microsoft bus mouse.
■■ logibm — A Logitech bus mouse.
■■ atibm — An ATI bus mouse.
■■ logitech — A Logitech mouse.
■■ mmseries — An older MouseMan mouse.
■■ mmhittab — An mmhittab mouse.
182 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 182
■■ XEMU3=value, where value is one of the following Boolean values:
■■ yes — The mouse has only two buttons, but three mouse buttons
should be emulated.
■■ no — The mouse already has three buttons.
■■ XMOUSETYPE=value, where value refers to the kind of mouse used
when X is running. The options here are the same as those provided by
the MOUSETYPE setting in this same file.
■■ DEVICE=value, where value is the mouse device. In addition,
/dev/mouse is a symbolic link that points to the actual mouse device.
/etc/sysconfig/named

The /etc/sysconfig/named file is used to pass arguments to the named
daemon at boot time if the named daemon is started. The named daemon is a
Domain Name System (DNS) server, which implements the Berkeley Internet
Name Domain (BIND) version 9 distribution. This server maintains a table of
which hostnames are associated with IP addresses on the network. Currently,
only the following values may be used:
■■ ROOTDIR=/some/where, where /some/where refers to the full direc-
tory path of a configured chroot environment under which named
will run. This chroot environment must first be configured. Type info
chroot for more information on how to do this.
■■ OPTIONS=”value”, where value is any option listed in the man page
for named except -t. In place of -t, use the preceding ROOTDIR line.
For more information about what parameters you can use in this file, type
man named. By default, the file contains no parameters.
CROSS-REFERENCE For detailed information on how to configure a BIND
DNS server, see Chapter 18.
/etc/sysconfig/netdump
The /etc/sysconfig/netdump file is the configuration file for the /etc/
init.d/netdump service. The netdump service sends both oops data and
memory dumps over the network. In general, netdump is not a required ser-
vice, so you should run it only if you absolutely need to. For more information
about what parameters you can use in this file, type man netdump.
Examining the System Configuration Files 183
13_599496 ch08.qxd 8/30/05 6:37 PM Page 183
/etc/sysconfig/network
The /etc/sysconfig/network file is used to specify information about the
desired network configuration. The following values may be used:
■■ NETWORKING=value, where value is one of the following Boolean
values:
■■ yes — Networking should be configured.

■■ no — Networking should not be configured.
■■ HOSTNAME=value, where value should be the fully qualified domain
name (FQDN), such as hostname.domain.com, but can be whatever
hostname you want.
NOTE For compatibility with older software that people might install, the
/etc/HOSTNAME file and the /etc/sysconfig/network file should contain
the same value.
■■ GATEWAY=value, where value is the IP address of the network’s
gateway.
■■ GATEWAYDEV=value, where value is the gateway device, such as eth0.
■■ NISDOMAIN=value, where value is the NIS domain name.
/etc/sysconfig/ntpd
The /etc/sysconfig/ntpd file is used to pass arguments to the ntpd dae-
mon if it is used at boot time. The ntpd daemon sets and maintains the system
clock to synchronize with an Internet standard time server. It implements ver-
sion 4 of the Network Time Protocol (NTP). For more information about what
parameters you can use in this file, point a browser at the following file:
/usr/share/doc/ntp-version/ntpd.htm (where version is the ver-
sion number of ntpd). By default, this file sets the owner of the ntpd process to
the user ntp.
/etc/sysconfig/pcmcia
The /etc/sysconfig/pcmcia file is used to specify PCMCIA configuration
information. The following values may be used:
■■ PCMCIA=value, where value is one of the following:
■■ yes — PCMCIA support should be enabled.
■■ no — PCMCIA support should not be enabled.
184 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 184
■■ PCIC=value, where value is one of the following:
■■ i82365 — The computer has an i82365-style PCMCIA socket chipset.

■■ tcic — The computer has a tcic-style PCMCIA socket chipset.
■■ PCIC_OPTS=value, where value is the socket driver (i82365 or tcic)
timing parameters.
■■ CORE_OPTS=value, where value is the list of pcmcia_core options.
■■ CARDMGR_OPTS=value, where value is the list of options for the
PCMCIA cardmgr (such as -q for quiet mode, -m to look for loadable
kernel modules in the specified directory, and so on). Read the cardmgr
man page for more information.
/etc/sysconfig/selinux
This file is a link to /etc/selinux/config and is used to control selinux on
the system. It contains two settings that control the state of selinux — enforc-
ing, permissive, or disabled — and the type of policy, either targeted or strict.
A sample of this file is shown here.
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=permissive
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
/etc/sysconfig/system-config-users
The /etc/sysconfig/system-config-users file is the configuration file
for the graphical application User Manager. This file is used to filter out system
users such as root, daemon, and lp. This file is edited via the Preferences ➪
Filter system users and groups pull-down menu in the User Manager applica-
tion and should not be edited manually.
/etc/sysconfig/system-logviewer

The /etc/sysconfig/system-logviewer file is the configuration file for
the graphical, interactive log-viewing application Log Viewer. This file is edited
Examining the System Configuration Files 185
13_599496 ch08.qxd 8/30/05 6:37 PM Page 185
via the Edit ➪ Preferences pull-down menu in the System Logs application and
should not be edited manually.
/etc/sysconfig/samba
The /etc/sysconfig/samba file is used to pass arguments to the smbd and
the nmbd daemons at boot time. The smbd daemon offers file-sharing connec-
tivity for Windows clients on the network. The nmbd daemon offers NetBIOS-
over-IP naming services. For more information about what parameters you
can use in this file, type man smbd. By default, this file sets smbd and nmbd to
run in daemon mode.
/etc/sysconfig/sendmail
The /etc/sysconfig/sendmail file allows messages to be sent to one or
more recipients, routing the message over whatever networks are necessary.
The file sets the default values for the Sendmail application to run. Its default
values are to run as a background daemon, and to check its queue once an
hour in case something has backed up and stalled the process. The following
values may be used:
■■ DAEMON=value, where value is one of the following Boolean values:
■■ yes — Sendmail should be configured to listen to port 25 for incom-
ing mail. yes implies the use of Sendmail’s -bd options.
■■ no — Sendmail should not be configured to listen to port 25 for
incoming mail.
■■ QUEUE=1h, which is given to Sendmail as -q$QUEUE. The -q option is
not given to Sendmail if /etc/sysconfig/sendmail exists and
QUEUE is empty or undefined.
/etc/sysconfig/vncservers
The /etc/sysconfig/vncservers file configures the way the virtual net-

work computing (VNC) server starts up. VNC is a remote display system that
allows you to view a desktop environment not only on the machine where it is
running but across different networks on a variety of architectures. It may con-
tain the following:
■■ VNCSERVERS=value, where value is set to something like 1:fred to
indicate that a VNC server should be started for user fred on display
:1. User fred must have set a VNC password using vncpasswd before
attempting to connect to the remote VNC server.
186 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 186
Note that when you use a VNC server, your communication with it is unen-
crypted, and so it should not be used on an untrusted network. For specific
instructions concerning the use of SSH to secure the VNC communication, see
research.att.com/vnc/sshvnc.html. To find out more about SSH,
see Chapter 28.
/etc/sysconfig/xinetd
The /etc/sysconfig/xinetd file is used to pass arguments to the xinetd
daemon at boot time. The xinetd daemon starts programs that provide Inter-
net services when a request to the port for that service is received. For more
information about what parameters you can use in this file, type man xinetd.
For more information on the xinetd service, see Chapter 25.
Directories in the /etc/sysconfig/ Directory
The following directories are normally found in /etc/sysconfig/.
apm-scripts
This contains the Red Hat APM suspend/resume script. You should not edit
this file directly. If you need customization, simply create a file called /etc
/sysconfig/apm-scripts/apmcontinue, and it will be called at the end
of the script. Also, you can control the script by editing /etc/sysconfig/
apmd.
daemons

This directory is initially empty after the system installation. It is used to hold
the configuration scripts for programs that the user may have installed. For
example, the configuration files for the webmin program are placed in this
directory during its installation.
networking
This directory is used by the Network Configuration tool (system-config-
network), and its contents should not be edited manually.
CROSS-REFERENCE For more information about configuring network
interfaces using the Network Configuration tool, see Chapter 11.
Examining the System Configuration Files 187
13_599496 ch08.qxd 8/30/05 6:37 PM Page 187
network-scripts
This directory contains files used for network configuration.
■■ Network configuration files for each configured network interface, such
as ifcfg-eth0 for the eth0 Ethernet interface.
■■ Scripts used to bring up and down network interfaces, such as ifup
and ifdown.
■■ Scripts used to bring up and down ISDN interfaces, such as ifup-
isdn and ifdown-isdn.
■■ Various shared network function scripts that should not be edited
directly.
rhn
This directory contains the configuration files and GPG keys for Red Hat Net-
work. No files in this directory should be edited by hand. For more informa-
tion on Red Hat Network, see the Red Hat Network Web site at https://
rhn.redhat.com.
Examining the Network Configuration Files
This section discusses the following topics:
■■ Files to change when setting up a system or moving the system
■■ Starting up network services from xinetd

■■ Starting up network services from the rc scripts
■■ Other important network configuration files in the /etc/sysconfig
directory
Files to Change When Setting Up
a System or Moving the System
Whenever you set up a system to work on a new network, either because you’ve
just installed Red Hat or you’re moving the machine from one location to
another, a set of files needs to be modified to get it working on the new network.
You need to:
■■ Set up the IP addresses of your network interfaces. Make changes to:
/etc/sysconfig/network-scripts/ifcfg-eth0
188 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 188
■■ Set up the hostname of your machine. Make changes to:
/etc/sysconfig/network
/etc/hosts
■■ Set up the DNS servers to reference. Make changes to:
/etc/resolv.conf
■■ Make a local file of hostname to IP address mappings. Make changes to:
/etc/hosts
■■ Set up the device order from which hostnames are looked up. Make
changes to:
/etc/nsswitch.conf
CROSS-REFERENCE Chapter 20 explains the Domain Name System (DNS)
and how to set it up on your network.
TIP Fedora Core and Red Hat Enterprise Linux provide a handy graphical tool,
called the Network Configuration tool for configuring your network settings.
Start up the Network Configuration tool while in X-Window, and enjoy an
interface very similar to the Windows control panel for networks. Refer to
Chapter 11 for instructions on using the Network Configuration tool. If you use

the Network Configuration tool to set up your network, you do not need to edit
the files manually as explained in the next sections. Also, if you use DHCP to
obtain your IP information, you do not need to do any manual configuration and
can skip the sections related to manually configuring your network settings.
Setting Up the IP Address
The first thing you should do is set an IP address on your network interfaces.
This step provides your computer with an identity on the network. If you
haven’t set the IP address already in the installation process, you need to edit
the configuration files by hand.
To set the IP address on your first Ethernet interface eth0, edit the /etc/
sysconfig/network-scripts/ifcfg-eth0 file. A copy of this file is
shown in Listing 8-7.
Insert your interface’s IP address on the line that says:
IPADDR=””
You should also check that the rest of the lines look all right, but pay special
attention to the following two lines:
Examining the System Configuration Files 189
13_599496 ch08.qxd 8/30/05 6:37 PM Page 189
BROADCAST=192.168.1.255
NETMASK=”255.255.255.0”
DEVICE=”eth0”
BOOTPROTO=”static”
BROADCAST=192.168.1.255
IPADDR=”192.168.1.10”
NETMASK=”255.255.255.0”
NETWORK=192.168.1.0
ONBOOT=”yes”
USERCTL=no
Listing 8-7 The /etc/sysconfig/network-scripts/ifcfg-eth0 file.
Setting Up the Hostname

Once you’ve picked your hostname, you need to put it into two different
places: /etc/sysconfig/network and /etc/hosts.
In /etc/sysconfig/network, shown next, change the line that says:
HOSTNAME=”terry”
This is the /etc/sysconfig/network file:
NETWORKING=yes
HOSTNAME=”terry”
GATEWAY=”192.168.1.1”
GATEWAYDEV=”eth0”
FORWARD_IPV4=”yes”
You also need to modify the /etc/hosts file. Change the first line in the
file, which would look something like this by adding the hostname you want:
127.0.0.1 terry localhost.localdomain localhost locala localb localc
Setting Up the DNS Name Resolution
Now you should be able to communicate with the other hosts on the network.
However, you won’t be able to talk to them unless you know their IP addresses,
because you haven’t set up what DNS servers you should reference to map
hostnames to IP addresses.
190 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 190
The program that resolves hostnames to IP addresses reads a file called
resolv.conf, so you need to put your DNS server IP addresses there. Gen-
erally, you need one name server, but you can include up to three, if you’d like.
Specifying more than one name server is important. If the first one on the list
is not responding, your computer tries to resolve against the next one on the
list, and so on, until it finds one that is responding.
Edit /etc/resolv.conf to contain a list of name servers, like this:
nameserver 1.2.3.4
nameserver 1.2.3.5
nameserver 1.2.3.6

Making a Local File of Hostname to IP Address Mappings
Linux gives you the ability to store a list of hostnames and their corresponding
IP addresses in /etc/hosts, so that you don’t have to look them up in DNS
every time you use them. While you shouldn’t do this with every hostname
you ever use, one of the advantages gained by configuring often-used host-
names in this way includes the ability to alias a fully qualified hostname to a
shorter version of itself. So instead of typing ssh foo.xena.edu every time you
want to SSH to that machine, you can just type ssh foo, and have it connect
to the same host.
Another useful example occurs if you’re monitoring several servers’ net-
work services from a monitoring host. If you’re monitoring SSH connectivity
to certain servers, for example, and your DNS server stops responding, then
the monitoring software may report that all your hosts are down. This hap-
pens because the monitoring software tries to connect to the server via its host-
name, and gets no response because DNS is not providing it with an IP address
to connect to. In this case it looks as if your whole network fell over, when the
real problem is that your DNS service is not responding properly.
To keep this kind of scenario from happening, you should put the host-
names and IP addresses of all your monitored servers in /etc/hosts. This
way, your monitoring software looks into /etc/hosts to get the proper IP
addresses, instead of relying on DNS.
The only caveat to keep in mind when putting hosts in /etc/hosts is that
if the hostname’s IP address changes for whatever reason, the hosts file does
not automatically update to reflect that change. If you start getting connection
errors when connecting to a host in the /etc/hosts file, you should do an
nslookup on the host and update your /etc/hosts file accordingly.
Your /etc/hosts file should contain IP address to hostname mappings
that follow this format
IP_address canonical_hostname aliases
Examining the System Configuration Files 191

13_599496 ch08.qxd 8/30/05 6:37 PM Page 191
so that the lines look like this:
192.168.1.66 foo.xena.edu foo
192.168.1.76 buffy.xena.edu buffy
152.2.210.81 sunsite.unc.edu sunsite
Setting Up Name Service Resolution Order
Now that you’ve set up your DNS servers and hosts file, you need to tell your
Linux server which method it should use first to look up hostnames.
The place to set up this configuration is in the /etc/nsswitch.conf file.
Edit the following line:
hosts: files nisplus dns
The order of the words files, nisplus, and dns determines which
method is checked first. Files refers to the /etc/hosts file, nisplus refers
to any nisplus servers you may have on your network, and dns refers to any
DNS servers you have set up your machine to reference.
As you can see in Listing 8-8, the /etc/nsswitch.conf file contains some
other useful settings; for example the following two lines, specify whether the
server should authenticate users off the local password file or off the network’s
NIS plus service:
passwd: files nisplus
shadow: files nisplus
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry ‘[NOTFOUND=return]’ means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason

# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
# nisplus or nis+ Use NIS+ (NIS version 3)
# nis or yp Use NIS (NIS version 2), also called YP
# dns Use DNS (Domain Name Service)
# files Use the local files
Listing 8-8 The /etc/nsswitch.conf file. (continued)
192 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 192
# db Use the local database (.db) files
# compat Use NIS on compat mode
# hesiod Use Hesiod for user lookups
# [NOTFOUND=return] Stop searching if not found so far
#
# To use db, put the “db” in front of “files” for entries you want to be
# looked up first in the databases
#
# Example:
#passwd: db files nisplus nis
#shadow: db files nisplus nis
#group: db files nisplus nis
passwd: files nisplus
shadow: files nisplus
group: files nisplus
#hosts: db files nisplus nis dns
hosts: files nisplus dns
# Example - obey only what nisplus tells us

#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files nisplus
rpc: files
services: files nisplus
netgroup: files nisplus
publickey: nisplus
automount: files nisplus
aliases: files nisplus
Listing 8-8 (continued)
Starting Up Network Services from xinetd
xinetd is the replacement for inetd. xinetd is started on bootup and lis-
tens on ports designated in the /etc/xinetd.conf for incoming network
Examining the System Configuration Files 193
13_599496 ch08.qxd 8/30/05 6:37 PM Page 193
connections. When a new connection is made, xinetd starts up the corre-
sponding network service.
You should disable any unnecessary services from being started from xinetd as
part of securing your machine. The way to do this is to edit that service’s config-
uration file. xinetd’s main configuration file is /etc/xinetd.conf. At the end
of the xinetd.conf file is a line that indicates that all the files in the /etc/
xinetd.d are also included in the configuration. This means that you need to go

through the files in that directory as well to turn off any services you don’t want.
So, to disable Telnet, you would look in /etc/xinetd.d for a file called
telnet. The telnet file is shown in Listing 8-9. Edit the line in the config file
that says disable = no, and change that to disable = yes, as it appears in
Listing 8-9. After that line is set to disable = yes, the service is disabled and
does not start up the next time you boot up.
/etc/xinetd.d/telnet
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = yes
}
Listing 8-9 The Telnet config file in the xinetd.d directory.
An automated tool, called chkconfig, manages what services are started
from xinetd and the rc scripts. You can read more about chkconfig in the sec-
tion called “Managing rc Scripts Using chkconfig.”
Starting Up Network Services from the rc Scripts
Network services that are not started out of xinetd are started out of the rc
scripts at boot time. Network services started at the default boot level 3 (multi-
user networked mode) are started out of the /etc/rc3.d directory. If you
look in that directory, you should see a file with the name of the service you
want to stop or start. The script to start the service starts with an S, and the kill

script starts with a K.
So for example, SSH is started from /etc/rc3.d /S55sshd, and killed
upon shutdown from /etc/rc6.d/K25sshd. Runlevel 6 is the shutdown
level, so that’s why its kill script is located in the rc6.d directory.
194 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 194
Detailed information on managing all the services started at boot time can
be found in the section “Managing the init Scripts” later in this chapter.
CROSS-REFERENCE See Chapter 6 for details about the system startup
process.
Other Important Network Configuration Files
in the /etc/sysconfig Directory
You can use the files listed in this section to create routes to other hosts, either
on your own network or on outside networks. You also can use these files to
set up firewall rules for your network to either allow or disallow connections
to your network.
static-routes
If you want to set up some static routes on your machine, you can do so in the
static-routes file. This config file has lines in the following format:
network-interface net network netmask netmask gw gateway
Iptables
iptables is the current Fedora Core and Enterprise Linux firewall. It supercedes
the ipchains firewall. It can use ipchains rules as a component of its firewall fil-
tering, but iptables and ipchains cannot be run at the same time. This is the file
where the iptables rules are stored.
When you install Fedora or Enterprise Linux, the installation asks if you
would like to enable a host-based firewall. If you select to enable a host-based
firewall, a default set of iptables rules installs according to your preferences.
The following is a simplified configuration file. The gist of this configura-
tion is that all incoming traffic to privileged ports (those below 1024) is

dropped except for SSH traffic. The first line accepts all traffic from the loop-
back interface. The second line accepts all incoming TCP traffic to the SSH
port. The third line drops all incoming TCP traffic to ports between 1 and 1024.
The last line drops all incoming UDP traffic to ports between 1 and 1024.
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp dport 22 -p tcp -j ACCEPT
-A INPUT -p tcp -s ! 192.168.1.0/24 dport 1:1024 -j DROP
-A INPUT -p udp -s ! 192.168.1.0/24 dport 1:1024 -j DROP
Examining the System Configuration Files 195
13_599496 ch08.qxd 8/30/05 6:37 PM Page 195
Network Configuration Files in
/etc/sysconfig/network-scripts
You can use the files in this directory to set the parameters for the hardware
and software used for networking. The scripts contained here are used to
enable network interfaces and set other network-related parameters.
ifcfg-networkinterfacename
A few files fall into this specification. Red Hat specifies a separate configuration
file for each network interface. In a typical Red Hat install, you might have many
different network interface config files that all follow the same basic syntax and
format.
You could have ifcfg-eth0 for your first Ethernet interface, ifcfg-
irlan0 for your infrared network port, ifcfg-lo for the network loopback
interface, and ifcfg-ppp0 for your PPP network interface.
ifup and ifdown
These files are symlinks to /sbin/ifup and /sbin/ifdown. In future
releases, these symlinks might be phased out. But for now, these scripts are
called when the network service is started or stopped. In turn, ifup and
ifdown call any other necessary scripts from within the network-scripts direc-
tory. These should be the only scripts you call from this directory.
You call these scripts with the name of the interface that you want to bring

up or down. If these scripts are called at boot time, then boot is used as the
second argument. For instance, to bring your Ethernet interface down and
then up again after boot, you would type:
ifup eth0
ifdown eth0
Managing the init Scripts
This section discusses the following topics:
■■ Managing rc scripts by hand
■■ Managing rc scripts using chkconfig
Init scripts determine which programs start up at boot time. Red Hat and
other Unix distributions have different runlevels, so there are a different set of
programs that are started at each runlevel.
196 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 196
Usually Red Hat Linux starts up in multiuser mode with networking turned
on. These are some of the other runlevels available:
■■ 0 — Halt
■■ 1 — Single-user mode
■■ 2 — Multiuser mode, without networking
■■ 3 — Full multiuser mode
■■ 4 — Not used
■■ 5 — Full multiuser mode (with an X-based login screen)
■■ 6 — Reboot
The system boots into the default runlevel set in /etc/inittab. (See List-
ing 8-10.)
NOTE In Red Hat Linux, the default boot level is 3 for a non-GUI system.
When booting into an X-windows login, the default boot level is 5. You can get
more information about this topic in Chapter 6.
#
# inittab This file describes how the INIT process should set up

# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg, <>
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
Listing 8-10 A default /etc/inittab file. (continued)
Examining the System Configuration Files 197
13_599496 ch08.qxd 8/30/05 6:37 PM Page 197
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
# Things to run in every runlevel.
ud::once:/sbin/update
# Trap CTRL-ALT-DELETE

ca::ctrlaltdel:/sbin/shutdown -t3 -r now
# When our UPS tells us power has failed, assume we have a few minutes
# of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 “Power Failure; System Shutting Down”
# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c “Power Restored; Shutdown Cancelled”
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
# Run xdm in runlevel 5
# xdm is now a separate service
x:5:respawn:/etc/X11/prefdm –nodaemon
Listing 8-10 (continued)
Managing rc Scripts by Hand
If you want to configure which services are started at boot time, you need to
edit the rc scripts for the appropriate runlevel. The default runlevel is 3, which
is full multiuser mode without a graphical interface and runlevel 5 with a
graphical interface. So, to change the services that are started in the default
runlevel, you should edit the scripts found in /etc/rc3.d, or /etc/rc5.d
depending on your system.
When you look at a directory listing of the rc directories, notice that the files
either start with S or K. The files that start with S are startup files, and the files
that start with K are kill files. The S scripts are run in the numerical order listed
in their filenames. It should be mentioned that if a startup script is set to S15,

the K script should be K85 (or in general, SN becomes SM with M = 100 - n; the
idea being the last started service is the first killed).
198 Chapter 8
13_599496 ch08.qxd 8/30/05 6:37 PM Page 198

×