At this point, you should understand clearly how hostnames are resolved using DNS and how IP numbers are resolved into MAC addresses using ARP. There is one last level of detail which we now need to address: precisely how the remote host handles the incoming connection.
What are ports and the /etc/services file? In TCP/IP, ports are numbers assigned to specific TCP/IP services. For example, telnet uses port 23. Port numbers less than 1024 are assigned by the IETF (Internet Engineering Task Force, an international body which oversees technical developments in the internet) and are accessible only to root.
When you typed telnet lnxed1.ucs.indiana.edu, a program sitting on
your local disk called /bin/telnet got run. Since this program uses
the TCP/IP telnet protocol, it tries to connect to port 23 at the remote end.
The /etc/services file provides the mapping from port numbers to service
names. It is consulted by inetd (described below) at the remote end to
determine which service needs to be started when an incoming connection tickles
port 23.
Let's take a look at a typical services file: #
# Network services, Internet style
#
tcpmux 1/tcp
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp-data 20/tcp
ftp 21/tcp
telnet 23/tcp
ktelnet 1023/tcp #Added by AS 5/5/98
smtp 25/tcp mail
time 37/tcp timserver
time 37/udp timserver
name 42/udp nameserver
whois 43/tcp nicname # usually to sri-nic
.
.
.
As you can see, port 23 in /etc/sevices points to the service name
called "telnet".
Armed with the service name, the internet superdaemon inetd (described
below) uses its config file /etc/inetd.conf to figure out precisely
what action needs to be taken for a given service in /etc/services.
inetd, the internet superdaemon: One of the processes started at boot time by init is inetd. inetd is a long running daemon (meaning it stays running while the machine is up) and keeps a close watch for incoming network connections. When it senses incoming, it
# # Configuration file for inetd(1M). See inetd.conf(4). # # To re-configure the running inetd process, edit this file, then # send the inetd process a SIGHUP. # # Syntax for socket-based Internet services: #In our example, the service name was telnet. inetd.conf shows us that /usr/sbin/in.telnetd process will be fired up to handle this specific telnet request. in.telnetd daemon then provides login services, etc. to allow a log in.# # Ftp and telnet are standard Internet services. # ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd # # Shell, login, exec, comsat and talk are BSD protocols. # shell stream tcp nowait root /usr/sbin/tcpd in.rshd login stream tcp nowait root /usr/sbin/tcpd in.rlogind exec stream tcp nowait root /usr/sbin/tcpd in.rexecd comsat dgram udp wait root /usr/sbin/in.comsat in.comsat talk dgram udp wait root /usr/sbin/in.talkd in.talkd . . .
Whenever you make changes to the /etc/inetd.conf file, you must send a HANGUP signal to inetd to activate the changes.