rc files are systemwide configuration scripts executed at boot time by init, which start up all of the basic system daemons (such as sendmail, cron, etc.) and configure things such as the network parameters, system hostname, and so on. rc files are usually found in the directory /etc/rc.d but on other systems may be in /etc.
Here, we're going to describe the rc files used to configure TCP/IP. There are two of them: rc.inet1 and rc.inet2. rc.inet1 is used to configure the basic network parameters (such as IP addresses and routing information) and rc.inet2 fires up the TCP/IP daemons (telnetd, ftpd, and so forth).
Many systems combine these two files into one, usually called rc.inet or rc.net. The names given to your rc files doesn't matter, as long as they perform the correct functions and are executed at boot time by init. To ensure this, you may need to edit /etc/inittab and uncomment lines to execute the appropriate rc file(s). In the worst case you will have to create the rc.inet1 and rc.inet2 files from scratch and add entries for them to /etc/inittab.
As we said, rc.inet1 configures the basic network interface. This includes your IP and network address, and the routing table information for your network. The routing tables are used to route outgoing (and incoming) network datagrams to other machines. On most simple configurations, you have three routes: One for sending packets to your own machine, another for sending packets to other machines on your network, and another for sending packets to machines outside of your network (through the gateway machine). Two programs are used to configure these parameters: ifconfig and route. Both of these are usually found in /etc.
ifconfig is used for configuring the network device interface with the parameters that it requires to function, such as the IP address, network mask, broadcast address and the like. route is used to create and modify entries in the routing table.
For most configurations, an rc.inet1 file that looks like the following should work. You will, of course, have to edit this for your own system. Do not use the sample IP and network addresses listed here for your own system; they correspond to an actual machine on the Internet.
#!/bin/sh
# This is /etc/rc.d/rc.inet1 -- Configure the TCP/IP interfaces
# First, configure the loopback device
HOSTNAME=`hostname`
/etc/ifconfig lo 127.0.0.1 # uses default netmask 255.0.0.0
/etc/route add 127.0.0.1 # a route to point to the loopback device
# Next, configure the ethernet device. If you're only using loopback or
# SLIP, comment out the rest of these lines.
# Edit for your setup.
IPADDR="128.253.154.32" # REPLACE with YOUR IP address
NETMASK="255.255.255.0" # REPLACE with YOUR netmask
NETWORK="128.253.154.0" # REPLACE with YOUR network address
BROADCAST="128.253.154.255" # REPLACE with YOUR broadcast address, if you
# have one. If not, leave blank and edit below.
GATEWAY="128.253.154.1" # REPLACE with YOUR gateway address!
/etc/ifconfig eth0 ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST}
# If you don't have a broadcast address, change the above line to just:
# /etc/ifconfig eth0 ${IPADDR} netmask ${NETMASK}
/etc/route add ${NETWORK}
# The following is only necessary if you have a gateway; that is, your
# network is connected to the outside world.
/etc/route add default gw ${GATEWAY} metric 1
# End of Ethernet Configuration
Again, you may have to tweak this file somewhat to get it to work. The above should be sufficient for the majority of simple network configurations, but certainly not all.
rc.inet2 starts up various servers used by the TCP/IP suite. The most important of these is inetd. inetd sits in the background and listens to various network ports. When a machine tries to make a connection to a certain port (for example, the incoming telnet port), inetd forks off a copy of the appropriate daemon for that port (in the case of the telnet port, inetd starts in.telnetd). This is simpler than running many separate, standalone daemons (e.g., individual copies of telnetd, ftpd, and so forth)---inetd starts up the daemons only when they are needed.
syslogd is the system logging daemon---it accumulates log messages from various applications and stores them into log files based on the configuration information in /etc/syslogd.conf. routed is a server used to maintain dynamic routing information. When your system attempts to send packets to another network, it may require additional routing table entries in order to do so. routed takes care of manipulating the routing table without the need for user intervention.
Our example rc.inet2, below, only starts up the bare minimum of servers. There are many other servers as well---many of which have to do with NFS configuration. When attempting to setup TCP/IP on your system, it's usually best to start with a minimal configuration and add more complex pieces (such as NFS) when you have things working.
Note that in the below file, we assume that all of the network daemons are held in /etc. As usual, edit this for your own configuration.
#! /bin/sh
# Sample /etc/rc.d/rc.inet2
# Start syslogd
if [ -f /etc/syslogd ]
then
/etc/syslogd
fi
# Start inetd
if [ -f /etc/inetd ]
then
/etc/inetd
fi
# Start routed
if [ -f /etc/routed ]
then
/etc/routed -q
fi
# Done!
Among the various additional servers that you may want to start in rc.inet2 is named. named is a name server---it is responsible for translating (local) IP addresses to names, and vice versa. If you don't have a nameserver elsewhere on the network, or want to provide local machine names to other machines in your domain, it may be necessary to run named. (For most configurations it is not necessary, however.) named configuration is somewhat complex and requires planning; we refer interested readers to a good book on TCP/IP network administration.