inetd을 이용하여 서비스 데몬들을 관리할 때, 허용하지 않은 서비스로 누군가 접근을 시도할 경우 서버 계정의 메일로 그 내용을 받아볼 수 있도록 설정을 할 수 있습니다.

물론 이것을 응용하여 sms와 연동하면 실시간으로 문자 메세지를 받아볼 수 있으나, 단순한 포트 스캐닝의 경우에도 동작하기 때문에 불필요한 메세지를 받을 수도 있습니다.

/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!

ALL: ALL: spawn ( \
echo -e "\n\
TCP Wrappers\:  Connection Refused\n\
By\:                    $(uname -n)\n\
Process\:               %d (pid %p)\n\
User\:                  %u\n\
Host\:                  %c\n\
Date\:                  $(date)\n\
" | /bin/mail -s "From
tcpd@$(uname -n).  %u@%h -> %d." 메일을 받고자하는 계정명)

 저의 경우는 codememo 계정으로 메일을 받기 위해 다음과 같이 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!

ALL: ALL: spawn ( \
echo -e "\n\
TCP Wrappers\:  Connection Refused\n\
By\:                    $(uname -n)\n\
Process\:               %d (pid %p)\n\
User\:                  %u\n\
Host\:                  %c\n\
Date\:                  $(date)\n\
" | /bin/mail -s "From
tcpd@$(uname -n).  %u@%h -> %d." codememo)

 이렇게 작성하고나서 inetd를 재시작하여 주면, hosts.allow에서 허용하지 않은 IP나 혹은 서비스로 접속 시도가 있을 경우, 설정된 계정으로 메일이 옵니다.

+ Recent posts