2009年11月26日木曜日

dovecot ダウン

メールが受信できない・・・ただし送信は問題なくできる。ん?
ということで調査開始。

・環境
CentOS5.4 + Postfix 2.3.3 + Dovecot 1.0.7

・原因
maillogを検索してみると・・・
Nov 26 04:01:49 mail01 dovecot:
Time just moved backwards by 13 seconds.
This might cause a lot of problems,
so I'll just kill myself now. http://wiki.dovecot.org/TimeMovedBackwards

時刻が13秒戻りました。
これにより多くの問題を引き起こす可能性があります。
ですので、私は自分で死にます。http://wiki.dovecot.org/TimeMovedBackwards
こんなことが書かれていました。

とりあえず吐き出されているDovecot Wikiのリンク先http://wiki.dovecot.org/TimeMovedBackwardsを見てみたところ
  1. ntpdateを使っていますか?良くありません
  2. 仮想化環境を使用していますか?
と書かれていた。
このサーバは仮想環境ではないが、時刻合わせのスクリプト(ntpdateを使用)を1日1回実行されるようcron.daily内に配置している。ntpdateは一瞬にして時刻が修正されるので、これにより13秒戻ったということになる。ダウンした時刻とcron.dailyの時刻(4:02)がほぼ同じなので、これが原因のようです。

・解決方法
Dovecot Wikiによるとntpdを使用してください。とあるのでntpdサービスを使用して時刻同期を取るように変更します。
※ntpdの時間同期は、ずれを徐々に修正するような仕組みになっている。遅れているいる場合は刻み速度を早くして修正し逆に進んでいるときは刻みを遅くして修正するのでいきなり時刻がずれることはない。

インストール
# yum install ntp

設定
※タイムサーバとして稼動も可能だがとりあえず、ローカルホストの時刻同期専用とする。
# vi /etc/ntp.conf
-----------------------------------------------------------------------------
アクセス制御について
#restrict default kod nomodify notrap nopeer noquery   → コメント(IPv4)
#restrict -6 default kod nomodify notrap nopeer noquery  → コメント(IPv6)
restrict ignore → 追記(とりあえず全てのアクセスを拒否)

restrict 127.0.0.1 → ローカルホストは許可(IPv4)
#restrict -6 ::1 → ローカルホストは許可(IPv6) 使わないのでコメント

参照タイムサーバ
#server 0.centos.pool.ntp.org → コメント
#server 1.centos.pool.ntp.org → コメント
#server 2.centos.pool.ntp.org → コメント
server -4 ntp.nict.jp      → 追記(NICT)※-4 はIPv4
server -4 ntp.jst.mfeed.ad.jp → 追記(上記と同期されている)
server -4 ntp.ring.gr.jp    → 追記(Ring Server Project)

上記サーバがどれも応答しないときの参照先?よくわかりません
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
-----------------------------------------------------------------------------
 
restrictで始まる行は指定したホストに対してのNTPアクセスを制御します。またrestrictは最後の設定条件で有効になるので、最初に全拒否をして接続を許可していくスタイルになります。


  • ignore:全てのパケットを拒否
  • noquery:クエリーを拒否
  • nomodify:設定変更のクエリーを拒否
などがあるようです。詳しくはこちらを参照してください。

・起動
時刻差が大幅にあると起動できないため、一度手動で合わせる。
# ntpdate ntp.nict.jp
 
開始
# /etc/init.d/ntpd start
 
自動起動
# chkconfig ntpd on
# chkconfig --list ntpd
ntpd     0:off  1:off  2:on  3:on  4:on  5:on  6:off

・確認
# ntpq -p
 
 
 
 
 
 
remote列の左側にある"*"は同期中で、"+"がいつでも使用できることを表しています。
尚、開始後に同期するまで5~10分程度必要です。
これで時刻が急に変化することがなくなりましたので大丈夫でしょう。
 

2009年11月24日火曜日

