後日、順番を入れ替えました。詳しくは
こちら。
1. ポート開放の前に各種セキュリティ対策。
※ファイル改竄検知システム導入(Tripwire)
※rootkit検知ツール導入(chkrootkit)
※アンチウィルスソフト導入(Clam AntiVirus)
※ファイアウォール構築(iptables)
2. ポート開放。
引用元:
http://www.obenri.com/_network/routerset1.html 1.インターネットへ接続の設定。
2.WAN側の ゲートウェイアドレス の設定。
3.LAN側の サブネット の設定。
4.LAN側の DHCPサーバー の設定。
5.WAN←→LANの NAT + IPマスカレード の設定。
6.LAN→WANの バケットフィルタリング の設定。
7.WAN→LANの ポートフォワーディング の設定。
3. ドメイン取得。
4. 各種サーバーのインストール
ウェブサーバー(apache)
ファイルサーバー(Samba)
DHCPサーバー
DNSサーバー(bind)
NTPサーバー(ntpd)
SMTPサーバー(sendmail、または、Postfix)
POP3サーバー(Dovecot)
FTPサーバー(vsftpd)
/************************************************************
*Tripwireのインストール
************************************************************/
yum -y install wget
yum -y install bzip2
yum -y install gcc
yum -y install gcc-c++
yum -y install make
wget http://jaist.dl.sourceforge.net/sourceforge/tripwire/tripwire-2.4.2.2-src.tar.bz2
tar jxvf tripwire-2.4.2.2-src.tar.bz2
cd tripwire-2.4.2.2-src
./configure --prefix=/usr/local/tripwire sysconfdir=/etc/tripwire && make && make install
****** site :passwd
****** local:passwd
cd
rm -rf tripwire-2.4.2.2-src
rm -f tripwire-2.4.2.2-src.tar.biz
echo PATH=$PATH:/usr/local/tripwire/sbin >> .bashrc ; source .bashrc
/************************************************************
*Tripwireの設定
************************************************************/
vi /etc/tripwire/twcfg.txt
LOOSEDIRECTORYCHECKING =true
REPORTLEVEL =4
twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
rm -f /etc/tripwire/twcfg.txt
vi /etc/tripwire/twpolmake.pl
==================▼copy▼======================
#!/usr/bin/perl
# Tripwire Policy File customize tool
# ----------------------------------------------------------------
# Copyright (C) 2003 Hiroaki Izumi
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# ----------------------------------------------------------------
# Usage:
# perl twpolmake.pl {Pol file}
# ----------------------------------------------------------------
#
$POLFILE=$ARGV[0];
open(POL,"$POLFILE") or die "open error: $POLFILE" ;
my($myhost,$thost) ;
my($sharp,$tpath,$cond) ;
my($INRULE) = 0 ;
while (
) {
chomp;
if (($thost) = /^HOSTNAME\s*=\s*(.*)\s*;/) {
$myhost = `hostname` ; chomp($myhost) ;
if ($thost ne $myhost) {
$_="HOSTNAME=\"$myhost\";" ;
}
}
elsif ( /^{/ ) {
$INRULE=1 ;
}
elsif ( /^}/ ) {
$INRULE=0 ;
}
elsif ($INRULE == 1 and ($sharp,$tpath,$cond) = /^(\s*\#?\s*)(\/\S+)\b(\s+->\s+.+)$/) {
$ret = ($sharp =~ s/\#//g) ;
if ($tpath eq '/sbin/e2fsadm' ) {
$cond =~ s/;\s+(tune2fs.*)$/; \#$1/ ;
}
if (! -s $tpath) {
$_ = "$sharp#$tpath$cond" if ($ret == 0) ;
}
else {
$_ = "$sharp$tpath$cond" ;
}
}
print "$_\n" ;
}
close(POL) ;
==================▲copy▲======================
perl /etc/tripwire/twpolmake.pl /etc/tripwire/twpol.txt > /etc/tripwire/twpol.txt.new
twadmin -m P -c /etc/tripwire/tw.cfg -p /etc/tripwire/tw.pol -S /etc/tripwire/site.key /etc/tripwire/twpol.txt.new
rm -f /etc/tripwire/twpol.txt*
tripwire --init 初期化
tripwire -m i -s -c /etc/tripwire/tw.cfg データベース作成
tripwire -m c -s -c /etc/tripwire/tw.cfg Tripwireチェック実行
echo test > test.txt 試しにテストファイルを作成する
tripwire -m c -s -c /etc/tripwire/tw.cfg 【再】Tripwireチェック実行
rm -f test.txt テストファイル削除(後始末)
vi tripwire.sh Tripwire定期自動実行スクリプト作成
==================▼copy▼======================
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/bin:/usr/local/tripwire/sbin
# パスフレーズ設定
LOCALPASS=xxxxxxxx # ローカルパスフレーズ
SITEPASS=xxxxxxxx # サイトパスフレーズ
cd /etc/tripwire
# Tripwireチェック実行
tripwire -m c -s -c tw.cfg|mail -s "Tripwire(R) Integrity Check Report in `hostname`" root
# ポリシーファイル最新化
twadmin -m p -c tw.cfg -p tw.pol -S site.key > twpol.txt
perl twpolmake.pl twpol.txt > twpol.txt.new
twadmin -m P -c tw.cfg -p tw.pol -S site.key -Q $SITEPASS twpol.txt.new > /dev/null
rm -f twpol.txt* *.bak
# データベース最新化
rm -f /usr/local/tripwire/lib/tripwire/*.twd*
tripwire -m i -s -c tw.cfg -P $LOCALPASS
==================▲copy▲======================
chmod 700 tripwire.sh Tripwire定期自動実行スクリプトへ実行権限付加
echo "0 3 * * * root /root/tripwire.sh" > /etc/cron.d/tripwire Tripwire定期自動実行設定追加