サーバー設定 · 3 min read · Oct 13, 2025
完璧なSpamSnake - Ubuntu Jeos 12.04 LTS Precise Pangolin
完璧なSpamSnake - Ubuntu Jeos 12.04 LTS Precise Pangolin
著者: Rocky
バージョン: 5
Postfix w/Bayesian Filtering, Postscreen, Postfix Recipient Callout (Relay Recipients via look-ahead Optional), Nginx/Uwsgi, Mysql, Dnsmasq, MailScanner (Spamassassin, ClamAV, Pyzor, Razor, DCC-Client), Baruwa, SPF Checks, FuzzyOcr, Sanesecurity Signatures, Greyfix, KAM, Scamnailer, FireHOL (Iptables Firewall), Relay Recipients Script (Optional), Webmin (Optional), Outgoing Disclaimer with alterMIME (Optional)
このチュートリアルでは、ゲートウェイモードでスパムフィルターとしてUbuntu Jeosベースのサーバーを設定する方法を示します。最終的には、クリーンなメールをMTAに中継するSpamSnakeゲートウェイが完成します。また、受信キューを表示し、SpamSnakeをトレーニングし、Baruwaを介していくつかの高度な操作を実行することもできます。
これがあなたにとって機能することを保証することはできません。私にとって機能しているのと同じように。
以下のソフトウェアを使用します:
• ウェブサーバー: Nginx v1.1.19/Uwsgi v1.0.3
• データベースサーバー: MySQL v5.5.28
• メールサーバー: Postfix v2.9.3
• キャッシングDNSサーバー: Dnsmasq 2.59
• フィルター: MailScanner v4.84.5-3
• フロントエンド: Baruwa v1.1.2-4sn
クレジットはHowToForgeの皆さんとMailScanner、Baruwa、Clamav、Nginx/Uwsgi、Mysql、Postfix、Spamassassin、Razor/Pyzor/DCC、Fireholの開発者にあります。
基本インストール
- 最小vmオプションをインストール
ホスト名をserver1に設定 - デフォルトのガイド付きパーティション方法
- ユーザーを設定:
u: administrator
p: password
暗号化なし - 自動更新なし
- OpenSSHをインストール
インストール後
1. ルート権限を取得
以下を実行してルートログインを有効にし、ルートにパスワードを設定します。これで、直接ルートとしてログインできます:
sudo passwd root2. ネットワークを構成
UbuntuインストーラーがDHCP経由でネットワーク設定を取得するようにシステムを構成したため、サーバーには静的IPアドレスが必要です。/etc/network/interfacesを編集し、必要に応じて調整します(この例ではIPアドレス192.168.0.100を使用します):
vi /etc/network/interfaces次のようにします:
# このファイルは、システムで利用可能なネットワークインターフェースと、それらをアクティブにする方法を説明します。
# 詳細については、interfaces(5)を参照してください。
# ループバックネットワークインターフェース
auto lo
iface lo inet loopback
# プライマリネットワークインターフェース
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 192.168.0.1その後、ネットワークを再起動します:
/etc/init.d/networking restartvi /etc/hosts次のようにします:
127.0.0.1 localhost.localdomain localhost
192.168.0.100 server1.example.com server1
# 次の行は、IPv6対応ホストにとって望ましいです
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts次に実行します:
echo server1.example.com > /etc/hostname
reboot nowその後、実行します:
hostname
hostname -f両方ともserver1.example.comを表示するはずです。
3. デフォルトシェルを変更
/bin/shは/bin/dashへのシンボリックリンクですが、/bin/dashではなく/bin/bashが必要です。したがって、次のようにします:
dpkg-reconfigure dashdashを/bin/shとしてインストールしますか? <– いいえ
後で必要になるいくつかのパッケージと要件をインストールします:
apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev libcompress-raw-zlib-perl libdb4.8-dev libpcre3 libpopt-dev lynx m4 make ncftp nmap openssl perl perl-modules unzip zip zlib1g-dev autoconf automake1.9 libtool bison autotools-dev g++ build-essential telnet wget gawk -y4. キャッシングDnsmasq
apt-get install dnsmasq -yvi /etc/dnsmasq.confDnsmasqがlocalhostでリッスンするようにします:
listen-address=127.0.0.15. Mysqlをインストール
apt-get install mysql-client mysql-server libdbd-mysql-perl -y MySQLのルートユーザーのパスワードを提供するように求められます。このパスワードは、ユーザーroot@localhostと[email protected]の両方に有効ですので、後でMySQLのルートパスワードを手動で指定する必要はありません:
MySQLの「root」ユーザーの新しいパスワード: <– yourrootsqlpassword
MySQLの「root」ユーザーのパスワードを再入力: <– yourrootsqlpassword
6. Postfixをインストール:
apt-get install postfix postfix-mysql postfix-doc procmail -y2つの質問がされます。次のように答えます:
メール構成の一般的なタイプ: –> インターネットサイト
システムメール名: –> server1.example.com
Postfixを停止します:
postfix stopvi /etc/postfix/master.cf次のようにします:
pickup fifo n - - 60 1 pickup
-o content_filter=
-o receive_override_options=no_header_body_checksmain.cfを編集:
vi /usr/src/postfix.sh次の内容で:
#!/bin/sh
postconf -e "alias_maps = hash:/etc/aliases"
newaliases
postconf -e "myorigin = domain.tld"
postconf -e "myhostname = server1.domain.tld"
postconf -e "mynetworks = 127.0.0.0/8, 192.168.0.0/24"
postconf -e "message_size_limit = 10485760"
postconf -e "local_transport = error:No local mail delivery"
postconf -e "mydestination = "
postconf -e "local_recipient_maps = "
postconf -e "relay_domains = mysql:/etc/postfix/mysql-relay_domains.cf"
postconf -e "relay_recipient_maps = mysql:/etc/postfix/mysql-relay_recipients.cf"
postconf -e "transport_maps = mysql:/etc/postfix/mysql-transports.cf"
postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
postconf -e "disable_vrfy_command = yes"
postconf -e "strict_rfc821_envelopes = no"
postconf -e "smtpd_banner = $myhostname ESMTP SpamSnake"
postconf -e "smtpd_delay_reject = yes"
postconf -e "smtpd_recipient_limit = 100"
postconf -e "smtpd_helo_required = yes"
postconf -e "smtpd_client_restrictions = permit_sasl_authenticated, permit_mynetworks, permit"
postconf -e "smtpd_helo_restrictions = permit_sasl_authenticated, permit_mynetworks, permit"
postconf -e "smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_sender, reject_unknown_sender_domain, permit"
postconf -e "smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_recipient_domain, reject_unauth_destination, whitelist_policy, grey_policy, rbl_policy, spf_policy, permit"
postconf -e "smtpd_data_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_pipelining"
postconf -e "smtpd_restriction_classes = spf_policy, grey_policy, whitelist_policy"
postconf -e "spf_policy = check_policy_service unix:private/policy-spf"
postconf –e "policy-spf_time_limit = 3600s"
postconf -e "rbl_policy = reject_rbl_client zen.spamhaus.org, reject_rbl_client bl.spamcop.net"
postconf -e "grey_policy = check_policy_service unix:private/greyfix"
postconf -e "whitelist_policy = check_client_access mysql:/etc/postfix/mysql-global_whitelist.cf, check_sender_access mysql:/etc/postfix/mysql-global_whitelist.cf"
postconf -e "header_checks = regexp:/etc/postfix/header_checks"
touch /etc/postfix/virtual
echo "root [email protected]" >> /etc/postfix/virtual && echo "abuse [email protected]" >> /etc/postfix/virtual && echo "postmaster [email protected]" >> /etc/postfix/virtual
postmap /etc/postfix/virtual
touch /etc/postfix/header_checks
echo "/^Received:/ HOLD" >> /etc/postfix/header_checks
postmap /etc/postfix/header_checks
cat > /etc/postfix/mysql-global_whitelist.cf < /etc/postfix/mysql-relay_domains.cf < /etc/postfix/mysql-relay_recipients.cf < /etc/postfix/mysql-transports.cf < 注意:このステップでは、[email protected]、example.com、@example.comを実際の値に置き換えることを確認してください。
実行可能にして実行します:
chmod +x /usr/src/postfix.sh
./usr/src/postfix.sh
*注意:cfファイルのユーザー/パスワードは、後でBaruwa DBセットアップで使用するユーザー/パスワードと同じである必要があります。スクリプトを実行する前に、赤い部分をすべて変更してください。
Postfix受信者コールアウト(オプション)
この機能は、受信者サーバーにクエリを実行して、受信者が存在するかどうかを確認します。存在しない場合、送信サーバーに550エラーで応答し、接続を切断します。ユーザーが存在する場合、SpamSnakeはメールの処理を続行します。これはバックスキャッターを防ぐための別の方法ですが、代償が伴います。http://www.postfix.org/ADDRESS_VERIFICATION_README.htmlで詳細を確認してください。この方法をスキップし、スクリプトメソッド(このガイドの後半で)を使用することもできます。
vi /etc/postfix/main.cfを開き、次の内容を追加します:
verify_recipient = reject_unknown_recipient_domain, reject_unverified_recipient
look_ahead = check_recipient_access hash:/etc/postfix/access
unverified_recipient_reject_code = 550
address_verify_map = btree:/var/lib/postfix/verifyこれをsmtpd_restriction_classesに追加します:
verify_recipient, look_aheadこれをsmtpd_recipient_restrictionsに追加します:
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, look_ahead, whitelist_policy, grey_policy, rbl_policy, spf_policy, permitアクセスファイルを作成します:
touch /etc/postfix/accessドメインを追加します:
cat > /etc/postfix/access <
example.com verify_recipient
example2.com verify_recipient
EOF
*注意:フィルタリングする有効なドメインを追加してください。
Postmapします:
postmap /etc/postfix/accessPostfixインストールの最終確認:
less /etc/postfix/main.cfファイルの内容にエラーがないか確認し、必要に応じて修正します。Postfixを起動します:
postfix startPostfixが応答するか確認します:
telnet 127.0.0.1 25次のように表示されるはずです:
220 [yourFQDNhere] ESMTP Postfix (Ubuntu)新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。