Redmine アップデート(0.8.6→0.8.7)

CentOS5.4 + PostgreSQL 8.2.5の環境でアップデート
※MySQL環境でも同じ手順でOKです

まずはインストール先へ移動
# cd /home/redmine

レポジトリからチェックアウト
# svn update
U test/unit/helpers/application_helper_test.rb
U test/functional/timelog_controller_test.rb
U test/integration/admin_test.rb
U test/integration/account_test.rb
U app/controllers/timelog_controller.rb
U app/controllers/application.rb
U app/controllers/account_controller.rb
U app/views/wiki/export_multiple.rhtml
U app/views/wiki/export.rhtml
U config/initializers
U config/environments/test.rb
U config/environments/test_sqlite3.rb
U config/environments/test_pgsql.rb
U doc/INSTALL
U doc/CHANGELOG
U lib/redmine/version.rb
A lib/tasks/initializers.rake
U lib/redcloth3.rb
U public/themes/alternate/stylesheets/application.css
Updated to revision 3085.

マイグレーション
# rake db:migrate RAILS_ENV="production"
(in /home/redmine)
rake aborted!
Missing session secret. Please run 'rake config/initializers/session_store.rb' to generate one

(See full trace by running task with --trace)

あれ?失敗した模様・・・なにやらsession_store.rbを実行?
先にこれを実行するんですね。
# rake config/initializers/session_store.rb
(in /home/redmine)

再度マイグレーション
# rake db:migrate RAILS_ENV="production"
(in /home/redmine)

今度は大丈夫みたい

情報が以下のように変わりました。
Redmine 0.8.7.stable.3085 (PostgreSQL)
 

2009年11月20日金曜日

Windows Server 2008 R2 Standard

新しいHyper-V(2.0)を試すため2008 R2をとりあえずフルインストールで構築してみました。
ServerCoreの環境ではGUIによる役割追加ができませんのでフルインストールした方が簡単でお勧めです。

ハードウェア

  • 本体:Dell PowerEdge SC1435
  • CPU:AMD Opteron 2376(2.3GHz/6MB L3キャッシュ) × 2
  • メモリ:4GB(DDR2/667MHz 1GB×4)
  • HDD:160GB×2 RAID1構成(3.5インチSATAⅡ 7200RPM)


 
とりあえずOSは完了しました。
後日Hyper-Vを追加してCentOSでも入れてみることにしよう。
 

2009年11月16日月曜日

FortiGuard スパムデータベース

http://www.fortinet.co.jp/support/antispam.html

ここではIPアドレス、Eメールアドレス、メール本文中のURLなどでスパムのブラックリスト検索が行えます。



2009年11月13日金曜日

BitNami::Redmine 0.8.6対応版

WindowsPCに簡単構築できるオールインワンタイプのRedmine
BitNami::RedmineがRedmine0.8.6に対応したようですね。

Windows版はもちろんのことLinuxやMac用のインストーラもありますが、VMWare等で使用するVMDK形式の仮想マシンまで用意されておりOSはOpenSUSE 11.1で構成されているようです。

BITNAMIへはこちらからどうぞ。
 

2009年11月11日水曜日

バラクーダレピュテーションブロックリスト(BRBL)

セキュリティ製品の発売元でもあるバラクーダネットワークスが無料のDNSBLを提供しているみたいです。提供元が信頼できるのでこのDNSBLをPostfixで使ってみます。

もし使用する方は、くれぐれも自己責任でお願いします

無料ではあるがDNSの登録が必要ですのでまず登録をします。
http://www.barracudacentral.org/ を開き左側のメニューからBRLB>Request Accessを選択します。



Login Information(ログイン情報)
  • Email Address:ログインアカウント
  • Password:パスワード
  • Confirm Password:パスワードを再入力
