본문 바로가기
IT 실무/서버 관리

[리눅스] 슈퍼데몬 xinetd 정리

by 지식id 2018. 3. 9.
반응형

데몬에는 2가지 종류가 있다.

슈퍼데몬 방식(xinetd 방식), standalone 방식이 있다. standalone방식은 말 그대로 단독으로 메모리에 상주하고 있는 방식이다. 자주 사용되는 데몬이라면 문제가 없지만 어쩌다 한번 가끔 사용하는데 항상 메모리에 상주 하고 있는 것도 비효율적이다. 

그래서 슈퍼데몬이라는 것이 있는데, 슈퍼데몬이 메모리에 상주 해 있으면서 슈퍼데몬에서 관리하는 데몬이 호출 될 경우 그 데몬을 잠깐 올렸다가 처리가 끝나면 다시 종료시킨다. standalone보다는 느리겠지만 간혈적으로 사용되는 많은 데몬들을 효율적으로 운용할 수 있다.


xinetd


리눅스 커널 2.2 시절까진(아주 옛날엔) inetd를 사용하였다. 거기다 접근 제어 기능을 가진 TCP Wrapper를 같이 사용했다. 커널 버전 2.4 부턴 개선된 inetd에 TCP Wrapper의 접근 제어 기능까지 포함하여 xinetd 데몬이 사용된다.


xinetd = inetd + TCP Wrapper + α



구성

/etc/xinetd.conf

/etc/xinetd.d (디렉터리)

/etc/rc.d/init.d/xinetd (데몬)



xinetd.conf


#

# This is the master xinetd configuration file. Settings in the

# default section will be inherited by all service configurations

# unless explicitly overridden in the service configuration. See

# xinetd.conf in the man pages for a more detailed explanation of

# these attributes.


defaults

{

# The next two items are intended to be a quick access place to

# temporarily enable or disable services.

#

#       enabled         =

#       disabled        =


# Define general logging characteristics.

# xinetd.conf in the man pages for a more detailed explanation of

# these attributes.


defaults

{

# The next two items are intended to be a quick access place to

# temporarily enable or disable services.

#

#       enabled         =

#       disabled        =


# Define general logging characteristics.

        log_type        = SYSLOG daemon info

        log_on_failure  = HOST

        log_on_success  = PID HOST DURATION EXIT


# Define access restriction defaults

#

#       no_access       = 111.222.333.444 123.123.123.123/11

#       only_from       = 111.222.333.444 123.123.123.123/11

#       max_load        = 0

        cps             = 50 10

        instances       = 50

        per_source      = 10


# Address and networking defaults

#

#       bind            =

#       mdns            = yes

        v6only          = no


# setup environmental attributes

#

#       passenv         =

        groups          = yes

        umask           = 002


# Generally, banners are not used. This sets up their global defaults

#

#       banner          =

#       banner_fail     =

#       banner_success  =

}


includedir /etc/xinetd.d

▲ xinetd를 설치한 직후 /etc/xinetd.conf 파일


log_type = SYSLOG | FILE

# 로그파일을 rsyslog등 시스템 로그에서 관리되도록 위임하거나, 별도의 파일로 선택할 수 있다.


log_on_failure = HOST | USERID | ATTEMPT

# 접속에 실패했을 때 기록될 값을 정한다.


log_on_success = PID | HOST | USERID | EXIT | DURATION | TRAFFIC

# 접속에 성공했을 때 기록될 값


cps = [초당 요청수] [제한시간]

# 초당 요청수만큼을 초과할 경우 제한시간에 설정된 초만큼 접속을 중단시킨다.


instances = 최대 서버수

# 동시에 서비스할 수 있는 서버의 최대 서버 수를 지정한다.


per_source = 최대 접속수

# 같은 IP에서 접속할 수 있는 최대 서비스 수


only_form = 접속 가능한 호스트

no_access = 접속 불가능한 호스트

# only_form과 no_access가 중복되면 차단된다.


enabled = 사용 가능한 서비스 목록

disabled = 사용 불가능한 서비스 목록

# enabled과 disabled가 중복되면 차단된다.



/etc/xinetd.d


디렉터리 하위에 서비스 명으로 된 설정파일을 만들어 서비스별로 설정할 수 있다. 서비스명은 /etc/services 와 동일하게 맞추고 .conf 는 붙이지 않는다.


# cat /etc/xinetd/rsync


# default: off

# description: The rsync server is a good addition to an ftp server, as it \

# allows crc checksumming etc.

service rsync

{

disable = yes

flags = IPv6

socket_type     = stream

wait            = no

user            = root

server          = /usr/bin/rsync

server_args     = --daemon

log_on_failure  += USERID

}


socket_type : stream, dgram, raw값을지정할수있다.

user : 서비스를 사용할 사용자의 이름이다.

wait : yes는 단일 쓰레드, no는 다중 쓰레드로 동작한다.

server : 서비스가연결되었을때실행할프로그램이다.

이 외에도 xinetd.conf 상의 설정값들은 대부분 이용 가능하다. access_time, redirect, port, nice등의 설정도 가능하다.



TCP Wrapper


xinetd가 쓰인 후 inetd는 더이상 안 쓰이지만 TCP Wrapper는 여전히 사용된다.


/etc/hosts.deny

/etc/hosts.allow


를 참조 한다. 기본적으로 서비스를 다 막아두고 ssh, ftp등 주요 서비스를 특정 호스트에만 허용해 줄 수 있다.



반응형

댓글