Client/Server in UNIX
首頁

Client & Server in UNIX

 

 

bulletWhat is  a server
 
bullet

A server is a services proviser and is  always listening and waiting to provide service in according to the service request from remote sites.
 

bullet

From O.S. point of view, server is a special program which always running on the background. In UNIX system, we call such program a daemon.
 

bullet

UNIX中的 network server程式係以daemon的形式存在,該由何server program提供服務取決於service request中的port number及protocol number.
 

bullet

UNIX中常見的Server 程式:

sendmail : SMTP server

httpd : Web Server

mountd & nfsd : NFS Server

inetd : TCP/IP Network super daemon 

 

bullet

UNIX TCP/IP Super Daemon -- inetd

bullet

A super daemon which manages other nework daemons.

bullet

Used to improve UNIX network client/server performance.

bullet

Manages other network daemons by its configuration file /etc/inetd.conf

bullet

User-developed network services can also be installed as inetd clients.

bullet

inetdBSD引進的觀念,BSD 4.3版以前,個別network service均以獨立的 daemon方式存在;因此如果一個伺服器提供10service,就必須至少啟動10個以上的daemon,以應付隨時到來的service request。這衍生了效率與管理的問題,尤其當network service種類快速的增加及user自行開發network program風氣大開的網路時代,這種運作方式更顯得捉襟見肘。

bullet

BSD 4.4開始,inetd成為大多數network server deamon(ftptelnetrshtalk ?)的代言人,inet會根據/etc/inetd.confservice port定義,在Service request到來時,叫起適當的program以提供必要的service.

bullet

經過適當的定義,使用者自行開發的client/server程式,也可以被整合至inetd中,以整體且有效率的方式提供服務。

bullet

How /etc/inetd works - An Eample


 

bullet

Ientd must ne restarted when any of the configuration files(/etc/inetd.conf, /etc/services & /etc/protocols) updated

bullet

定義inetd運作方式的的兩個設定檔: /etc/services  &  /etc/inetd

bullet

/etc/services --> 定義network services(protocol) name與tcp (transport layer) port number的對應關係。

An Example of /etc/services:
...
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp-data 20/tcp
ftp  21/tcp
fsp 21/udp fspd
ssh  22/tcp  # SSH Remote Login Protocol
ssh   22/udp # SSH Remote Login Protocol
telnet  23/tcp
# 24 - private
smtp   25/tcp mail
# 26 - unassigned
time   37/tcp timserver
time   37/udp timserver
rlp    39/udp resource # resource location
nameserver   42/tcp name  # IEN 116
whois   43/tcp nicname
re-mail-ck   50/tcp # Remote Mail Checking Protocol
re-mail-ck   50/udp # Remote Mail Checking Protocol
domain    53/tcp nameserver # name-domain server
domain   53/udp nameserver
mtp   57/tcp # deprecated
...

### Note that it is presently the policy of IANA to assign a single well-known port number ### for both TCP and UDP; hence, most entries here have two entries even if the protocol ### doesn't support UDP operations.


bullet

/etc/inetd.conf --> 定義network services(protocol) 特性與其相關應用程式啟動方式。一個service daemon被 inetd 叫起前,設定檔參考順序是:/etc/services --> /etc/inetd.conf。因此disable一個services,理論上可以在這兩個檔的任一個中,編輯其相關設定;不過習慣上,我們通常會修改/etc/inetd.conf。

 

An Example of /etc/inetd.conf
#echo  stream  tcp  nowait  root  internal
#echo  dgram  udp  wait  root  internal
#echo  dgram  udp  wait  root  internal
#discard  stream  tcp  nowait  root  internal
#discard  stream  tcp  nowait  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
telnet stream  tcp  nowait  root  /usr/sbin/tcpd in.telnetd
#
shell  stream  tcp  nowait  root  /usr/sbin/tcpd in.rshd
login  stream  tcp  nowait  root  /usr/sbin/tcpd in.rlogind
syslog  dgram  udp  wait  root  /usr/sbin/tcpd  syslogd  -m 0
...