Contact Information(メイン問い合わせ情報)
  • Name:(氏名)
  • Company:(会社名)
  • Address 1:(番地)
  • Address 2:(町名)
  • City:(市や区)
  • Country:(Japanを選択)
  • State/Province:(都道府県)
  • Zip/Postal Code:(郵便番号)
  • Phone Number:(電話番号 +81-****-****)
  • Alternate Email Address:(サブ連絡用E-Mailアドレス)
Alternate Contact Information(サブの問い合わせ情報)
※空はダメみたいです。面倒なのでメインと同じにしてしまいました。
  • Name:(氏名)
  • Phone Number:(電話番号 +81-****-****)
  • Email Address:(連絡E-Mailアドレス)
  • Alternate Email Address:(サブ連絡用E-Mailアドレス)
Access Information(アクセス情報)
  • IP Addresses:自前DNSサーバのIPアドレスを入力(複数あればカンマ区切りで10までOK)

It's OK to email me with BarracudaCentral.org updatesにチェックを入れsubmitを押します。

しばらくするとログイン情報で入力したメールアドレス宛に以下のようなメールが届きます。
-----------------------------------------
Hello,


Thank you for your interest in the Barracuda Reputation Block List (BRBL). Please click on the link below to verify the status of your account and to begin accessing the BRBL.

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓このURLをクリックする↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
http://www.barracudacentral.org/account/verify/~/*********

The Barracuda Reputation System is a compilation of the most sophisticated IP analysis techniques and is one of 12 defense layers included in the Barracuda Spam Firewall. Click here to learn more.

Thank you,

BarracudaCentral.org
-----------------------------------------
 
これで登録は完了ですので使えるかテストしてみましょう。
 
設定するメールサーバ上で以下のコマンドを入力して結果を見ます。
$ host 2.0.0.127.b.barracudacentral.org
2.0.0.127.b.barracudacentral.org has address 127.0.0.2  ← 成功
  

以下のようならば失敗となります
Host 2.0.127.b.barracudacentral.org not found: 3(NXDOMAIN) ← 失敗
 
 
成功を確認後main.cfを編集
※当環境での設定ですので注意
# vi /etc/postfix/main.cf
smtpd_client_restrictions =
 permit_mynetworks
 permit_sasl_authenticated
 reject_rbl_client b.barracudacentral.org ← 追記
 permit
 
ログ(/var/logs/maillog)
 postfix/smtpd[24805]: NOQUEUE: reject: RCPT from unknown[**.**.***.**]: 554 5.7.1 Service unavailable; Client host [**.**.***.**] blocked using b.barracudacentral.org; http://www.barracudanetworks.com/reputation/?pr=1&ip=**.**.***.**; from=root@sample.com to= proto=ESMTP helo=<[**.**.***.**]>
postfix/smtpd[24805]: disconnect from unknown[**.**.***.**]
 

2009年11月10日火曜日

Redmine アップデート(0.8.3→0.8.6)

Redmine 0.8.6がリリースされてました。
当環境ではSubversionリポジトリからのチェックアウトしているので、Subversionリポジトリから更新します。(CentOSに構築した手順はこちらです)

まずredmineのソースが配置されているディレクトリに移動します。(当環境では/home/redmine)
#cd /home/redmine/

svnコマンドで更新ファイルを取得
# svn update
U test/unit/helpers/application_helper_test.rb
U test/unit/mail_handler_test.rb
U test/unit/query_test.rb
U test/functional/issues_controller_test.rb
U test/functional/news_controller_test.rb
U test/functional/account_controller_test.rb
U test/functional/projects_controller_test.rb
A test/fixtures/mail_handler/ticket_with_spaces_between_attribute_and_separator.eml
U test/fixtures/journals.yml
U test/fixtures/users.yml
U test/fixtures/attachments.yml
U app/helpers/application_helper.rb
U app/models/mail_handler.rb
U app/models/query.rb
U app/models/changeset.rb
G app/controllers/issues_controller.rb
U app/controllers/timelog_controller.rb
U app/controllers/messages_controller.rb
U app/controllers/news_controller.rb
U app/controllers/account_controller.rb
U app/controllers/wiki_controller.rb
U app/views/journals/_notes_form.rhtml
U app/views/users/_memberships.rhtml
U app/views/versions/show.rhtml

