Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

Choosing Network Services During Installation

As noted earlier, Linux supports many network services. Your job is determining which ones you need. Network services come in two basic flavors:

  • Services that deliver information to clients for human consumption. For example, a Web server, which allows users to download documents and media.

  • Services that deliver information to clients or hosts for network and operational purposes. For example, Dynamic Host Configuration Protocol, which automatically sets up clients' network configuration.

Network services that provide people with data or functionality are generally not essential. Instead, they are privileges and niceties that you afford your users, and you'd profit by viewing them that way. Indeed, because almost every service you run will complicate system administration and security, the fewer you allow the better. Here are some nonessential services that provide people with data or functionality:

  • bootpd—A server that can implement the bootstrap protocol, which allows you to boot diskless clients from a server. During startup, a diskless client queries the server and discovers its IP address. It also loads any files specified by the server. (Typically, the server forwards a boot program.) Don't run bootpd if you don't need it.

  • fingerd—The finger server, which gathers personal information on specified users, including their username, real name, shell, directory, and office telephone number (if available). On request, fingerd forwards this information to anyone using a finger client. Here's an example of what fingerd returns:

  • Login name: unowen           In real life: U. N. Owen
    Directory: /home/unowen         Shell: /sbin/sh
    On since Feb 3 18:13:14 on pts/15 from ppp-208-19-49-133.samshacker.net
    Mail last read Wed Feb 3 18:01:12 1999
  • This isn't essential by any means. In fact, it might expose your users and your Linux server to unwanted invasions of privacy. Disable fingerd unless you have a good reason not to. To do so, comment it out in /etc/inet.d by placing a # symbol at the beginning of the finger definition line). Users of xinetd can either remove the server file from their /etc/xinetd.d directory, or set disable = yes within the service file.

  • ftpd—File Transfer Protocol (FTP), which provides standard file transfer over internetworks. Today, there's less reason to run an FTP server. The WWW has made it easy to distribute files using HTTP, which most users are more familiar with anyhow. If you are going to provide FTP services, see Chapter 11, "FTP Security."

  • httpd—The Hypertext Transfer Protocol server. This is your Web server. Without a doubt, you'll want to provide at least limited Web services. Check Chapter 14, "Web Server Security," for ways to tighten access control and general Web security.

  • nfs—Network File System, a system that allows you to transparently import files from or export file systems to remote hosts. These files appear and act as though they were installed on your local machine. NFS is useful in many situations. For example, if you're hosting Web servers for third parties (running a Web farm), you can run exports to a RAID server. That way, all user Web directories are actually stored on a single server, redundant and prepared for possible individual host failures. To users, who maintain their own Web pages, everything appears to be local when they telnet or FTP into their co-located box.

  • NFS has many other uses, too. However, if you don't need it, don't install or enable it. NFS has some security issues, even though secure NFS systems do exist. Learn more in Chapter 15, "Secure Web Protocols."

  • nntpd—Network News Transfer Protocol server. This is the Usenet news server. Today, most people get Usenet news from their ISP's feed, so there's little reason to run NNTP yourself.

  • rlogind—The rlogin (remote login) server. rlogin is an r service that allows users to conduct remote terminal sessions, much like telnet does. A major difference between rlogin and telnet is that rlogin allows users to set up passwordless access on trusted hosts with trusted users. You probably don't want this.

  • rshd—The remote shell (rsh) server. rsh allows users to execute commands on remote hosts running rshd. This is a member of the r services family (rsh, rlogin, and so on), which is a notorious security hazard. Carefully consider whether you need to provide such services.

  • talkd—The talk server. talk is an interactive chatting system for Linux that splits each user's screen in half. The top half echoes the requesting party's keystrokes, and the bottom echoes the responding party's keystrokes. Is this essential? Hardly. However, if your system is in-house (not wired to the Net), you might want to keep talk for quick interdepartmental communication.

  • telnetd—The telnet server. Although telnet can increase risk, it is indispensable for some administrative tasks, so you'll probably want it. Check Chapter 13, "Telnet and SSH Security," for ways to lock down telnet and keep it useful but safe.

  • sshd—The secure shell server. The Secure Shell Daemon provides a replacement to telnet that offers full traffic encryption. This is a good thing to keep around if you want to perform remote administration.

  • tftp—Trivial File Transfer Protocol (TFTP). TFTP is an antiquated means of transferring files. You probably don't need it.

