[qmail] ucspi-tcp 설치
ITWeb/서버관리 2012. 5. 9. 11:51[원본링크]
http://cr.yp.to/ucspi-tcp.html
http://cr.yp.to/ucspi-tcp/install.html
http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
[원본글]
TCP/IP
ucspi-tcp
How to install ucspi-tcpUpgrading from previous versions of ucspi-tcp
The tcpserver program
The tcprules program
The tcprulescheck program
The argv0 program
The fixcrio program
The recordio program
The rblsmtpd program
The tcpclient program
The who@ program
The date@ program
The finger@ program
The http@ program
The tcpcat program
The mconnect program
The addcr and delcr programs
What is it?
tcpserver and tcpclient are easy-to-use command-line tools for building TCP client-server applications.tcpserver waits for incoming connections and, for each connection, runs a program of your choice. Your program receives environment variables showing the local and remote host names, IP addresses, and port numbers.
tcpserver offers a concurrency limit to protect you from running out of processes and memory. When you are handling 40 (by default) simultaneous connections, tcpserver smoothly defers acceptance of new connections.
tcpserver also provides TCP access control features, similar to tcp-wrappers/tcpd's hosts.allow but much faster. Its access control rules are compiled into a hashed format with cdb, so it can easily deal with thousands of different hosts.
This package includes a recordio tool that monitors all the input and output of a server.
tcpclient makes a TCP connection and runs a program of your choice. It sets up the same environment variables as tcpserver.
This package includes several sample clients built on top of tcpclient: who@, date@, finger@, http@, tcpcat, and mconnect.
tcpserver and tcpclient conform to UCSPI, the UNIX Client-Server Program Interface, using the TCP protocol. UCSPI tools are available for several different networks.
Other command-line TCP tools
The current ucspi-tcp interface is a refinement of the tcpserver/tcpclient interface in my 1991 clientserver package, which replaced the attachport/authtcp interface in my 1989 auth package.ucspi-tcp now competes with several other programs:
- inetd, a root-only TCP server supplied by all UNIX vendors;
- xinetd, a replacement for inetd;
- the mconnect client supplied as part of SunOS;
- the socket program;
- faucet and hose, part of the netpipes package; and
- the netcat program, which also supports UDP.
Many sites are replacing inetd with tcpserver, for several reasons:
- inetd is unreliable under high loads. It cuts off service for 10 minutes if it receives ``too many'' connections in 1 minute.
- inetd does not provide effective resource management. It will happily use up all your memory if you are running a popular service.
- inetd has trouble with sudden bursts of activity. Its listen() backlog is typically only 5 or 10 and cannot be raised.
TCP/IP
ucspi-tcp
How to install ucspi-tcp
Like any other piece of software (and information generally), ucspi-tcp comes with NO WARRANTY.System requirements
ucspi-tcp works only under UNIX.Installation
Download the ucspi-tcp package. The latest published ucspi-tcp package is ucspi-tcp-0.88.tar.gz.Unpack the ucspi-tcp package:
gunzip ucspi-tcp-0.88.tar tar -xf ucspi-tcp-0.88.tar cd ucspi-tcp-0.88
Compile the ucspi-tcp programs:
make
As root, install the ucspi-tcp programs under /usr/local:
make setup check
To report success:
( echo 'First M. Last'; cat `cat SYSDEPS` ) \ | mail djb-sysdeps@cr.yp.to
Replace First M. Last with your name.
========================================================================================
메일을 전달하기 위해서 메일 클라이언트(접속을 시도하는 프로그램이
메일 클라이언트이든, 다른 메일 서버이든, 클라이언트라고 하겠습니다.)가
는 일단 qmail 이 돌아가고 있는 서버의 25번 포트로 접속을 합니다.
그러면, 서버의 tcpserver 가 그 요청을 받습니다.
그리고 tcpserver 는 /etc/tcp.smtp 파일을 체크해서
(정확히는 /etc/tcp.smtp.cdb 입니다) 접속을 해 온
클라이언트의 ip 주소를 체크합니다.
만약, ip 주소가 /etc/tcp.smtp 에서 allow 로 되어 있는 ip 주소라면,
릴레이를 허용합니다.
(해당 엔트리에 RELAYCLIENT 옵션이 있다면,
/var/qmail/control/rcpthosts 파일도 무시합니다.)
그리고, tcpserver 는 qmail-smtpd 에게 연결을 넘겨줍니다.
qmail-smtpd 는 접속해 들어온 클라이언트와
helo servername.domain.com
으로 인사(?)를 나눕니다.
그리고,
mail from:id@domain.com
rcpt to:id@destdomain.com
message..
등의 일반적인 smtp 처리를 합니다.
그런데,
rcpt to:
명령(?)이 클라이언트로부터 들어오게 되면,
만약 /var/qmail/control/rcpthosts 파일을 참조합니다.
(클라이언트의 ip 가 /etc/tcp.smtp 파일에서 RELAYCLIENT 옵션을 주지
않은 ip 일 경우)
그리고, rcpt to: 뒤의 메일을 받을 사람의 도메인 네임(서버 이름)을
/var/qmail/control/rcpthosts 파일을 검색해서 찾을 수 없다면,
sorry, 릴레이를 허용하지 않습니다....
류의 메세지를 클라이언트에게 보내주고, 해당 메일을 전송해 주지 않습니다.
그러나, /etc/tcp.smtp 에서 allow 로 되어 있고, RELAYCLIENT 옵션을 부여한
ip 를 가진 클라이언트에서 25 번 포트로 접속해 들어오면,
qmail-smtpd 는 /var/qmail/control/rcpthosts 파일을 체크하지 않고,
rcpt to: 가 지정하는 도메인(메일주소)으로 메일을 보내(릴레이 하여)줍니다.
아웃룩, balsa 등의 메일 클라이언트를 이용하여 메일을 보낼때에도
이와 똑같은 일이 일어납니다.
메일 클라이언트는 지정된 메일 서버의 25번 포트로 접속해 들어가서,
메일을 보냅니다.
따라서, /etc/tcp.smtp 파일에, (회사내에서) 메일 클라이언트를 사용하는
사용자들의 ip 주소를 모두 적어주어야 아웃록 등의 클라이언트에서
메일을 보내 줄 수 있습니다.
그리고, /etc/tcp.smtp 파일을 갱신했다면,
tcprules 를 이용해서 반드시 /etc/tcp.smtp.cdb 도 갱신해 주어야
한다는 것을 잊지 않도록 합니다.
설정 파일들의 형식(문법)에 대한 자세한 것들은
기존의 문서를 참조하면 쉽게 알 수 있습니다.
전 단지, qmail 서버에 접속 요청이 들어왔을 때
서버가 어떻게 작동하는지에 대해 설명했을 따름입니다.
(제대로 맞게 했는지 불안하지만.. -_-a)