データベースのマイグレーション(テーブル作成)
# rake db:migrate RAILS_ENV="production"
(in /home/redmine)

キャッシュのクリア
# rake tmp:cache:clear
(in /home/redmine)

セッションのクリア
# rake tmp:sessions:clear
(in /home/redmine)

Apacheを再起動

Redmineにログインして「管理」>「情報」を開きます。
Redmine 0.8.6.stable.3023 (MySQL)となりました。
※DBにPostgreSQLが使用されているときはRedmine 0.8.6.stable.3023 (PostgreSQL)となる。
 

2009年11月6日金曜日

PostfixによるtaRgrey その2

その1からの続きです。

その1ではPostfixの基本構築が完了、これからtaRgreyの設定を行っていきますが、taRgreyでは S25R+tarpitting+greylisting というスパム判定手法を組み合わせて使います。S25Rにて動的IPらしき場合は怪しいと判断してtarpitting(指定時間の遅延処理)を行います。待ちきれず接続を切断されてもすぐにはsmtpdプロセスが終了しません。遅延中に相手が接続を切ったらsmtpdプロセスもすぐに終了するようにPostfixにパッチを適用します。

Postfixのパッチ(メモリ消費を抑える効果がある)
PostfixのSRPM(ソースファイル)をyumからダウンロードするためyum-utilsをインストール
# yum install yum-utils

yumのBaseレポジトリに追記
# vi /etc/yum.repos.d/CentOS-Base.repo
 [base-source]
 name=CentOS-$releasever - Base Source
 baseurl=http://mirror.centos.org/centos/$releasever/os/SRPMS/
 gpgcheck=1
 enabled=1
 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
 
 [updates-source]
 name=CentOS-$releasever - Updates Source
 baseurl=http://mirror.centos.org/centos/$releasever/updates/SRPMS/
 gpgcheck=1
 enabled=1
 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

 [extras-source]
 name=CentOS-$releasever - Extras Source
 baseurl=http://mirror.centos.org/centos/$releasever/extras/SRPMS/
 gpgcheck=1
 enabled=1
 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5


PostfixのSRPMダウンロード
# yumdownloader --noplugins --source postfix

SRPMの展開
# rpm -ivh postfix-2.3.3-2.1.el5_2.src.rpm (警告が出るが気にしない)

SRPM展開先ディレクトリへ移動
# cd /usr/src/redhat/SOURCES/

ソースの展開
# tar zxvf postfix-2.3.3.tar.gz

展開ディレクトリへ移動
# cd postfix-2.3.3

パッチのダウンロード
# wget http://k2net.hakuba.jp/pub/postfix-sleep.patch

パッチの適用
# patch -p1 < postfix-sleep.patch

上位ディレクトリへ移動
# cd ../

ソースの再アーカイブ化(パッチを適用する前のソースを削除してから再アーカイブ)
# rm -rf postfix-2.3.3.tar.gz && tar czvf postfix-2.3.3.tar.gz postfix-2.3.3

ソース展開先ディレクトリを削除
# rm -rf postfix-2.3.3

ホームディレクトリへ
# cd

PostfixのRPMパッケージを作成
# rpmbuild -bb --clean --define "dist .`echo postfix-*.src.rpm |awk -F. '{print $(NF-2)}'`" /usr/src/redhat/SPECS/postfix.spec
※1行で記述する

作成したRPMパッケージをインストール(アップデート)
# rpm -Uvh --force /usr/src/redhat/RPMS/i386/postfix-2.3.3-2.1.el5_2.i386.rpm

