tcp_wrapper 설치 및 사용법
작성자 정보
- 웹관리자 작성
- 작성일
컨텐츠 정보
- 7,629 조회
- 0 추천
- 목록
본문
TCP wrapper 개론
일반적으로 많이 알려진 도구이다. 이 소프트웨어를 설치하여도 기존의 네트워킹 소프트웨어에는 영향이 없다.
inetd에 대한 이해가 있어야만 이 도구를 완벽하게 이해하고 운용할 수 있을 것이다. 이 도구를 구성하고 있는 것은 다음과 같다.
/etc/inetd.conf
/usr/sbin/inetd
/etc/syslog.conf
/usr/sbin/tcpd
/etc/hosts.allow
/etc/hosts.deny
/var/log/secure
일반적으로 inetd라는 인터넷수퍼데몬이 떠 있을 때 외부에서 /etc/inetd.conf에 등록되어 있는 서비스의 호출이 있었다고 한다면 서비스가 이루어지는 절차는 다음과 같다고 할 수 있다. (telnet의 경우)
① 외부에서 telnet 서비스의 요청이 들어온다.
② inetd데몬이 /etc/inetd.conf에 등록되어 있는 telnet 프로그램을 호출한다.
예) telnet stream tcp nowait root /usr/sbin/telnetd telnetd
③ 외부의 telnet 요청과 내부프로그램(/usr/sbin/telnetd)를 연결시켜 서비스요청에
대한 처리를 해주게 된다.
하지만 TCP_Wrapper를 설치하여 tcpd를 운용할 경우에는 위의 순서와는 조금
다른 절차를 통해서 실행된다. 우선 tcpd가 설치가 되면 /etc/inetd.conf의 모양이
조금 바뀌게 되는데 예를 들어보면 다음과 같다.
telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
① 외부에서 telnet 서비스의 요청이 들어온다.
② inetd 데몬은 외부에서 요청된 서비스를 tcpd에 넘겨준다.
③ tcpd는 /etc/hosts.allow를 먼저 검사하여 허가된 접속인지를 체크한다.
④ ③에서 허가되지 않은 요청일 경우에는 /etc/hosts.deny를 검사하여 거부된 요청일 경우에는
이 요청을 최종적으로 거부하게 된다.
⑤ ③과 ④에서 검사하여 허가된 요청일 경우에는 /etc/syslog.conf 에 설정되어
있는 /var/log/secure 파일에 접속요청에 대한 정보를 기록하 in.telnetd를
호출하여 서비스를 제공하게 된다.
Tcp_Wrapper 설치하기
1. 소스구하기
ftp://ftp.cert.org/pub/tools/tcp_wrappers_7.6.tar.gz
ftp://ftp.uu.net/pub/security/tcp_wrappers_7.6.tar.gz
ftp://ftp.cert-kr.or.kr/pub/Security/tool/tcp_wrappers/tcp_wrappers_7_2_tar.gz
Tcp_Wrapper 설치하기
2. 압축해제하기
[/home/sspark:@sms #] ls -l
-rw-r--r-- 1 sspark other 99459 5월 25일 16:49 tcp_wrappers_7.6.tar.gz
[/home/sspark:@sms #]
[/home/sspark:@sms #] gunzip tcp_wrappers_7.6.tar.gz
[/home/sspark:@sms #]
[/home/sspark:@sms #] ls -l
-rw-r--r-- 1 sspark other 360448 5월 25일 16:49 tcp_wrappers_7.6.tar
[/home/sspark:@sms #]
[/home/sspark:@sms #] tar xvfp tcp_wrappers_7.6.tar
x tcp_wrappers_7.6, 0 bytes, 0 테이프 블럭
x tcp_wrappers_7.6/README, 48215 bytes, 95 테이프 블럭
x tcp_wrappers_7.6/miscd.c, 3139 bytes, 7 테이프 블럭
.......
[/home/sspark:@sms #] cd tcp_wrappers_7.6
Tcp_Wrapper 설치하기
3. Tcp_Wrapper에 대한 정보획득을 위해 README파일을 읽어본다.(vi README, cat README)
4. 컴파일하기(make)
아래의 예와 같이 그냥 “make”라고 하면 에러가 발생할 것이다.
[/home/sspark/tcp_wrappers_7.6:@sms #] make
Usage: edit the REAL_DAEMON_DIR definition in the Makefile then:
make sys-type
If you are in a hurry you can try instead:
make REAL_DAEMON_DIR=/foo/bar sys-type
And for a version with language extensions enabled:
make REAL_DAEMON_DIR=/foo/bar STYLE=-DPROCESS_OPTIONS sys-type
This Makefile knows about the following sys-types:
generic (most bsd-ish systems with sys5 compatibility)
386bsd aix alpha apollo bsdos convex-ultranet dell-gcc dgux dgux543
dynix epix esix freebsd hpux irix4 irix5 irix6 isc iunix
linux machten mips(untested) ncrsvr4 netbsd next osf power_unix_211
ptx-2.x ptx-generic pyramid sco sco-nis sco-od2 sco-os5 sinix sunos4
sunos40 sunos5 sysv4 tandem ultrix unicos7 unicos8 unixware1 unixware2
uts215 uxp
If none of these match your environment, edit the system
dependencies sections in the Makefile and do a 'make other'.
tcp_wrapper는 시스템사양과 OS등이 맞아야만이 정상적으로 작동되기 때문에 OS와 플래폼에 따라서 그 컴파일옵션이 모두 다르다.
따라서 위의 에러는 컴파일옵션이 확실히 지정되지 않아서 발생하는 에러이며, 위의 안내대로 다음과 같이 컴파일 옵션을 주어서 컴파일하면 될 것이다.
Tcp_wrapper를 컴파일하는 방법에는 두가지가 있다.
첫번째는 Makefile을 조금 수정해서 “make”로 컴파일하는 방법이 있고, 두번째로는 Makefile을 수정하지 않고 수정사항에 대한 옵션을 컴파일시에 주는 것이다.
여기서는 실제로 많이 사용되고 있는 방법인 두번째 방법으로 컴파일을 해볼 것이며, 첫번째 방법으로 컴파일하시는 분들은 Makefile을 열어서 사용하고 있는 운영체제에 맞는 REAL_DAEMON_DIR 과 STYLE을 선택해주면 된다.
두번째 방법으로 컴파일하려면 다음과 같이 REAL_DAEMON_DIR 과 STYLE을 make와 함께 옵션으로 주면된다.
컴파일 명령어의 형식은 다음과 같다.
형식 : # make REAL_DAEMON_DIR=/foo/bar STYLE=-DPROCESS_OPTIONS sys-type
설치되는 서버에 따라서 위의 옵션이 달라질 수 있다.
[/home/sspark/tcp_wrappers_7.6:@sms #]
[/home/sspark/tcp_wrappers_7.6:@sms #] make REAL_DAEMON_DIR=/usr/sbin sunos5
cc -O -DFACILITY=LOG_MAIL -DHOSTS_ACCESS -DPARANOID -DNETGROUP -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK -DSOLARIS_24_GETHOSTBYNAME_BUG -DDAEMON_UMASK=022 -DREAL_DAEMON_DIR="/usr/sbin" -DSEVERITY=LOG_INFO -DRFC931_TIMEOUT=10 -DHOSTS_DENY="/etc/hosts.deny" -DHOSTS_ALLOW="/etc/hosts.allow"
...............
5. 컴파일후의 결과확인
컴파일이 정상적으로 끝이 났다면 다음과 같은 5개의 실행파일들이 생성된다.
tcpd : 메인데몬
tcpdchk : 설정체크프로그램
tcpdmatch : 체크 프로그램
try-from : 호스트와 유저 체크
safe_finger : finger 체크
아래는 위의 데몬들에 대한 설명의 원문을 실어놓은 것이다.
You can use the `tcpdchk' program to identify the most common problems
in your wrapper and inetd configuration files.
With the `tcpdmatch' program you can examine how the wrapper would
react to specific requests for service.
The `try-from' program tests the host and username lookup code. Run it
from a remote shell command (`rsh host /some/where/try-from') and it
should be able to figure out from what system it is being called.
The `safe_finger‘ command should be used when you implement a booby
trap: it gives better protection against nasty stuff that remote hosts
may do in response to your finger probes.
The tcpd program can be used to monitor the telnet, finger, ftp, exec,
rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
a one-to-one mapping onto executable files.
6. 인스톨하기
인스톨프로그램이 없기 때문에 위의 실행파일들을 모두 직접 적절한 위치에 복사를 해야한다.
[/home/sspark/tcp_wrappers_7.6:@sms #]
[/home/sspark/tcp_wrappers_7.6:@sms #] cp tcpd tcpdchk tcpdmatch try-from safe_finger /usr/sbin
[/home/sspark/tcp_wrappers_7.6:@sms #]
이번에는 tcp_wrapper와 관련된 매뉴얼을 복사해 줘야한다. 아래와 같이 복사하고 난 후에는 시스템에서 tcp_wrapper와 관련된 도움말을 보고자 할때에는 “man tcpd”와 같은 형식으로 사용할 수가 있다.
[/home/sspark/tcp_wrappers_7.6:@sms #] cp *.3 /usr/local/man/man3
[/home/sspark/tcp_wrappers_7.6:@sms #] cp *.5 /usr/local/man/man5
[/home/sspark/tcp_wrappers_7.6:@sms #] cp *.8 /usr/local/man/man8
매뉴얼파일을 복사한 후에 복사되었는가를 확인해 본 것이다.
[/home/sspark/tcp_wrappers_7.6:@sms #]
[/home/sspark/tcp_wrappers_7.6:@sms #] ls -l /usr/local/man/man3
-r--r--r-- 1 root other 3602 5월 30일 13:54 /usr/local/man/man3
[/home/sspark/tcp_wrappers_7.6:@sms #]
[/home/sspark/tcp_wrappers_7.6:@sms #]
[/home/sspark/tcp_wrappers_7.6:@sms #] ls -l /usr/local/man/man5
total 44
-r--r--r-- 1 root other 15225 5월 30일 13:56 hosts_access.5
-r--r--r-- 1 root other 6655 5월 30일 13:56 hosts_options.5
[/home/sspark/tcp_wrappers_7.6:@sms #]
[/home/sspark/tcp_wrappers_7.6:@sms #] ls -l /usr/local/man/man8
total 28
-r--r--r-- 1 root other 7022 5월 30일 13:56 tcpd.8
-r--r--r-- 1 root other 2570 5월 30일 13:56 tcpdchk.8
-r--r--r-- 1 root other 3252 5월 30일 13:56 tcpdmatch.8
[/home/sspark/tcp_wrappers_7.6:@sms #]
7. /etc/inetd.conf 파일수정하기
/etc/inetd.conf 파일은 인터넷수퍼데몬이라는 tcpd의 환경설정파일 즉, tcpd 컨트롤파일이라고 할수 있다.
이 파일에는 인터넷서비스를 위한 각종 데몬들의 실행위치 및 옵션들이 설정되어 있으며 이제 우리는 원하는 인터넷서비스(예, telnet, ftp, pop등)에 tcp_wrapper를 적용하기 위해서 다음과 같은 셋팅을 해야한다.
아래는 ftp와 telnet의 설정사항만을 보여준 것이다.
/etc/inetd.conf파일을 vi로 열어서 아래와 같이 고쳐주면된다.
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
만약, 다른서비스들도 tcp_wrapper를 적용하여 서비스되길 원한다면 그 예를 아래에 보인다.
ftp stream tcp nowait root /usr/sbin/tcpd ftpd
telnet stream tcp nowait root /usr/sbin/tcpd ftpd
tftp dgram udp wait nobody /usr/sbin/tcpd tftpd -n
finger stream tcp nowait nobody /usr/sbin/tcpd fingerd
exec stream tcp nowait root /usr/sbin/tcpd rexecd
login stream tcp nowait root /usr/sbin/tcpd rlogind
shell stream tcp nowait root /usr/sbin/tcpd rshd
talk dgram udp wait root /usr/sbin/tcpd talkd
ntalk dgram udp wait root /usr/sbin/tcpd talkd
8. /etc/hosts.allow 와/etc/hosts.deny 파일설정하기
위의 두 파일은 tcp_wrapper의 엑세스컨트롤규칙을 정하는 파일이라고 할수 있다. Tcp_wrapper는 일종의 방화벽역할을 한다.
즉, 서버에 접근할수 있는 서비스(ftp, telnet, pop등)와 접근을 허용할 IP Address(A, B, C Class로 설정가능)를 설정할수 있기 때문이다.
먼저 /etc/hosts.allow 파일은 접근허용할 범위(IP Address)를 설정하고, /etc/hosts.deny 파일은 접근을 허용하지않을 범위(IP Address)를 설정한다.
가장 일반적으로 사용하는 정책은 hosts.deny 파일을 ALL:ALL로 설정하여 모든 호스트로부터의 접근을 제한한 다음 hosts.allow파일에서 접근을 허용할 호스트를 설정하는 것이다.
이런 설정은 어떤회사의 회사사원이나 또는 특정부서 또는 특정관리자만
관련자료
-
이전
-
다음