These are just a few examples, Chapter 14 has a larger list with descriptions. A default installation could result in many more nonessential services cluttering up your system and eroding its security. For this reason, whenever possible, you should run a verbose installation and explicitly reject packages that you don't need.

Five Minutes to a More Secure System

After installing Linux, the first thing you should do is assess the services that are running on your computer. Linux starts services in one of two primary ways: by running them at boot time, or by a connection request occurring at the appropriate port.

inetd and xinetd

The first place to look for unnecessary services is in the /etc/inetd.conf file or /etc/xinetd.d directory. The inetd process is the Internet daemon. It listens on the appropriate port for a service request, and then starts the corresponding server to process the request. If you have a system that uses inetd, check your system for the presence of /etc/inetd.conf. A sample of the file contents are shown here:

#echo  stream tcp   nowait root  internal
#echo  dgram  udp   wait  root  internal
#discard    stream tcp   nowait root  internal
#discard    dgram  udp   wait  root  internal
#daytime    stream tcp   nowait root  internal
#daytime    dgram  udp   wait  root  internal
#chargen    stream tcp   nowait root  internal
#chargen    dgram  udp   wait  root  internal
#time  stream tcp   nowait root  internal
#time  dgram  udp   wait  root  internal
#
# These are standard services.
#
ftp   stream tcp   nowait root /usr/sbin/tcpd in.ftpd -l -a
#
# Pop and imap mail services et al
#
#pop-2  stream tcp   nowait root  /usr/sbin/tcpd ipop2d
#pop-3  stream tcp   nowait root  /usr/sbin/tcpd ipop3d
#imap  stream tcp   nowait root  /usr/sbin/tcpd imapd

Each line denotes a particular service that can be activated on your system. If a line in this file begins with a pound sign (#), it is disabled. Unless you are absolutely sure that you need a service, you can comment out any services that are currently enabled on your system. After making your changes, either reboot your system or reload the inetd configuration by finding the inetd process ID (ps ax | grep inetd), and then issuing the command kill -1 <inetd PID>.

If you've looked for the /etc/inetd.conf file and can't find one, you're probably running xinetd, an advanced replacement for the standard Internet daemon. Check the system for the presence of /etc/xinetd.conf. If it exists, open it.

service ntalk
{
    socket_type       = dgram
    wait          = yes
    user          = nobody
    group          = tty
    server         = /usr/sbin/in.ntalkd
}

Each of the xinetd services is configured in a block, as seen here. To disable a service, comment out the entire block, or add a line reading "disable=yes" to the block. Depending on your setup, your /etc/xinetd.conf file might include a line like this:

includedir /etc/xinetd.d

If you see such a line, xinetd will read the contents of that directory and look in each of the contained files for other service definitions. Typically a single service is defined for each file. To disable services on a system that uses this option, simply move the service files from the included directory (usually /etc/xinetd.d), or add the "disable=yes" line to the service file you want to incapacitate.

Runlevel Services

Runlevel services, rather than starting when requested, start when the system boots. These services are usually defined by creating a symbolic link between service start and stop files in /etc/rc.d/init.d and the runlevel directories /etc/rc.d/rc#.d, where the # varies between 0 and 6. (Unless you've modified your system, runlevel 3 is the standard text boot mode, whereas runlevel 5 is the graphical X Window startup.)

To view the services included on your system, list the /etc/rc.d/init.d directory:

[jray@bcdinc rc.d]$ ls /etc/rc.d/init.d/
anacron  functions keytable  network rawdevices single ypbind
apmd   gpm    killall  nfs   rhnsd    snmpd  yppasswdd
arpwatch halt    kudzu   nfslock rstatd   sshd  ypserv
atalk   httpd   linuxconf pcmcia  rusersd   syslog
atd    identd   lpd    portmap rwalld   webmin
crond   ipchains  named   pppoe  rwhod    xfs
dhcpd   kdcrotate netfs   random  sendmail  xinetd

To see which are running on your system, first determine the runlevel you're at. (Again, if you're in text mode, 3 is a good guess. If not, use 5.) Then list either the rc3.d (runlevel 3) or rc5.d (runlevel 5) directory:

[jray@bcdinc rc.d]$ ls /etc/rc.d/rc3.d
K00linuxconf K20rstatd   K60lpd   K87portmap  S40atd     S85gpm
K01kdcrotate K20rusersd  K65identd  K95kudzu   S50xinetd   S85httpd
K01pppoe   K20rwalld   K75netfs  K96pcmcia  S55named    S90crond
K03rhnsd   K20rwhod   K83ypbind  S08ipchains S55sshd    S91atalk
K05keytable  K34yppasswdd K84apmd   S10network  S56rawdevices S95anacron
K10xfs    K45arpwatch  K84ypserv  S12syslog  S65dhcpd    S99local
K20nfs    K50snmpd   K86nfslock S20random  S80sendmail  S99webmin

Files that are prefaced with a K are files used to safely shut down processes, whereas files with the S prefix are used to start files. The number preceding the service name determines the order in which services are started or stopped. To completely remove a service from the runlevel, just delete the links from the runlevel directory.

chkconfig

If you're more comfortable with a command-line tool, you can use chkconfig to show the what's in your current runlevel and to delete and add services. Additionally, chkconfig will also show the xinetd services enabled on your system. For example, to show the runlevel settings, type chkconfig --list:

[jray@bcdinc rc.d]$ chkconfig --list
anacron     0:off  1:off  2:on  3:on  4:on  5:on  6:off
httpd      0:off  1:off  2:off  3:on  4:on  5:on  6:off
apmd      0:off  1:off  2:on  3:off  4:on  5:on  6:off
syslog     0:off  1:off  2:on  3:on  4:on  5:on  6:off
crond      0:off  1:off  2:on  3:on  4:on  5:on  6:off
netfs      0:off  1:off  2:off  3:off  4:on  5:on  6:off
...
sendmail    0:off  1:off  2:on  3:on  4:on  5:on  6:off
snmpd      0:off  1:off  2:off  3:off  4:off  5:off  6:off
rhnsd      0:off  1:off  2:off  3:off  4:on  5:on  6:off
xinetd     0:off  1:off  2:off  3:on  4:on  5:on  6:off
ypbind     0:off  1:off  2:off  3:off  4:off  5:off  6:off
yppasswdd    0:off  1:off  2:off  3:off  4:off  5:off  6:off
ypserv     0:off  1:off  2:off  3:off  4:off  5:off  6:off
dhcpd      0:off  1:off  2:off  3:on  4:off  5:off  6:off
webmin     0:off  1:off  2:on  3:on  4:off  5:on  6:off
atalk      0:off  1:off  2:off  3:on  4:on  5:on  6:off
xinetd based services:
    imap:  on
    imaps: off
    ipop2: off
    ipop3: on
    pop3s: off

To delete a service from the runlevel or xinetd, use chkconfig --del <service name>. Similarly, you can add a service with chkconfig --add <service name>. This provides a clean interface to service management and is less prone to introducing errors into the system than editing the configuration files by hand.

Depending on your system, you might also have access to ntsysv, a Curses-based service editor. Users of KDE and GNOME also have runlevel editors built into their desktop systems. Personally, I find it easy to edit xinetd/inetd and runlevels manually.

If you plan to connect your machine to a network immediately upon installation, I highly recommend that you disable as many services as necessary before reading beyond this chapter. I've seen instances in which machines on open Internet connections have been hacked in less than an hour because they were not properly secured. Take your server's security seriously—it would be a shame if a hacker got to use your computer before you!

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.