ソースファイル、specファイルの削除
# rpmbuild --rmsource --rmspec /usr/src/redhat/SPECS/postfix.spec

作成したRPMパッケージの削除
# rm -rf /usr/src/redhat/RPMS/i386/postfix-*

ダウンロードしたSRPMの削除
# rm -rf postfix-2.3.3-2.1.el5_2.src.rpm


Postgreyのインストール

PostgreyのSRPMダウンロード
# wget http://apt.sw.be/redhat/el5/en/SRPMS.rpmforge/postgrey-1.32-1.rf.src.rpm

SRPMの展開
# rpm -ivh postgrey-1.31-1.rf.src.rpm(警告が出るが気にしない)

SRPM展開先ディレクトリへ移動
# cd /usr/src/redhat/SOURCES/

ソースの展開
# tar zxvf postgrey-1.32.tar.gz

展開ディレクトリへ移動
# cd postgrey-1.32

パッチをダウンロード(postgreyのバージョンに注意)
# wget http://k2net.hakuba.jp/pub/targrey-0.31-postgrey-1.32.patch

パッチの適用
# patch -p0 < targrey-0.31-postgrey-1.32.patch

上位ディレクトリへ移動

# cd ../

ソースの再アーカイブ化(パッチを適用する前のソースを削除してから再アーカイブ)
# rm -f postgrey-1.32.tar.gz && tar czvf postgrey-1.32.tar.gz postgrey-1.32

ソース展開先ディレクトリを削除
# rm -rf postgrey-1.32

ホームディレクトリへ
# cd

PostgreyのRPMパッケージを作成
# rpmbuild -bb --clean /usr/src/redhat/SPECS/postgrey.spec

Postgrey依存パッケージをインストールためrpmforgeリポジトリを利用
# rpm-ivh http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

yumで自動updateされないよう制御
# vi /etc/yum.repos.d/rpmforge.repo
 enabled = 1 ← 0に変更する

依存パッケージのインストール(Postgreyをインストールして即削除)
# yum -y --enablerepo=rpmforge install postgrey && rpm -e postgrey
 
作成したPostgreyのRPMパッケージをインストール
# rpm -ivh /usr/src/redhat/RPMS/noarch/postgrey-1.32-1.rf.noarch.rpm
 
作成したRPMパッケージの削除
# rm -rf /usr/src/redhat/RPMS/i386/postgrey-*

ダウンロードしたSRPMの削除
# rm -rf postgrey-1.31-1.rf.src.rpm

taRgreyの解説ページから設定例を取得
# wget http://k2net.hakuba.jp/spam/postfix.conf.2.tar.gz
# tar zxvf postfix.conf.2.tar.gz

一部のファイルをコピー
# cp postfix.conf.2/whitelist_recipient /etc/postfix/

# cp postfix.conf.2/whitelist_client /etc/postfix/
# cp postfix.conf.2/permit_client_nots25r /etc/postfix/

whitelist_recipient とwhitelist_client はDB参照となるためDB化
# postmap /etc/postfix/whitelist_recipient

# postmap /etc/postfix/whitelist_client

DBがあるか確認
# ls /etc/postfix
whitelist_client.db     whitelist_recipient.db (この2つを確認)

Postfixの設定変更

Postfixの設定変更
# vi /etc/postfix/main.cf
 smtpd_recipient_restrictions =
  permit_mynetworks
  reject_unauth_destination
  reject_non_fqdn_recipient
  check_recipient_access hash:$config_directory/whitelist_recipient ← 追記
  check_client_access hash:$config_directory/whitelist_client ← 追記
  check_client_access regexp:$config_directory/permit_client_nots25r ← 追記
  check_policy_service inet:60000 ← 追記

#以下全文追記
smtpd_data_restrictions =
  permit_mynetworks
  reject_unauth_destination
  check_recipient_access hash:$config_directory/whitelist_recipient
  check_client_access hash:$config_directory/whitelist_client
  check_client_access regexp:$config_directory/permit_client_nots25r
  check_policy_service inet:60000
  permit


