Linux Network Administrator Manual (9)

Source: Internet
Author: User
Article title: Linux Network Administrator Manual (9 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Chapter 9 network applications
After successfully setting the IP address and parser, we will discuss the services you want to provide on the network. This chapter
The configuration of some simple network applications, including the inetd server and programs in the rlogin family. Network Files
The remote process call interfaces based on systems (NFS) and network information systems (NIS) will also be discussed in brief. However
NFS and NIS have too many configuration items, which are described in an independent chapter. Email and internet news (netnews)
Separate chapters will also be used for discussion.
Of course, we cannot discuss all network applications in this book. If you want to install one that is not discussed here
For example, talk, gopher, or Xmosaic, refer to their manual for details.
9.1 inetd super server)
Generally, the service is executed by the so-called daemons, the backend program {or port monitoring program. A port monitoring program is
Programs, which open a port and wait for the connection to enter. If a connection is established, it creates a sub-process.
To accept the connection, and the parent process continues to listen for more requests. This concept has a disadvantage, that is, for each
Service, you must run a port monitoring program that listens to a port connection, which usually means
Such a waste of system resources.
Therefore, almost all un x installers run a "super server", which creates sockets for many services and
Use select (2) to listen to all these ports at the same time. When a remote system requests a service
The server program that generates the port.
The commonly used super server is inetd, that is, Internet Daemon (Internet Port listener ). It is introduced in the system
Started at import, and obtains the list of services to be managed from the startup file named/etc/inetd. conf. Besides
In addition to the called server programs described above, there are many general services processed by inetd itself, called internal servers.
Service (internal services ). These include the chargen that generates strings and returns the da of the system date and time.
Ytime.
A row in this file is composed of the following fields:
Service type protocol wait user server internal line
The meaning of each field is as follows:
Service
The name of the service. By searching for the/etc/services file, the service name can be converted into a port number. This file
The description is provided in the services and protocols file section (Section 10.3.
Type
Specifies a socket type, or stream (for connection-based protocols) (for connection-oriented
Protocols) or dgram (for datagram-based protocols) (for datax protocols ). Therefore
TCP-based services always use stream, while UDP-based services always use dgram.
Protocol
The transmission protocol used by the naming service. This must be a valid protocol name found in the protocols file.
Provide explanations.
Wait
This option is only used for dgram sockets. It can be wait or nowait. If wait is specified
Inetd executes the server program only once at any time. Otherwise, after the specified server is executed, it will immediately
Listen on this port.
This is useful for reading all incoming data packets and then exiting the "single thread" server program. Many RP
C server programs are of this type, so they must be specified as wait. For the opposite type, multi-threaded servers
The program allows an infinite number of concurrent routines; this is rarely used. This type of server program must be specified as nowait. St
Ream socket should always use nowait.
User
This is the user's login id, and the user's process runs under it. This is usually a root user, but some services can use
The same account. The principle of least privilege is a good idea. it means that you should not have a privileged account.
Run a command. For example, the NNTP news server program
Services that run as news and may cause security risks (such as tftp or finger) often run as nobody
.
Server
The full path of the server program to be executed is provided. Internal Services are marked with the keyword internal.
Cmdline
This is the command line (parameter) that is passed to the server program ). This includes the parameter 0? Command name. Generally, this is a server program.
Name, unless a different name call is used, the program has different behaviors. This field is blank for internal services.
.
#
# Inetd services
Ftp stream tcp nowait root/usr/sbin/ftpd in. ftpd-l
Telnet stream tcp nowait root/usr/sbin/telnetd in. telnetd-B/etc/issue
# Finger stream tcp nowait bin/usr/sbin/fingerd in. fingerd
# Tftp dgram udp wait nobody/usr/sbin/tftpd in. tftpd
# Tftp dgram udp wait nobody/usr/sbin/tftpd in. tftpd/boot/diskless
Login stream tcp nowait root/usr/sbin/rlogind in. rlogind
Shell stream tcp nowait root/usr/sbin/rshd in. rshd
Exec stream tcp nowait root/usr/sbin/rexmcm in. rexmcm
#
# Inetd internal services
#
Daytime stream tcp nowait root internal
Daytime dgram udp nowait root internal
Time stream tcp nowait root internal
Time dgram udp nowait root internal
Echo stream tcp nowait root internal
Echo dgram udp nowait root internal
Discard stream tcp nowait root internal
Discard dgram udp nowait root internal
Chargen stream tcp nowait root internal
Chargen dgram udp nowait root internal
Figure 9.1 shows a/etc/inetd. conf sample file.
Figure 9.1 shows a sample file of inetd. conf. The finger service is commented out, so this service does not exist.
. This is usually for security reasons because it may be used by intruders to obtain the user name on your system.
Tftp is also commented out. Tftp implements the original File Transfer Protocol (Primitive File Transfer Protocol)
It allows you to transmit any readable files directly from your system without password checks. For the/etc/passwd file
This is especially harmful. you can leave it blank when you do not use the shadow password file.
TFTP is usually used to download code from a boot server for diskless customers and X terminals. If you need to run
For line tftpd, add the directory names on the command line of tftpd to restrict their scope to the client to obtain files.
. See the second tftp line in the example.
9.2 tcpd access control tool
Because opening a computer to access networks involves many security risks, applications are designed to be defensive.
Several types of attacks. However, some of these defenses may be flawed (the most thorough example is the RTM Internet worm
), Or do not distinguish the security host of the specific service that the request can be accepted from the unreliable host that the request will be rejected. Upper
We have briefly discussed finger and tftp services. Therefore, people want to restrict these services to only "trusted owners ".
But the general settings are impossible. for these services, inetd is either provided to all customers.
Or one customer is not available.
To achieve this, a useful tool is tcpd. [1] is the so-called port Monitor Package (daemon wra)
Upper ). For TCP services that you want to monitor and protect, this tcpd will be called instead of the server program. Tcpd logs requests
Log to the syslog background program, check whether the remote host allows the service, and run
Real server programs. Note that this does not work for UDP-based services.
For example, to wrap finger daemon, you must change the corresponding line in indetd. conf
# Wrap finger daemon
Finger stream tcp nowait root/usr/sbin/tcpd in. fingerd
No access control is added, which will be displayed to the customer like the common finger settings. all requests
Logs to the syslog auth facility.
Access control is implemented through two files:/etc/hosts. allow and/etc/hosts. deny. They contain
Specifies the entries that allow and deny access to the service and host. When tcpd processes a server from a client host named biff.foobar.com
For example, in the finger service request, it will put the hosts. allow and hosts. deny (in this order) files
Scan the entries that match the service and host. If a matched entry is found in hosts. allow, access is allowed instead
Manage any entries in hosts. deny. If a matched entry is found in hosts. deny, the request is closed
The connection is rejected. If no matched entries are found, access is allowed.
The entries in the access file look like this:
Servicelist: hostlist [: shellcmd]
Servicelist is a list of service names in/etc/services, or the keyword "ALL. To match
When finger and tftp are used for ALL services, "ALL privileges T finger, tftp" is used ".
Hostlist is a list of host names or IP addresses, or the keyword "ALL", "LOCAL", or "UNKNOWN. ALL matches any
Host, while the LOCAL match does not include a host name. [2] UNKNOWN matches any host whose name or address query fails.
. A host whose name starts with a vertex matches the host whose domain name is equal to this name. For example, .foobar.com and biff. foobar
. Com matches. There are also rules for IP address and subnet number. For more information, see the hosts_access (5) manual page.
  
Except for the local host, to restrict all hosts to access the finger and tftp services, add the following line to/etc.
In the/hosts. deny file, and the/etc/hosts. allow file is empty:
In. tftpd, in. fingerd: ALL records t local,. your. domain
The optional shellcmd field can contain a shell command, which is called when the entries match. This enables the app
The traps exposed by intruders are useful:
In. ftpd: ALL records t local, .vbrew.com :\
Echo "request from % d @ % h">/var/log/finger. log ;\
If [% h! = "Vlager.vbrew.com"]; then \
Finger-l @ % h>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.