1. TCP Wrapper
Wrap의 사전적 의미를 알고 있다면, 대충 짐작은 할 수 있을 것이다.
TCP접속은 인터넷에 있어 기본이다.
이 기본적인 connection은 인터넷상의 어느 누가 접속요청을 하건 무조건 그 접속을 받아들인다.
그래서 많이 알려진 TCP접속에 대해 Wrap을 씌워서 리눅스박스로 접근하는 불청객들의 접속요청을 거부하게 하는 것이 TCP Wrapper가 하는 일이다.
그러면, 무엇을 기준으로 접속을 제한하는 것일까?
Tcp Wrapper는 ip address로 접속제한을 하는 방식이다.
허가된 ip address로부터 오는 요청은 받아들이고, 허가되지 않은 ip address로부터의 접속요청은 거부한다.
그러므로 자신의 서버에 사용자들이 있는 경우엔, 적어도 telnet과 ftp 서비스에 대해선 이 기능을 사용할 수 없다.
(사용자들은 원격의 어느 곳에서나 들어올 수 있다.
그 각기 다른 모든 ip address에 대해 허가권을 설정할 수는 없는 노릇이다.)
보통 리눅스 상에 데몬(Daemon)(항시 메모리에 상주해있는 프로세스)으로 올라오지 않는 서비스들은 inet 에 의해서 외부에서 접속요청이 있을 때만, 메모리에 올라가게 되어있는데, inet 데몬에 의해 메모리에 해당서비스가 올라가기 전에,tcp wrapper가 해당 접속을 받아들일 것인지, 미리 설정된 리스트를 참조해 판단하게 된다.
우선 /etc/inetd.conf 화일을 한번 보자. 다음은 /etc/inetd.conf 파일의 일부이다.
# These are standard services.
#
#
# ALZZA Linux use proftpd instead of wu-ftpd
#
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd
#-l -a
telnet stream tcp nowait root /usr/sbin/tcpd 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/tcpd in.comsat
#talk dgram udp wait nobody.tty /usr/sbin/tcpd in.talkd
#ntalk dgram udp wait nobody.tty /usr/sbin/tcpd in.ntalkd
#dtalk stream tcp wait nobody.tty /usr/sbin/tcpd in.dtalkd
#
# Pop and imap mail services et al
#
#pop-2 stream tcp nowait root /usr/sbin/tcpd ipop2d
#pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d
#imap stream tcp nowait root /usr/sbin/tcpd imapd
#
# The Internet UUCP service.
#
#uucp stream tcp nowait uucp /usr/sbin/tcpd /usr/lib/uucp/uucico -l
#
# Tftp service is provided primarily for booting. Most sites
# run this only on machines acting as "boot servers." Do not uncomment
# this unless you *need* it.
#
#tftp dgram udp wait root /usr/sbin/tcpd in.tftpd
#bootps dgram udp wait root /usr/sbin/tcpd bootpd
#
# Finger, systat and netstat give out user information which may be
# valuable to potential "system crackers." Many sites choose to disable
# some or all of these services to improve security.
#
#finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd
#cfinger stream tcp nowait root /usr/sbin/tcpd in.cfingerd
#systat stream tcp nowait guest /usr/sbin/tcpd /bin/ps -auwwx
#netstat stream tcp nowait guest /usr/sbin/tcpd /bin/netstat -f inet
#
# Authentication
#
#auth stream tcp wait root /usr/sbin/in.identd in.identd -e -o
#
# End of inetd.conf
각 서비스를 실행하는 라인들을 보면, /usr/sbin/tcpd 와 함께, 해당
서비스들을 실행하는 것을 볼 수 있다.
여기서 /usr/sbin/tcpd 가 바로 tcp wrapper이다.
필자의 경우, 사용하지 않는 서비스들엔 모두 주석(#)을 달아 놓은 것을 볼 수 있다.
현재 요청이 있을 때, 응답을 할 수 있는 서비스는 telnet과 ftp뿐이다.
2. /etc/hosts.deny
이 파일에 적힌 주소들은 모두 거부된다.
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
in.telnetd: ALL <-- telnet으로 들어오는 모든 요청을 거부.
in.ftpd: ALL <-- ftp로 들어오는 모든 요청을 거부
in.identd: ALL
ALL: 203.235.27.98
ALL: 199.75.110.250
ALL: 195.199.104.109
ALL: 152.163.188.66
ALL: 202.110.2.111
ALL: 210.101.3.160
ALL: 211.46.144.3
ALL: 209.86.0.251
ALL: 211.44.25.38
ALL: 209.123.128.12
ALL: 147.6.80.146
ALL: 200.36.64.68
ALL: 212.186.187.66
ALL: 203.158.109.1
ALL: 207.142.42.12
ALL: 211.46.78.225
ALL: 24.0.198.183
ALL: 202.96.191.70
ALL: 63.225.64.167
ALL: 195.215.240.98
제한이 필요한 inet 서비스 명 : ip address 또는 ALL
이와 같은 형식으로 각 라인을 추가하면 되며, 모든 서비스에 대해 제한을 걸기 위해선,
ALL : ip address
형식으로 써주면 된다.
허가(allow), 거부(deny)에 대한 정책은 일반적으로, All Deny & allow 정책을 사용하면 된다.
즉, 위의 내용과 같이, 특별한 경우가 아니면, hosts.deny파일엔 ' 서비스 명:ALL' 형식으로 적어주어, 일단 모든 접속을 거부한 뒤, hosts.allow 파일에서 허가할 ip 주소를 명시해 주면 된다.
위에서, 'ALL:' 다음에 나와있는, ip address들은 과거, 필자의 서버에 이유 없는 포트스캔을 한 ip 주소들로, port scan detection 프로그램에게 발각되어, 프로그램에 의해 자동으로 등록된 것들이다.
일반적으론, hosts.deny파일엔 '서비스 명:ALL' 형식으로만 써주고, 나머지는 hosts.allow파일에서 결정한다.
3. /etc/hosts.allow
hosts.deny와 같은 형식으로 접속을 허가할 ip address들을 적어준다.
in.telnetd : 210.110.35.10
in.ftpd: 210.110.35.11
ALL: 210.110.35.12
hosts.deny 파일과 연결해서 해석해보면, '기본적으로 telnet접속에 대해선 모든 접속을 거부(deny)하고, 210.110.35.10 에 대해서만 허가한다.' 라는 의미가 된다.
마지막 라인은 '210.110.35.12 에 대해서는 모든 서비스에 대한 접속을 허가한다.' 라는 의미이다.
4. 장점 및 단점
일단 리눅스서버에 일반 user가 없는 경우엔, 사용을 적극 권한다. 하지만, telnet까지 TCP wrapper를 걸어두면, 관리자조차도 불편을 느낄 것이다.
(외부에서 telnet으로 접속할 일은 반드시 생긴다.) 일단 셋팅 해두면, wrapper에 쌓인 서비스들은 거의 100% 보호가 되는 장점이 있으나, 강력한 보안이 사용자의 편의성과는 반비례 관계에 있듯이, 어느 정도의 불편함은 감수해야 할 것이다.
Written and Edited by 임준형
[저작권]
이 글의 작성 및 편집자는 임준형 님(saster@hitel.net)이며 상업적인 목적이 아니라면 이 글을 원작자의 이름과 함께, 배포하는 것은 자유입니다.

운영자
01-06-02 10:40
0개
2,530회
최소한의 보안장치 TCP Wrapper설정법
댓글목록
등록된 댓글이 없습니다.