main.cfの入力を終了します。

※解説
smtpd_recipient_restrictionsでの一度目のcheck_policy_serviceでtarpittingを掛け、一旦tarpittingブラックリストに登録されます。

tarpittingを抜けた接続はsmtpd_data_restrictionsまで渡ってくるため、再度check_policy_serviceで呼び出し、tarpittingのブラックリストから削除します。
tarpittingのブラックリストに入っているIPからの接続から再送された場合、tarpittingの処理には回さずに、greylistingの処理に回ります。



Postgreyの起動モードを指定(taRgreyモード 125秒)
# vi /etc/init.d/postgrey
 #OPTIONS="--unix=$SOCKET" ← コメント化
 OPTIONS="--dbdir=$DBPATH --inet=127.0.0.1:60000 --tarpit=125 --targrey --retry-count=2 --delay=3600"

Postgreyの起動
# /etc/init.d/postgrey start

Postgreyの自動起動
# chkconfig postgrey on

Postfixの再起動
# /etc/init.d/postfix restart

Postfixがyum cronで自動アップデートしないよう制御
# vi /etc/yum.conf
 [main]内に以下を記述する
 exclude=postfix*


以上でtaRgreyの環境は完了です。

 

PostfixによるtaRgrey その1

自前のメールサーバが負荷に耐え切れなくなり?頻繁にカーネルパニックを起こすようになってしまった。スペックの低いこともあり新たにDell R610を購入して再構築しました。

スパム対策として今まで特定の国からのパケット破棄・Rgrey(S25R + greylisting)でしたが、今回はtaRgrey(S25R + tarpitting + greylisting)でスパム対策することにしました。
※RgreyやtaRgreyについての説明は省きます。詳しくはこちらを参照してください。
アンチウイルス等ファイアウォールについてはFortiGateで行うためここでは考慮しません。

ハードウェア
  • 本体:Dell PowerEdge R610
  • CPU:Intel(R) Xeon E5502(1.86GHz)
  • メモリ:4GB(DDR3 2GB×2)
  • HDD:146GB×2 RAID1構成(2.5インチSAS 10000RPM) ※ホットプラグ対応
  • 電源:717W
ソフトウェア
  • OS:CentOS-5 (5.4)
  • SMTP:Postfix(2.3.3)
  • POP:Dovecot(1.0.7) ※IMAP対応
  • その他:Postgrey(1.32)
メール使用ユーザには/home/UserName/の下にMaildirディレクトリが必要となります。メールユーザ追加するたびMaildirを手動で作成するのは面倒なので、ユーザが追加されたと同時にメールディレクトリを作成するようにしておきます。
# mkdir /etc/skel/Maildir
# chmod 700 /etc/skel/Maildir
初回送受信時にMaildirの配下にNew(新着メール)、Cur(既読メール)、Tmp(配送中メール)が作られます。

Postfixのインストール
# yum install postfix

設定ファイル編集(変更や追記部分のみ表記)
# vi /etc/postfix/main.cf

FQDN形式でのホスト名(DNSで名前解決できるもの)
myhostname = mail.exsmple.com

自身のドメイン名
mydomain = exsmple.com

ローカルから発せられるメールのUserName@以降に付与
myorigin = $myhostname

待ち受けるネットワーク(ローカル、LANなど全て)
inet_interfaces = all

ローカルで受信するドメイン名およびそのサブドメイン(必要に応じてカンマ区切りで追記)
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, www.$mydomain

ローカルで受信するユーザの存在マッピング
local_recipient_maps = unix:passwd.byname $alias_maps

ローカルのユーザが存在しないときのエラー
※安定するまで450(再送信依頼)で対応、その後は550(存在しません)で拒否するのがよい。
450で返すと正常なMTAは30分後ぐらいに送信してくる。
unknown_local_recipient_reject_code = 450

