Internet superserver Daemon(inetd)

Internet superserver Daemon(inetd)は、インターネット経由のサービスを 処理するデーモンである。inetdが必要なときに必要なサービス用のプログラ ムを起動するので、それぞれのサービス用のデーモンを起動しておく必要は ない。つまり、インターネットからのサービスの受け付け係と言った ところでしょう。
また、利用するホストを受け付けで制限できるという利点もあります。

もどる
関連ファイル
/etc/inetd.conf設定用ファイル
/etc/hosts.deny禁止するホストを書く
/etc/hosts.allow有効にするホストを書く
/etc/servicesinetdが参照しサービスを決定するために利用する。
/etc/protcolsinetdが参照しサービスを決定するために利用する。(多分)

設定ファイル(inetd.conf)
基本的には以下のように設定する。

# <service_name> <sock_type> <proto> <flags><user> <server_path> <args>
	
例えばtelnetを設定する場合は、
telnet	stream  tcp 	nowait  root    /usr/sbin/tcpd	in.telnetd
	
のように設定する。以下に僕が現在使っている/etc/inetd.confを示します。
#
# inetd.conf	This file describes the services that will be available
#		through the INETD TCP/IP super server.  To re-configure
#		the running INETD process, edit this file, then send the
#		INETD process a SIGHUP signal.
#
# Version:	@(#)/etc/inetd.conf	3.10	05/27/93
#
# Authors:	Original taken from BSD UNIX 4.3/TAHOE.
#		Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
#
# Modified for Debian Linux by Ian A. Murdock <imurdock@shell.portal.com>
#
# Modified for RHS Linux by Marc Ewing <marc@redhat.com>
#
# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>
#
# Echo, discard, daytime, and chargen are used primarily for testing.
#
# To re-read this file after changes, just do a 'killall -HUP inetd'
#
#echo	stream	tcp	nowait	root	internal
#echo	dgram	udp	wait	root	internal
#discard	stream	tcp	nowait	root	internal
#discard	dgram	udp	wait	root	internal
#daytime	stream	tcp	nowait	root	internal
#daytime	dgram	udp	wait	root	internal
#chargen	stream	tcp	nowait	root	internal
#chargen	dgram	udp	wait	root	internal
#
# These are standard services.
#
#ftp	stream	tcp	nowait	root	/usr/sbin/tcpd	in.ftpd -l -a
ftp	stream	tcp	nowait	root	/usr/sbin/tcpd	in.proftpd -l -a
telnet	stream  tcp 	nowait  root    /usr/sbin/tcpd	in.telnetd
#gopher	stream  tcp 	nowait  root    /usr/sbin/tcpd	gn

# do not uncomment smtp unless you *really* know what you are doing.
# smtp is handled by the sendmail daemon now, not smtpd.  It does NOT
# run from here, it is started at boot time from /etc/rc.d/rc#.d.
#smtp	stream	tcp	nowait	root	/usr/sbin/tcpd	sendmail
#nntp	stream	tcp	nowait	root	/usr/sbin/tcpd	in.nntpd
#
# 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
#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	in.qpopper
#pop-3   stream  tcp     nowait  root    /usr/sbin/tcpd	in.qpopper
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	root	/usr/sbin/tcpd	in.fingerd -u
#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
#
# Time service is used for clock syncronization.
#
#time	stream	tcp	nowait	nobody	/usr/sbin/tcpd	in.timed
#time	dgram	udp	wait	nobody	/usr/sbin/tcpd	in.timed
#
# Authentication
#
# identd is run standalone now
#
#auth	stream	tcp	wait	root	/usr/sbin/in.identd in.identd -e -o
#
# End of inetd.conf

#linuxconf stream tcp wait root /bin/linuxconf linuxconf --http
#swat      stream  tcp     nowait.400      root /usr/sbin/tcpd swat
	
僕はもともとあったものをlinuxconfが書き換えたものを利用しています。 自分自身では一切編集していません。

設定ファイルはlinuxconfを使うと書きかえることができる。
設定場所は、Control->Control panel->Control service activity の部分にある。


しかし、この部分は、inetdが提供するサービス以外も出て来ている。
サービスを選んで、一番上にInternet serverとでるのがinetdが提供 しているものである。

Disabledを選択すると/etc/inetd.confの中の該当箇所をコメントアウトされる。
Enabledを選択すると/etc/inetd.confの中の該当箇所の有効になる。

hosts.denyとhosts.allow
hosts.denyは、アクセスしてくるホスト毎にサービス毎の禁止ができる。
hosts.allowは、アクセスしてくるホスト毎にサービス毎の許可ができる。
先にhosts.denyが読まれるので、全面禁止をしてから、 hosts.allowで許可するホスト、サービスを書くというやり方がいいでしょ う。
下記に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
	
これで全面禁止にしておいてhosts.allowで
#
# hosts.allow	This file describes the names of the hosts which are
#		allowed to use the local INET services, as decided
#		by the '/usr/sbin/tcpd' server.
#

ALL : 192.168.1.0/255.255.255.0 : allow
ALL : 127.0.0.0/255.0.0.0 : allow
	
これでローカルエリアだけinetdで提供されるサービスに アクセスできるようになる。
また、tcpdchk tcpdmatchでアクセス状況をチェックすることができる。
# tcpdchk -v
Using network configuration file: /etc/inetd.conf

>>> Rule /etc/hosts.allow line 6:
daemons:  ALL
clients:  192.168.1.0/255.255.255.0
option:   allow 
access:   granted

>>> Rule /etc/hosts.allow line 7:
daemons:  ALL
clients:  127.0.0.0/255.0.0.0
option:   allow 
access:   granted

>>> Rule /etc/hosts.deny line 10:
daemons:  ALL
clients:  ALL
access:   denied
	
# tcpdmatch in.proftpd 192.168.1.64
client:   address  192.168.1.64
server:   process  in.proftpd
matched:  /etc/hosts.allow line 6
option:   allow 
access:   granted
	

もどる


Kenji Ohmori
Last modified: Tue May 31 01:58:26 JST 2005