はじめにGo To Index
さまざまなインターネットのサービスを提供するサーバ.皆さんもインターネットを利用しているなら,必ずお世話になっています.
通常,サーバは主にプロバイダなど第3者によって運営され,我々はその利用権限をもらったり買ったりして利用します.
自宅サーバはそのサーバを自宅に設置し,自らの手で運営し,ネットワークに関するスキルアップと快適なインターネット環境を模索することを目的とします.
自宅サーバは以前なら自宅まで専用線を引き,IPアドレスを買い,サーバ専用の機器を購入し・・・.と,構築には莫大な費用と手間がかかりました.しかし,近年の情報インフラの普及に伴い,非常に安価に構築が可能です.
専用線はフレッツADSL・ISDN,あるいはBフレッツなどの一般向けの常時接続で代用可能ですし,IPアドレスも一つ月々1,000円ぐらいか らもらえるようになりました.また,LINUXを利用すれば,apacheなど世界標準のサービスソフトウェアが無償で提供されているので,ソフトウェア はOSを含め,すべて無償でそろえることができます.
このページではこれから自宅サーバを構築する人のために,私の経験を踏まえて,機器の選定から導入,ソフトウェアの設定までを紹介して行きます.
しかし,あくまで私の経験ですので,正しいとは限りません.ここでの内容を実行するときはすべて自らの責任の上で行ってください.
1 環境選び,環境作りGo To Index
1.1 回線Go To Index
思い立ったが吉日!さあ,いきなりはじめます.まずは家にインターネットを引きましょう.これを見てるなら,多分もう引いてあるでしょう.でも,本 格的にサーバを立てたいのなら,常時接続が基本.フレッツADSL・ISDN,あるいはBフレッツなどがいいのではないでしょうか.私はBフレッツ,ファミリータイプにしました.これから先は,Bフレッツであることを前提に話を進めさせていただきます.
申し込んでから1ヶ月強で工事をしてくれました.工事は1時間ぐらいで終わりました.青い光ファイバを外から引っ張って,屋内にある光終端装置につ ける程度の工事です.速度は速いときで5Mbpsぐらいです.遅いような気がしますが・・・.ADSLよりは劇的に早くなったので良しとします.
1.2 ルータGo To Index
ブロードバンドルータを決めます.自宅サーバ運営で必要な機能は
- 静的IPマスカレード
- ファイアウォール機能
- PPPoE接続機能
しかも,ブロードバンドの場合は
- 高スループット
も考慮に入れる必要があります.私はマイクロ総合研究所 NetGenesis SuperOPT50にしました.設定が少々面倒くさいところがありますが,パケットフィルタリングが細かく設定できるところが嬉しいです.高機能,高スループットで最高のルータだと思います.
1.3 プロバイダGo To Index
プロバイダは固定IPをくれるところがいいです.今は結構増えてきています.まだまだBフレッツの固定IPは高いですが・・・.http://www.flatray.com/static-ip/index.htmlに,固定IPを提供しているプロバイダの一覧があります.
1.4 ドメイン名Go To Index
ドメイン名を取ります.私はお名前.comでとりました.
もし,DNSを管理するのが面倒ならば,DNS登録も同時にやってくれるレジストリがあるので,そこを狙うのがいいでしょう.独自ドメイン取得情報は参考になります.
1.5 本体Go To Index
たいしたスペックは要りません.私はあまりパーツで自分で組み立てました.ただ,ネットワークカードは100Mbpsにしたほうがいいです.
- CPU:Celeron 433MHz
- メモリ:128MB
- NIC:100Mbps PCI製
- HDD:13GB+15GB
1.6 OSGo To Index
Linux,特に今回はRedHat Linux 7.2にします.ほとんどの場合,OSもソフトウェアも無料です.Windowsはセキュリティ面でちょっと不安があります.世界的に見ても,Unixベースのサーバのほうが圧倒的に多いと思いますから,Linuxに慣れることはのちのち有利になるかもしれません.
1.7 提供するサービスとそのサーバソフトウェア
- DNS:BIND
- FTP:ProFTPD
- SSH:OpenSSH
- Web:Apache
- メール:PostFix&Qpopper
の5つとします.telnetはセキュリティ上提供しません.ソフトウェアは世界標準といっても過言ではないものを選んでいます.使われていないものを使っても将来役に立たなさそうですから・・・.
2 インストールGo To Index
2.1 OSGo To Index
まずはOSのインストールからはじめます.RedHat Linux 7.2を雑誌,またはFTPでイメージを落としCDに焼くなりして手に入れます.
インストール方法はカスタムインストールとします.一つ一つ自分で決めながらインストールです.
まずは,パーティションの切り方です.
- / 3GB
- /var 2GB
- /home 10GB
- swap 128MB
/varと/homeは後々のことを考えて,分けたほうがいいです./varにはログとメール,/homeにはユーザのデータが記憶されています.swapはメモリと同じぐらいの大きさをとります.
IPの割り当ててすが,DHCPではなく固定でわかりやすい番号を一つ決めておきます.ルータによってはDHCP機能が働いている場合があるので,DHCPで割り当てるIPの範囲外のものにしておきます.サーバ名も自分の好きな名前をつけます.
同時にインストールするパッケージですが,ネットワーク関連のソフトウェアは入れても入れなくてもかまいません.どうせ後で最新版を探してくるからです.
2.2 RPMについてGo To Index
RPM(RedHat Package Manager)とは、パッケージ管理システムです。RPMでパッケージ、平たく言うとソフトウェアを管理することで、依存性のチェックやアップデートなどを楽~に行うことができます。
ソフトウェアをソースからコンパイルしてインストールすると、設定ファイルやログが/usr/local 以下に入ってしまうことが多く、管理も面 倒くさくなってしまいます。RPMでインストールすろと設定ファイルは/etc 以下、ログは/var/log 以下にきちんと置かれるので大変管理がし やすくなります。
こんな楽なRPMですが、結構探すのが面倒くさかったり、逆にインストールやアップデートが面倒くさくなることがあります。RPMのバイナリパッ ケージはKondara用とかVine用とかって言うのがあるので、所望の物がなかなか無かったりします。インストールのときはちゃんと依存関係をチェッ クするので、入れておかなければいけない物があったら怒られて、それを探しにいって、・・・なんてことがあったりします。また、ソフトウェアの最新版が RPMになって無かったりということもあります。また、アーキテクチャによっても異なったりします。普通はi386ですが・・。
でも、やっぱりRPMがいいです。ソースからコンパイルしてなんぼ!という人もいるかもしれませんが、僕はRPMを意地でも使って管理をしたほうが一元的に管理ができていいと思います。
2.3 BINDGo To Index
では,いよいよソフトウェアを入れていきます.まずはDNSを担当するBINDを入れていきます.BINDはバージョン9を入れます.BIND9は 内部からは内部向けの名前引き、外部からは外部向けの名前引きをしてくれます.これが,IPアドレスを一つしかもらえないホームサーバにとってはありがた いからです。/etc/named.confには以下のような設定を行ってみます。
options {
//辞書ファイルをどこに置くか?
directory "/var/named";
};
//対内部用名前引きの設定
view "internal"{
//この設定をどのIPに効かせるか
match-clients {192.168.0.0/24; 127.0.0.0/8;};
recursion yes;
zone "." IN {
type hint;
file "named.ca";
};
//ローカルホスト順引き
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
//ローカルホスト逆引き
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
//内部LAN用順引き
zone "tamochan.com" IN{
type master;
notify no;
file "tamochan.com.local.zone";
};
//内部LAN用逆引き
zone "0.168.192.in-addr.arpa" IN{
type master;
notify no;
file "0.168.192.rev";
};
};
//外部公開用
view "external"{
match-clients {any;};
recursion no;
//外部用順引き
zone "tamochan.com" IN{
type master;
notify no;
file "domain";
};
};
外部用の逆引きは,プロバイダの都合上,してくれないので,記述していません.
個々の辞書ファイルですが,外部向きの設定ファイル(上の設定ファイルに合わせると,/var/named/domain)だけ公開します.
$TTL 43200
@ IN SOA dns.tamochan.com. tamori.tamochan.com. (
2002022501;serial
28800;refresh
14400;retry
3600000;expire
86400;minimum )
dns IN A 211.133.147.90
@ IN NS dns.tamochan.com.
//メールサーバ
@ IN MX 10 mail.tamochan.com.
//エイリアスの設定
www IN CNAME dns.tamochan.com.
ftp IN CNAME dns.tamochan.com.
mail IN CNAME dns.tamochan.com.
細かい部分は他所に譲るとして,結構重要なのは,上で行くとserial.これはシリアル番号で,変更を行った際には必ず,さらに大きな番号をつけておきます.変更した日付(YYYYMMDD)+2桁の通し番号としておくと,大きな番号になっていきます.また,忘れがちなのがdns.tamchan.com.の最後のピリオド.本当に忘れます.
2.4 ProFTPDGo To Index
FTPサービスを実現するソフトウェアにProFTPDがあります.RPMでインストールすると設定ファイルは/etc/proftpd.confです.この設定を見ていきます.
# This is the ProFTPD configuration file
# 起動時に最初に表示させるメッセージ
ServerIdent on "tamochan.com FTP Server ready."
#アドミニストレータのメールアドレス
ServerAdmin root@tamochan.com
#ined経由で起動するので,standaloneではなくて,inetd
ServerType inetd
DefaultServer on
# Use pam to authenticate by default
AuthPAMAuthoritative on
# Do not perform ident lookups (hangs when the port is filtered)
IdentLookups off
# Port 21 is the standard FTP port.
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# Chmod isn't allowed by default
#AllowChmod on
# Default to show dot files in directory listings
LsDefaultOptions "-a"
# See Configuration.html for these (here are the default values)
#MultilineRFC2228 off
#RootLogin off
#LoginPasswordPrompt on
#MaxLoginAttempts 3
#MaxClientsPerHost none
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances 30
# Set the user and group that the server normally runs at.
User nobody
Group nobody
# Normally, we want files to be overwriteable.
<Directory /*>
AllowOverwrite on
</Directory>
#anonumous(匿名)は受け付けないようにするため,コメントアウト.
# A basic anonymous configuration, no upload directories.
#<Anonymous ~ftp>
# Uncomment the following line to allow anonymous access
#RequireValidShell off
# AllowChmod off
# User ftp
# Group ftp
# AccessGrantMsg "Anonymous login ok, restrictions apply."
# We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp
#
# Limit the maximum number of anonymous logins
# User ftp
# Group ftp
# AccessGrantMsg "Anonymous login ok, restrictions apply."
# We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp
#
# Limit the maximum number of anonymous logins
# MaxClients 10
# We want 'welcome.msg' displayed at login, '.message' displayed in
# each newly chdired directory and tell users to read README* files.
# DisplayLogin welcome.msg
# DisplayFirstChdir .message
# DisplayReadme README*
# Limit WRITE everywhere in the anonymous chroot
# <Limit WRITE>
# DenyAll
# </Limit>
#</Anonymous>
FTPはinetdを経由して起動します.inetdとは,一つのプロセスでいろんなポートを見張っていて、クライアントからの通信が来た場合に初 めてサーバを実行してくれる便利な仕組みのことです.そこで次に,このinetdの設定をします.RedHatでは,inetdのさらに強力な管理機能を 持つxinetdになっています.設定ファイルは/etc/xinetd.d/proftpdです.
# default: off
# description: The ProFTPD FTP server serves FTP connections. It uses \
# normal, unencrypted usernames and passwords for authentication.
service ftp
{
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.proftpd
log_on_success += DURATION USERID
log_on_failure += USERID
nice = 10
disable = no
}
曲者はdisableでしょうか.デフォルトではyesになっていますが,noにしないと,起動しません.
2.5 SSHGo To Index
リモートでサーバを管理するために,従来はtelnetを使っていました.しかし,telnetは内容が暗号化されないため,パスワードなどが容易 に盗聴できました.そこで,SSH(Secure SHell)を採用するところが多くなってきています.パケットをすべてRSAまたはDSAという方法で暗号化して送るため,盗聴しにくくなっています. また,SSHにはポートフォワードという便利な機能もあるため,利用しない手はありません.
RSA方式を採用するものがSSH1,DSA方式を採用するものがSSH2となります.暗号強度的にはDSA方式のほうが有利ですが, Windowsからアクセスするためには,ソフトウェアの都合からRSA方式でなくてはならないようです.両方に対応しているものがOpenSSHです. RPMでいれると,/etc/ssh/sshd_configが設定ファイルになります.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
# This is the sshd server system-wide configuration file. See sshd(8)
# for more information.
Port 22
Protocol 2,1
#ListenAddress 0.0.0.0
#ListenAddress ::
HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
ServerKeyBits 768
#ポートフォワードなどでつなぎっぱなしにしたいときは0
LoginGraceTime 0
KeyRegenerationInterval 3600
#ルートでのログインを拒否
PermitRootLogin no
# Don't read ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
StrictModes yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd yes
#AllowUsers tamori
#PrintLastLog no
KeepAlive yes
# Logging
SyslogFacility AUTH
LogLevel INFO
#obsoletes QuietMode and FascistLogging
RhostsAuthentication no
#
# For this to work you will also need host keys in /usr/local/etc/ssh_known_host
s
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
RSAAuthentication yes
#平文パスワードの拒否
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
PermitEmptyPasswords no
Subsystem sftp /usr/local/libexec/sftp-server
(END)
平文パスワードの拒否はnoにしておいたほうがいいでしょう.クライアントには秘密鍵,サーバ側には自分のホームディレクトリに.sshというディレクトリを作り,中に公開鍵を置きます.
SSHはVPNにも応用されているようですので,暗号化ということに免疫をつけるにはちょうどいい第一歩かもしれません.
2.6 ApacheGo To Index
Apacheはいわずと知れたウェブサービスを提供するソフトウェアです.今では最新版として2.0が出ていますが,ここでは1.3について紹介し ます.RPMでのインストールではインストール後,デーモンを立ち上げ,127.0.0.1にアクセスするとすぐに「It worked!」などという画面がすぐに出てくれます.ただ,外部に公開するにはいくつか設定を変更しなくてはなりません.以下に, /etc/httpd/conf/httpd.confの変更するべき一部を抜粋して紹介します.
#サーバの管理者のメールアドレス
ServerAdmin webmaster@tamochan.com
#サーバの名前
ServerName www.tamochan.com
#http://www.tamochan.comのルートディレクトリ.まずはじめに参照するディレクトリ.
DocumentRoot "/home/webmaster/public_html"
#/home/*/public_htmlの設定.CGIやSSIが動くようにしてある.
<directory home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
#CGIの実行を許可
Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI
#SSIの実行を許可
Options +Includes
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
#CGIのファイルを設定
AddHandler cgi-script .cgi
#SSIのファイルを設定
AddType text/html .shtml
AddHandler server-parsed .shtml
#バーチャルホストの設定
#まずはNameVirtualHostにサーバのIPを設定
NameVirtualHost 192.168.0.22
#もし,http://tanpopo.tamochan.comでアクセスしてきた場合
#ドキュメントルートは/home/tanpopo/public_htmlに設定
<VirtualHost 192.168.0.22>
ServerAdmin tanpopo@tamochan.com
DocumentRoot /home/tanpopo/public_html
ServerName tanpopo.tamochan.com
#ログの出力先
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log common
</VirtualHost>
CGIやSSIの設定が少々面倒くさいといったところでしょうか.ユーザに好評なのがヴァーチャルホストの設定.ユーザのホームページがhttp: //***.tamochan.comのような,チルダなしのアドレスで公開できます.ヴァーチャルホストの設定後は,違う名前でもアクセスできるよう に,/var/named/domain(正引きファイル)に,たとえば次の一行を足しておきます.
tanpopo IN CNAME dns.tamochan.com.
2.7 Postfix&QpopperGo To Index
一番重要なのがメールでしょう.ここはしっかり設定しないと,スパムメールの発信元などになりかねないので,気をつけます.
tamochan.comは"POP before SMTP"というものを採用しています.SMTPには本来, 認証手続きがないために,外部からのメールのリレーを許可すると,スパムメールのようなメールの不正中継に使われてしまう恐れがあります.だからといって メールのリレーを許可しないと外部からSMTPが使えなくなるので,たとえば自宅にメールサーバがあって,外出先から自宅のアカウントでメールを出した い,なんてときには不便です.そこで,外部のマシンがPOP接続をした場合,その後数分間は同じマシンからの SMTPリレーを許可することで,あたかもSMTPにユーザ認証機能が付いているかのようにするのが"POP before SMTP"です.(一部,PostfixとAPOP,POP before SMTPより引用)
今回はは,SMTPを提供するものにPostfix,POP3を提供するものにQpopper,POP before SMTPを提供するものにはDRACをそれぞれ利用します.
まずはDRACのインストール.http://mail.cc.umanitoba.ca/drac/よりDRACをダウンロードし,解凍します.
% tar xzvf drac.tar.Z
次にDRACのMakefileを編集します.
INSTALL = install
EBIN = /usr/sbin
DEFS = -DSOCK_RPC -DFCNTL_LOCK -DGETHOST -DDASH_C -DREQ_HASH
CFLAGS = $(DEFS) -g
LDLIBS = -ldb
TSTLIBS = -L. -ldrac
RPCGENFLAGS = -C -I
MANADM = 8
rpc.dracd.c を編集します.
#define DBFILE "/etc/postfix/dracd.db"
#define ALFILE "/etc/postfix/dracd.allow"
dracd-setup.linux を編集します.ここでは,POP認証の有効期限を60分に設定しています.
"daemon rpc.dracd&"の行を"daemon rpc.dracd -e 5&"に変更.
コンパイルとインストールを行います.
% make
% make install
% make install-man
% cp dracd-setup.linux /etc/rc.d/init.d/dracd
% ln -s /etc/rc.d/init.d/dracd /etc/rc.d/rc3.d/S78dracd
% ln -s /etc/rc.d/init.d/dracd /etc/rc.d/rc5.d/S78dracd
% ln -s /etc/rc.d/init.d/dracd /etc/rc.d/rc6.d/K22dracd
DRACの最後の仕上げは,Qpopperのインストール時に必要なライブラリを自分でインストールします.
% cp libdrac.a /usr/lib/
つぎは,Qpopperのインストールです.まず,ソースのRPMを探してきて,インストールします.
% rpm -ivh qpopper-4.0.3-0vl1.src.rpm
QpopperをDRAC対応にするため,specファイルを編集します.
% cd /usr/src/redhat/SPECS
% vi qpopper.spec
(%buildセクションに追加)
--prefix=/usr \
--enable-bulletins=/var/spool/mail/bulletins \
--enable-specialauth \
--with-pam=qpopper \
--with-popuid=pop \
--enable-apop=/etc/pop.auth \
--enable-drac (←これを追加)
(%preセクションのuseraddにオプションを追加)
/usr/sbin/useradd -M -g pop pop -c "Pop Account" -d /dev/null -s /dev/null
rpmを作成します.
% rpm -bb qpopper.spec
Qpopperの仕上げとして,作ったQpopperをアップデートします.
% cd /usr/src/redhat/RPMS/i386
% rpm -Uvh qpopper-4.0.3-0vl1drac.i386.rpm
いよいよPostfixのインストールです.RPMでインストールすると,設定ファイルは/etc/postfix/main.cfです.それでは見ていきましょう!主なものを抜粋です.
#キューをためるディレクトリ
queue_directory = /var/spool/postfix
#メールオーナー
mail_owner = mail
#ホストネーム
myhostname = mail.tamochan.com
#ドメイン
mydomain = tamochan.com
# myorigin パラメータにはローカルで送信されたメールがどのドメインから
# 来るように見えるかを指定
myorigin = $mydomain
#このマシンが自分自身が最終目的地だとみなすドメインのリストを指定
mydestination = $myhostname, localhost.$mydomain, $mydomain,
mail.$mydomain, www.$mydomain, ftp.$mydomain
#エイリアスのファイル
alias_maps = hash:/etc/aliases
#/sbin/newaliacesを実行したとき,どんなデータベースを作るか
alias_database = hash:/etc/aliases
#メールをためるディレクトリ
mail_spool_directory = /var/spool/mail
#このメールシステムがどのクライアントから
#リレーを受けるか、またはどの目的地にメールをリレーするかを制限
relay_domains = $mydestination
#SMTPを受け付けるアドレス
mynetworks = 192.168.0.0/16, 127.0.0.0/8, 211.133.147.90/32
#POP before SMTPを動かす設定
smtpd_recipient_restrictions =
permit_mynetworks,
check_client_access btree:/etc/mail/dracd,
check_relay_domains
#わかんないドメインからのメールは拒否
smtpd_sender_restrictions = reject_unknown_sender_domain
#送信を許可する最大のファイルサイズ
message_size_limit = 1024000
#メールの寿命
maximal_queue_lifetime = 12h
POP before SMTPを動かす設定を忘れないようにします.また,送信を許可する最大のファイルサイズも設定しておいたほうが,メール爆弾などが送られなくてすみます.
一番トラフィックが多いのはメールになってくると思います.きちんと設定しなければ損害賠償!なってこともあるかもしれないので,慎重に設定をしてください.なお,第三者中継のチェックはhttp://www.nanet.co.jp/rlytest/relaytest.htmlでやってくれますので,公開する前に試してみてください.
2.8 ルータの設定Go To Index
さぁ,いよいよ外部に公開!そこで最後の仕上げとして,ルータの設定をします.必要な設定は静的IPマスカレードです.これは,インターネット側か ら配信されたIPフレームを,プロトコルやポート番号に応じて内部LANの特定のIPアドレスへ転送する機能です.今回はサーバのアドレスを 192.168.0.100として,設定をしてみます.
- ftp-data 20/tcp -> 192.168.0.100
- ftp 21/tcp -> 192.168.0.100
- ssh 22/tcp -> 192.168.0.100
- smtp 25/tcp -> 192.168.0.100
- dns 53/udp -> 192.168.0.100
- www 80/tcp -> 192.168.0.100
- pop3 110/tcp -> 192.168.0.100
試しに,ポートスキャンをかけてみます.http://210.143.99.143/~p-sec/pscan.htmlからかけてみて,余計なポートは開いていませんか?確認してみてください.
2.9 WebDAVGo To Index
WebDAVとは(簡単に言うと)HTTPでファイル転送を行う,FTPに変わるものと注目されるファイル共有プロトコルです.コネクションが単一 方向なので,どうもファイアウォールでFTPが邪魔される,ということも無くなるようです.また,サーバサイドでの処理,一本のコネクションでの処理とい うメリットもあります.なお,ここで紹介する設定例はapache1.3用です.ご了承ください.
まず,apacheに必要なモジュールが入っているか確認します.mod_so.cが入っていれば利用可能です
% httpd -l
Compiled-in modules:
http_core.c
mod_so.c
SUExec: enabled; valid wrapper /usr/sbin/suexec
rpmを探してきてインストールしましょう.パッケージによってはすでに入っていることもあるようです.以下のコマンドで確認してみましょう.私はすでにインストール済みでした.入れた覚えはないのですが….
% rpm -qa | grep mod_dav
いよいよhttpd.confの設定です.
#以下の2行はあらかじめ書いてあるかもしれません
LoadModule dav_module modules/libdav.so
AddModule mod_dav.c
#ロックデータベースの設定.どこに設定してもいいが,ディレクトリに
#httpdプロセスのユーザ権限で書き込み可能でなくてはならない.
DAVLockDB /usr/local/apache/DAVLock
#Aliasの設定.設定した方がいいかも.
#エイリアス先はpublic_html以下はさけた方が無難.
Alias /dav "/home/httpd/davhome"
#指定のディレクトリに対してWebDAV可能にする.
<Location /dav>
DAV on
</Location>
httpdの再起動を忘れずに.ここまででとりあえず可能です.Windowsだと,「ネットワークプレイスの追加」により利用可能です.上の設定 例だとホスト名http://www.tamochan.com/davで設定します.XPだと,ドライブ名を割り当てることもできます.
しかし,ここまでだと誰でもファイルを閲覧可能です.ここで,.htaccessファイルにより認証設定を行います.以下に.htaccessの設定例を示します.
AuthUserFIle /usr/local/apache/pass.pwd #パスワードファイル名.後述.
AuthGroupFile /dev/null #認証用グループファイル
AuthName DAVhome #認証ダイアログ表示用文字列
AuthType Basic #認証タイプ
<LimitExcept GET OPTIONS>
Require user tamochan
</LimitExcept>
GET,OPTIONS以外の操作は認証が必要という設定でした.次にパスワードの設定です.以下のコマンドによりパスワードを入力してください.
% htpasswd -c /usr/local/apache/pass.pwd tamochan
さらに,.htaccessが動くようにhttpdの設定です.httpd.confに以下の設定を加えてください.
<Directory /home/httpd/davhome>
AllowOverride Limit AuthConfig
</Directory>
これで,(WinXPではなく)Win2000ではアクセスすると認証画面が表示されます.WinXPではなぜか認証画面が出ても認証されません.
さらに,このままだと日本語のファイル名を持つものを登録するとファイル名が文字化けしてしまいます.よって,mod_encodingというモジュールを導入します.これはWinXPの認証問題と日本語の問題を一気に解決してくれるものです.
まず,WebDAV Resourcesからソースアーカイブをダウンロードします.適当に展開します.
次にコンパイルですが,まず展開されたディレクトリの直下にlibディレクトリがあるので,そこの中からコンパイルです.
% cd lib
% ./configure
% make
% make install
これについては詳しいことはあまり述べないことにします.次に本体のコンパイルです.
% cd ..
(コメント)apxsというコマンドのパスとiconv_hookライブラリのパスの指定をしてください.
% ./configure --with-apxs=/usr/sbin/apxs --with-iconv-hook=/usr/local/lib
% make
% make install
さらに,httpd.confの設定です.
LoadFile /usr/local/lib/libiconv_hook.so
LoadModule encoding_module modules/mod_encoding.so
<IfModule mod_headers.c>
Header add MS-Author-Via "DAV"
</IfModule>
<IfModule mod_encoding.c>
EncodingEngine on
NormalizeUsername on
SetServerEncoding UTF-8
DefaultClientEncoding JA-AUTO-SJIS-MS SJIS
AddClientEncoding "cadaver/" EUC-JP
</IfModule>
httpdを再起動して確認してください.
2.10 SpamAssassinGo To Index
あまり望ましくないことですが、運営していると外部にメールアドレスが漏れたりしてスパムメールが頻発してくるようになることがあります。そういうときの強い見方がSpamAssassinです。これをMTAに組み合わせて使うことにより、強力なスパムフィルタにより自動的にスパムメールと思われるメールを廃棄してくれます。今回はデーモン(spamd)を起動しておいて、一回ずつ呼び出して処理するという手法を紹介します。
まず、SpamAssassinより、tarボールをダウンロードしてきます。このtarボールにはspecファイルが含まれているのでrpmパッケージが作成可能です。rpmパッケージは3つ作られると思いますが、いずれも一応インストールします。
次に、デーモンとして動かすための準備をします。以下のスクリプトを用意します。(rpmを入れたら入っているかもしれません。)
#!/bin/sh
#
# spamassassin This script starts and stops the spamd daemon
#
# chkconfig: 2345 80 30
#
# description: spamd is a daemon process which uses SpamAssassin to check
# email messages for SPAM. It is normally called by spamc
# from a MDA.
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# Source spamd configuration.
if [ -f /etc/sysconfig/spamassassin ] ; then
. /etc/sysconfig/spamassassin
else
SPAMDOPTIONS="-d -c -a -m5 -H"
fi
[ -f /usr/bin/spamd -o -f /usr/local/bin/spamd ] || exit 0
PATH=$PATH:/usr/bin:/usr/local/bin
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting spamd: "
daemon spamd $SPAMDOPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/spamassassin
;;
stop)
# Stop daemons.
echo -n "Shutting down spamd: "
killproc spamd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/spamassassin
;;
restart)
$0 stop
$0 start
;;
condrestart)
[ -e /var/lock/subsys/spamassassin ] && $0 restart
;;
status)
status spamd
;;
*)
echo "Usage: $0 {start|stop|restart|status|condrestart}"
exit 1
esac
exit 0
このスクリプトをspamdとして保存し実行権限を与え、各ランレベルでデーモンとして起動するようにします。
% chmod +x spamd
% /sbin/chkconfig spamd on
TLECより、設定ファイルをダウンロードし利用します。これを/etc/mail/spamassassin/local.cfとして保存します。
次に、Postfixのフィルタとしてのスクリプトを用意します。要するに、メールを受け取ったり発信したりする都度にこのスクリプトを実行するようにさせるわけです。様々なHPを参考に、私は以下のようなスクリプトを作成しました。
#!/bin/bash
#SpamAssasin filter with Postfix
#FILE PATH
RM=/bin/rm
INSPECT_DIR=/var/spool/filter
OUTPUTFILE=out.$$
SENDMAIL=/usr/sbin/sendmail
KILLFILE=/var/log/spammail
SPAMASSASSIN=/usr/bin/spamc
#Exit codes from
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
#Move to Work Dir
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist : exit $EX_TEMPFAIL; }
#Clean up when done or when aborting
trap "$RM -f $OUTPUTFILE" 0 1 2 3 15
cat | $SPAMASSASSIN -x > $OUTPUTFILE
#メールのヘッダにspamdによってつけられる"X-Spam-Status: Yes"があるなら、KILLFILEに捨てる。
spamflag=`less $OUTPUTFILE | grep -c 'X-Spam-Status: Yes'`
if [ $spamflag = 1 ]; then
cat $OUTPUTFILE >> $KILLFILE
#それ以外なら処理。
else
$SENDMAIL "$@" < $OUTPUTFILE
fi
exit $?
さらに、Postfixのmain.cfに、フィルタの定義を追加します。
filter unix - n n - - pipe user=filter argv=/usr/local/bin/sa_filter.sh -f ${sender} -- ${recipient}
次にmain.cfのsmtpの部分を書き換えます。
smtp inet n - n - - smtpd -o content_filter=filter:
Postfixを再起動し、きちんと動作するか確認します。
参考:http://www.sonorilo.net/spamassassin。ありがとうございました。
3 日々の管理Go To Index
3.1 logcheckGo To Index
日々の管理は,やはり/var/log以下のログを随時チェックすることが大事ですが,膨大なログを,逐一チェックするのは大変に手間のかかる作業です.
しかし,我々には大きな見方がいます.その名はlogcheck.大事なログだけを抜粋して設定時間おきにメールで送ってきてくれます.
RPMで入れて,早速設定します.まず,どのログファイルチェックするかを設定します./usr/bin/logcheck.shを編集します.以下に抜粋を示します.
# Linux Red Hat Version 3.x, 4.x
$LOGTAIL /var/log/messages > $TMPDIR/check.$$
$LOGTAIL /var/log/secure >> $TMPDIR/check.$$
$LOGTAIL /var/log/maillog >> $TMPDIR/check.$$
$LOGTAIL /var/log/router >> $TMPDIR/check.$$
#apacheのエラーログも送るようにする.
$LOGTAIL /var/log/httpd/error_log >> $TMPDIR/check.$$
次に,どんなログが大事で,どんなログがいらないかを設定します.特に,いらないログを設定することは大事です.一杯送られてきたら意味がないです から・・・.この設定は/etc/logcheck以下にありますが,今回はいらないログの設定を示します./etc/logcheck/ignoreに は,「こんな文字列があるものは,いらない!」という設定をすることができます.
authsrv.*AUTHENTICATE
cron.*CMD
cron.*RELOAD
cron.*STARTUP
ftp-gw.*: exit host
ftp-gw.*: permit host
ftpd.*ANONYMOUS FTP LOGIN
ftpd.*FTP LOGIN FROM
ftpd.*retrieved
ftpd.*stored
http-gw.*: exit host
http-gw.*: permit host
mail.local
named.*Lame delegation
named.*Response from
named.*answer queries
named.*points to a CNAME
named.*reloading
named.*starting
netacl.*: exit host
netacl.*: permit host
popper.*Unable
popper: -ERR POP server at
popper: -ERR Unknown command: "uidl".
telnetd.*ttloop: peer died
tn-gw.*: exit host
tn-gw.*: permit host
x-gw.*: exit host
x-gw.*: permit host
xntpd.*Previous time adjustment didn't complete
xntpd.*time reset
root 1
named.*Cleaned
named.*USAGE
named.*NSTATS
named.*XSTATS
ntpd.*ntpd
ntpd.*precision
ntpd.*using
ntpd.*frequency
ntpd.*: synchronisation lost
postfix/pickup.*: uid=
postfix/cleanup.*: message-id
postfix/nqmgr.*: from=
postfix/local.*: to=
postfix/smtp.*250
postfix/smtpd.*: connect from
postfix/smtpd.*: disconnect from
postfix/smtpd.*client
sshd.*: Connection closed by
sshd.*: Accepted rsa
PAM_pwdb.*: (login) session opened
PAM_pwdb.*: (login) session closed
named.*bad referral
named.*Lame server on
popper.*: login
popper.*: Stats:
xinetd.*pop3
.* というのはワイルドカードです.上手に利用して,アタックの早期発見を心がけましょう.
最後に,一時間おきにlogcheckを起動します.cronに書いておきます.
% su
% crontab -e
(この行を追加)
00 * * * * /usr/bin/logcheck.sh
3.2 SYSLOG機能を利用したルータのログ管理Go To Index
私の所有するルータには,SYSLOG機能があります.ログを,指定したIPアドレスに送ってくれる機能です.もしルータにこの機能があるなら,絶対に利用するべきです.
ルータの設定は説明書にお任せして,ここではサーバ側の設定を行います./etc/sysconfig/syslogを編集します.
#Options to syslogd
# -m 0 disables 'MARK' messages.
# -r enables logging from remote machines
# -x disables DNS lookups on messages recieved with -r
# See syslogd(8) for more details
SYSLOGD_OPTIONS="-m 0 -r" #<-ここを変更
# Options to klogd
# -2 prints all kernel oops messages twice; once for klogd to decode, and
# once for processing with 'ksymoops'
# -x disables all klogd processing of oops messages entirely
# See klogd(8) for more details
KLOGD_OPTIONS="-2"
SYSLOGD_OPTIONS="-m 0 -r"の"-r"オプションをつけることで外部からのSYSLOGを受け付けるようになります.最後に,SYSLOGデーモンを再起動すると,/var/log/messagesにルータのログが記録されていきます.
% /etc/init.d/syslog restart
3.3 攻撃がしつこいときに・・・パケットフィルタリングのマスクGo To Index
たとえば,こんなログが残ったりします.
[Wed May 15 20:50:53 2002] [error] [client 211.5.***.***]
File does not exist: /home/webmaster/public_html/scripts/..%5c../winnt/system32/cmd.exe
ルータのパケットフィルタリングはわかりづらいことがあります.IP/MASKといわれても,MASKってなに?って感じです.ここでは,このマスクについて解説します.
これは有名なNimdaから攻撃されたログです.IPドメインサーチで211.5.***.***を見ると、こんな感じで返事が返ってきます。
………
inetnum: 211.0.0.0 - 211.7.255.255
………
この全体をパケットフィルタリングします.おもむろに電卓で前から2進数になおしてみます.
前から13桁は変化なし,後ろの19桁はがらりと変わっています.この変化のなかった桁数,13という数字がマスクになります.ですから,この範囲からのパケットをはじきたい場合には
211.0.0.0/13
という設定になります.フィルタリングしたい最初のIP/変化のない桁数 です.
気をつけて設定しないと,予期しないところからもアクセスできない場合が出てきますので,気をつけて設定しましょう(汗).
ちなみに,http://www.nextcom.co.jp/tools/addr.htmで,サブネットに関する計算をしてくれます.参考にしてみてください.
3.4 up2dateでアップデートを簡単にする!Go To Index
RedHatにはup2dateという自動アップデート機能があるんです.設定方法を簡単にご説明します.まずはRedHat Networkだかに登録をします.登録は無料のようです.
% rhn_register --configure
% rhn_register --nox
初期設定です.
% up2date --nox --configure
自動起動の設定です.
% ntsysv
この後,rhnsdをON
いよいよアップデート.以下のコマンドを打つと,ずら~っとアップデートしてくれます.
% up2date -u
4 最後にGo To Index
最後に,私が自宅サーバを立ち上げてよかったなって思うことをいくつか.
まず,知識レベルがものすごく高くなりました.インターネットって,どんな仕組みなんだろうってことがだいぶわかるようになってきました.これは, 資格などに非常に有利だと思います.資格は実務経験がものをいうことが多いです.学生のうちはそんなものは得ることができないので,この自宅サーバを通じ て得る経験は大変に意義深いものだと思います.
リアクションがあるのも非常に嬉しいです.「DNSのセカンダリになって」とか,「設定わからないので教えて」というメールが多くなってきています.やりがいがあります.
最近は,就職活動の面接のネタとして非常に役に立ちました.私はネットワークスペシャリストを持っていますが,資格ではなく,経験を重視する企業も多いはずです.僕は面接で自宅サーバについて,たとえば苦労話など,熱く語ったらそこから話が弾むことも多かったです.
どうでしょう,皆さん.今すぐ始めてみたらいかがですか?少々費用がかさむかもしれませんが,自分の将来への投資と考えて・・・.
参考文献Go To Index
- 怒涛のLinuxネットワーク ぱぱんだ著
- UNIXUSER 2003年11月号 ソフトバンク パブリッシング社
Now you might be prepared to place on it.Aspects which you will want:&bull Gentle brush&bull Lint no cost towel&bull New water&bull Gentle detergentHow to cleanse it:&bull Clear away the dirt and dust particles from the boots with the help of a gentle brush. It can lead to a long lasting damage. Seeing that the Uggs are built of fur that why they demands appropriate routine maintenance. No wonder the ladies and the gals in the streets are all in UGGs. Ugg bailey boots will make your feet experience cosy and you can like the cold to the fullest. If you might be hunting for a magnificent pair that is ready to continue to keep your feet warm and dry all over the winter, UGG boots must be your perfect alternative. Preserving directly underneath the sun can bring about shrinkage. As a best blend of UGG Traditional Quick and UGG Classic Cardy, UGG Bailey Button boots have develop into a favourite alternative amongst manner conscious people all over the earth. You need to do it on a frequent basis to stop your boots losing its allure&bull Constantly continue to keep in thoughts that cleaning doesn't necessarily mean that you just will place them inside a washing machine.
http://suweesh.com/index.php
http://funkboxing.com/simplemachinesforum/index.php
http://www.breastconsult.com/ask-a-board-certified-plastic-surgeon.asp
http://www.4006819400.com.cn/bbs//index.php
http://forum.mygrid.asia/index.php
投稿情報: CDDyncented | 2011年12 月 3日 (土) 17:22
There are plenty of clutches to select from yet if you are looking regarding among the finest subsequently you need to seem no further than a Louis Vuitton travelling bag. There are lots of styles as well as hues to select from. You need to take a look at now there boutique to select louis vuitton luggage your favorite variations and colorations. Remember that one could not spend as much utilize the net to uncover ones next ladies handbag. Eventually http://www.louisvuittononlineforsale.com/ try to remember that you can find just about the most recognizable purses on the globe using a Louis Vuitton. People need not spend entire price for the reason that you'll find internet alternative open to a person. A fantastic solution can be to get an individual louis vuitton speedy who's needing promoting at this time there case all around health have the cash. Tips on how to explain to in case you are getting the genuine article? Very well, it is going to have that reproduction sewn interior the idea as well as it will have its very own serial amount.
louis vuitton speedy
louis vuitton speedy
louis vuitton sale
louis vuitton speedy
louis vuitton handbags
投稿情報: AfforoVafteda | 2012年1 月27日 (金) 18:11
Gucci shoes will be most of the best-styled boots and shoes inside trend community. From the identical vein, Delicious Couture shopping bags are a classic and also any kind of Gucci Bags woman having a perception involving style offers 1 anywhere you want. Gucci footwear http://www.officialguccibags.com/ will be masterpieces and so are unbeaten relating to his or her design plus technology. Your designers continually are most often in the realize in relation to what the heck is relevant construction business. Their boots and shoes are generally gorgeous regarding women of all ages Gucci Outlet as well as exquisite intended for guys along with this is why they might be really high priced. Happily, plenty of retailers commodity cheap Gucci shoes which can be truly simply just competitive with the particular newer models. These shoes and boots presented in a diverse choice of options for both men and women in addition to you'll find design intended for children as well. This support in quite a few online merchants stocking Gucci is actually great in addition to their particular delivery providers have grown quickly. Many people supply pieces for a front doorstep and also this company attracts a bunch of customers. The easiest way to learn related to in which low cost Gucci footwear can be found is definitely simply by examining on-line. You can also look at on-line for any most current Succulent Couture totes.
Gucci Outlet
Gucci Outlet
Gucci Outlet
Gucci Sale
Gucci Sale
投稿情報: HulaJaina | 2012年1 月28日 (土) 18:13
Besides all these, it is possible to opt for necklaces according to meals, wedding meal, fruits and so on. In actual fact, these kinds of come in a number nice Pandora Jewelry colorations which sometimes enrich ones persona any time you will Pandora Bracelets put on these individuals. Grape charms, that create grow to be any rage involving females, presented in shimmering environment friendly plus royal magenta. You are able to select the main one which in turn matches your own character, appearance along with model. If you'd like additional choices out there, you may opt for different Pandora the summer months group who has also been presented http://www.pandorabraceletsell.co.uk/ quite just lately. If you love gold jewellery, make sure you look at that Pandora Fluid Gold line of bracelets containing bought a good number of great designs created outside silver precious metal. A wide variety of coloured beans are available, yet when you are experience specifically regal or from the mood to the deeper conclude from the variety, that shade magenta is a great preference. A number of Pandora bracelet drops can be found presenting pink details as being a fundamental trait; actually, a common trouble you could possibly come across as soon as picking is likely to be whittling the choices decrease.
Pandora Charms
Pandora Bracelets
Pandora Beads
Pandora Beads
Pandora Beads
投稿情報: HulaJaina | 2012年1 月30日 (月) 18:11
Everyone knows of which manner improvements every now and then. Presently, zebra print has really developed for a superb manner pattern. Should you be a woman plus desire to bring out ones crazy aspect next zebra print coach factory outlet store add-ons can assist you. Totes and handbags are generally viewed as premier http://www.cheapcoachpursesforyou.com/ gadgets and also you can certainly buy these individuals on the market place so as to produce style affirmation. This particular write-up should cope with a few essential information relating to zebra creator handbags. Zebra artist clutches are usually rather understated when compared with giraffe plus leopard art print bags. The actual coach factory outlet combined non colored documents lashes might be considered to be large typical. Hobos, duffel, aftermarket clutches along with purses usually are some of the clutches available along with zebra imprints. There are various causes of your reputation connected with zebra art print luggage. First of all, your style and also style and design can be certainly not unexciting. It draws a variety of consideration plus readers. If you are someone exactly who consistently tries interest then this can be a appropriate tote to suit your needs! I need to show you of which this kind of wild designs may agree with that qualities on the confident lady.
coach factory store
coach factory outlet
coach outlet store
coach handbags outlet
cheap coach purses
投稿情報: HulaJaina | 2012年2 月 2日 (木) 17:19