権限の与えられるクライアントネットワーク定義(接続や中継を許可するなどに利用)
mynetworks = 10.1.0.0/16, 127.0.0.0/8

メールのリレーを許可するドメインおよびそのサブドメイン
relay_domains = $mydestination

メールボックスの形式
home_mailbox = Maildir/  ※スラッシュを付け忘れないこと

ヘッダチェックなどの制限等をする定義ファイル(後でheader_checksファイルを編集)
header_checks = regexp:/etc/postfix/header_checks

メールサーバソフトの隠蔽化
smtpd_banner = ESMTP unknown

ここまでが基本設定となります。
このままでも稼動させることができますが、セキュリティ強化の設定を追記していきます。

vrfyコマンドを無効(ユーザが存在するかどうか問い合わせをさせない)
disable_vrfy_command = yes

HELO(EHLO)コマンドで自己紹介を要求(ホスト名を通知しない接続を拒否する)
smtpd_helo_required = yes

RFC821の形式に合わないアドレスは拒否
strict_rfc821_envelopes = yes

HELOコマンドの場面で適用される制限
smtpd_client_restrictions =
permit_mynetworks           mynetworksで定義したネットワークは許可
reject_rbl_client bl.spamcop.net    外部ブラックリストに登録されている接続先は拒否
permit                  それ以外は許可

SMTP HELO(EHLO)コマンドの場面で適用される制限
smtpd_helo_restrictions =
permit_mynetworks           mynetworksで定義したネットワークは許可
reject_unknown_hostname       ホスト名のDNSでAまたはMXレコードない場合は拒否
reject_invalid_hostname         ホスト名の文法が不正の場合は拒否
reject_non_fqdn_hostname       ホスト名がFQDN形式ではない場合に拒否

  ※reject_unknown_hostname、reject_invalid_hostname、reject_non_fqdn_hostnameについては正常なホストでも"DNSで解決できない" "FQDN形式ではない"場合が多いため適用しないほうがよいと思われます。

SMTP Mail Fromコマンドの場面で適用される制限
smtpd_sender_restriction =
reject_non_fqdn_sender      送信者メールアドレスがFQDN形式でない場合は拒否           
reject_unknown_sender_domain 送信者メールアドレスのドメインが存在しない場合は拒否
permit                それ以外は許可

RCPT TOコマンドの場面で適用される制限
smtpd_recipient_restrictions =
permit_mynetworks        mynetworksで定義したネットワークは許可
reject_non_fqdn_recipient    受信者メールアドレスがFQDN形式でない場合は拒否
reject_unauth_destination     受信者メールアドレスがmydestinationに属さない宛先は拒否

main.cfの入力を終了します。

header_checksファイルの編集(追記)
# vi /etc/postfix/header_checks

ヘッダのReceived部分を非表示
/^Received:/ IGNORE

大量送信用特殊メーラーからのメールを拒否(他にも色々あります)
/^X-Mailer:.*PostMaster General/ REJECT

GMTを利用して特定地域からのメールを拒否
例)ブラジル(フェルナンド ノローニャ諸島)地域
/^Date:.*-1100/ REJECT

header_checksの入力を終了します。

CentOSではMTAのデフォルトがsendmailのためデフォルトMTAをPostfixへ切り替えます。
まずsendmailを止めて自動起動しないようにします。
# /etc/init.d/sendmail stop
# chkconfig sendmail off
# alternatives --config mta
There are 2 programs which provide 'mta'.

Selection Command
-----------------------------------------------
* + 1 /usr/sbin/sendmail.sendmail ← 現在sendmailがMTAとなっている
2 /usr/sbin/sendmail.postfix ← postfixもあり
Enter to keep the current selection[+], or type selection number:2 ←2を入力

Postfixの起動
#/etc/init.d/postfix start

Postfixの自動起動を有効にする
# chkconfig postfix on
# chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off ※2,3,4,5がONになっていれば問題なし

