4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

受けたメールをすべて捨てるSMTPブラックホールサーバの作り方②

Last updated at Posted at 2019-06-25

前回の記事で予告した通り、今回はmaster.cfの設定変更だけでSMTPブラックホールサーバを作るスマートな方法を紹介します。

Postfixのインストール

CentOS7.4でyumを使ってインストールしました。

main.cfの設定

/etc/postfix/main.cfを編集します。
変えた項目は以下の通り。あくまで私の設定例です。

myhostname = example.com
mynetworks = 127.0.0.0/8, 172.16.0.0/24(*制限かけています)
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
local_recipient_maps = 

master.cfの設定

/etc/postfix/master.cfを編集します。
変えた項目は以下のとおり。

smtp      inet  n       -       n       -       -       smtpd
  -o content_filter=discard:
  -o smtpd_client_restrictions=permit
  -o smtpd_recipient_restrictions=permit,reject

Postfixのreload

postfixをreloadします。

# postfix reload

これで作業は完了です。telnetなどでメールを送ると、mailogに以下のようなPostfixがメールをdiscardしたログが出力されます。

postfix/discard[3728]: 67BAC4A4DC5: to=<test@example.com>, relay=none, delay=8, delays=8/0.01/0/0, dsn=2.0.0, status=sent (example.com)
postfix/qmgr[3649]: 67BAC4A4DC5: removed

注意点はやはりネットワークの設定です。攻撃の対象になることもあるので十分気をつけましょう。

次回は、Dockerを使ってこのメールサーバを立ち上げる方法を紹介します。

*関連記事
受けたメールをすべて捨てるSMTPブラックホールサーバの作り方①
[受けたメールをすべて捨てるSMTPブラックホールサーバの作り方②]
(https://qiita.com/qualitia_cdev/items/85aaffcd5fddae5afb4c)
[受けたメールをすべて捨てるSMTPブラックホールサーバの作り方③ - Dockerを使う]
(https://qiita.com/qualitia_cdev/items/7f165e5f7e62e46ebe2b)

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?