「2004/07/20」
0.スーパーサーバ
多くのデーモンを起動すると、システム全体のパフォーマンスが低下します。それを回避する方法として、サーパーサーバというデーモンが存在します。
普段、各ネットワークサービスは停止していて、スーパーサーバが変わりに複数のポートを監視しています。そして、あるポートは停止していて、スーパー
サーバがそのポートに対応したデーモンが起動します。Fedora Coreでは、Xinetdというプログラムがスーパーサーバの役目を担っています。
1.xinetdのインストール確認
# rpm -q xinetd
xinetd-2.3.13-2
2.xinetdの起動確認
# /etc/rc.d/init.d/xinetd status
# /etc/rc.d/init.d/xinetd status
xinetd (pid 1495) を実行中...
3.xinetdのディレクトリ構造
/etc/rc.d/init.d/xinetd | xinetdを起動するプログラム |
/etc/xinetd.conf | メインの設定ファイル |
/etc/xinetd.d/ | 各サービス毎の設定ファイルを収まるディレクトリ |
/usr/sbin/xinetd | xinetdデーモン(プログラム本体) |
4.自動起動の設定
# chkconfig --list | grep xinetd (ランレベル3オン確認)
xinetd 0:オフ 1:オフ 2:オフ 3:オン 4:オン 5:オン 6:オフ
xinetd ベースのサービス:
# chkconfig --list | less(xinetdベースのサービスに関する設定の出力)
rpcidmapd 0:オン 1:オフ 2:オフ 3:オン 4:オフ 5:オン 6:オン
(略)
xinetd ベースのサービス:
time: オフ
chargen: オフ
services: オフ
daytime: オフ
time-udp: オフ
echo-udp: オフ
sgi_fam: オン
echo: オフ
chargen-udp: オフ
daytime-udp: オフ
rsync: オフ
# chkconfig --list | less
xinetd ベースのサービス:
chargen-udp: オフ
rsync: オフ
chargen: オフ
daytime-udp: オフ
daytime: オフ
echo-udp: オフ
echo: オフ
services: オフ
time: オフ
time-udp: オフ
5.xinetdの設定例(swatの場合)
# grep swat /etc/services(サービスの確認)
swat 901/tcp # Samba Web Administration Tool
# vi /etc/xinetd.d/swat
# default : off # service swat { port = 901 socket_type = stream wait = no only_from = 127.0.0.1 user = root server = /usr/sbin/swat log_on_failure += USERID disable = yes } |
disable = yes ⇒ 無効になる。Swatへの接続を受け付けません。 disable = no ⇒ 有効になる。Swatへの接続を受け付け、サービスができるようになります。 # chkconfig swat on # /etc/rc.d/init.d/xinetd reload |
6.TCP Wrapper を使うサービス
7.アクセス制御の流れ
●/etc/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.
#
●/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!
8.TCP Wrapper の設定
/etc/hosts.allowファイルと/etc/hosta.denyファイルは、ほとんど同じ書式をしています。
最低限記述する必要がある項目は、「サーバデーモン名」と「アクセスしてきたクライアントのアドレス」
の2つです。
各項目はコロン(:)で区切る必要があります。
●/etc/hosts.allowの設定例
sshd : 192.168.0.
●/etc/hosts.denyの設定例
ALL : ALL