Postfixの基本環境は完了です。
その2でPostgrey等のインストール・設定を行います。

その2へ

2009年11月4日水曜日

DELL R610 RAIDドライバ

CentOS5 にてSAS 6/iR Integratedのドライバをアップデートします。

DELLから新しいドライバをダウンロードします。
# wget http://ftp1.us.dell.com/sas-raid/R211003-mptlinux-4.00.38.02-3.tar.gz
# tar zxvf R211003-mptlinux-4.00.38.02-3.tar.gz
dkms-2.0.19.1-1.noarch.rpm
mptlinux-4.00.38.02-3dkms.noarch.rpm
mptlinux-4.00.38.02-src.tar.gz
mptlinux-4.00.38.02.txt

DKMSパッケージとドライバをインストールします。
※DKMS (Dynamic Kernel Module Support) は、カーネルのアップグレード時にモジュールを簡単に再構築するために設計されています。この再構築のために、カーネルに依存するモジュール ソースが常駐できるフレームワークを作成します。
# rpm -ivh dkms-2.0.19.1-1.noarch.rpm
warning: dkms-2.0.19.1-1.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 23b66a9d

Preparing... ########################################### [100%]
1:dkms ########################################### [100%]
 
# rpm -ivh mptlinux-4.00.38.02-3dkms.noarch.rpm
Preparing... ########################################### [100%]
 1:mptlinux ########################################### [100%]
Creating symlink /var/lib/dkms/mptlinux/4.00.38.02/source ->
 /usr/src/mptlinux-4.00.38.02
DKMS: add Completed.
Module build for the currently running kernel was skipped since the
kernel source for this kernel does not seem to be installed.
現在使用中のドライバがあるため再起動が必要です。

# shutdown -r now

新しいカーネルにアップグレードする場合は、DKMS が有効に設定されたドライバパッケージを再インストールする必要があるため以下のコマンドを使います。
dkms build -m <モジュール名> -v <モジュールのバージョン> -k <カーネルのバージョン>
dkms install -m <モジュール名> -v <モジュールのバージョン> -k <カーネルのバージョン>

# dkms build -m mptlinux -v 4.00.38.02 -k 2.6.18-164.el5 --kernelsourcedir=/usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386/
# dkms install -m mptlinux -v 4.00.38.02 -k 2.6.18-164.el5 --kernelsourcedir=/usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386/

# modinfo mptsas
filename: /lib/modules/2.6.18-164.el5/extra/mptsas.ko

version: 4.00.38.02
license: GPL
description: Fusion MPT SAS Host driver
author: LSI Corporation
srcversion: E51EE0D539AEBDC23494300
alias: pci:v00001000d00000062sv*sd*bc*sc*i*
alias: pci:v00001000d00000058sv*sd*bc*sc*i*
alias: pci:v00001000d00000056sv*sd*bc*sc*i*
alias: pci:v00001000d00000054sv*sd*bc*sc*i*
alias: pci:v00001000d00000050sv*sd*bc*sc*i*
depends: mptscsih,mptbase
vermagic: 2.6.18-164.el5 SMP mod_unload 686 REGPARM 4KSTACKS gcc-4.1
parm: mpt_pt_clear: Clear persistency table: enable=1 (default=MPTSCSIH_PT_CLEAR=0) (int)
parm: mpt_cmd_retry_count: Device discovery TUR command retry count: default=144 (int)
parm: mpt_disable_hotplug_remove: Disable hotpug remove events: default=0 (int)
parm: mpt_sdev_queue_depth: Max Device Queue Depth (default=64)
parm: max_lun: max lun, default=16895 (int)

# dkms status
mptlinux, 4.00.38.02, 2.6.18-164.el5, i686: installed (original_module exists)
mptlinux, 4.00.38.02, 2.6.18-164.2.1.el5, i686: installed-weak from 2.6.18-164.el5

Google検索