削除
[root@falcon21 ~]# /etc/init.d/postfix stop
postfix を停止中: [ OK ]
[root@falcon21 ~]# /etc/init.d/dovecot stop
Dovecot Imap を停止中: [ OK ]
[root@falcon21 ~]# yum erase postfix
削除しました:
postfix.i686 2:2.6.6-8.el6
完了しました!
[root@falcon21 ~]# rpm -qa | grep postfix
----------------
削除
[root@falcon21 ~]# rm -rf /usr/libexec/postfix
[root@falcon21 ~]# rm -rf /etc/postfix
[root@falcon21 ~]# rm -rf /usr/sbin/post*
*****************************
再インストール
[root@falcon21 ~]# yum -y install postfix
インストール:
postfix.i686 2:2.6.6-8.el6
***************************
postfix 設定
[root@falcon21 ~]# vi /etc/postfix/main.cf
75 myhostname = mail.falcon21.space
83 mydomain = falcon21.space
99 myorigin = $mydomain
116 inet_interfaces = all
119 inet_protocols = ipv4
164 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
264 mynetworks = 192.168.2.0/24, 192.168.0.0/24 127.0.0.0/8
419 home_mailbox = Maildir/
571 smtpd_banner = $myhostname ESMTP
最終行へ追記
mailbox_size_limit = 1073741824
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
|
postfix を起動
[root@falcon21 ~]# /etc/rc.d/init.d/postfix start
postfix を起動中: [ OK ]
[root@falcon21 ~]# chkconfig postfix on
----------------
sendmail コマンドで送信テスト
[root@falcon21 ~]# sendmail kazuya@falcon21.space
From: hayato@falcon21.space
To: kazuya@falcon21.space
Subject:テスト送信
テスト送信してみました。
.
-----------------
ログで確認
[root@falcon21 ~]# tail -10 /var/log/maillog
May 7 11:06:19 falcon21 postfix/qmgr[2873]: E7EF611EFCD: from=<root@falcon21.space>, size=343, nrcpt=1 (queue active)
May 7 11:06:19 falcon21 postfix/smtpd[2913]: connect from localhost.localdomain[127.0.0.1]
May 7 11:06:19 falcon21 postfix/smtpd[2913]: 0CEFF11EFCB: client=localhost.localdomain[127.0.0.1]
May 7 11:06:19 falcon21 postfix/cleanup[2910]: 0CEFF11EFCB: message-id=<20170507020618.E7EF611EFCD@mail.falcon21.space>
May 7 11:06:19 falcon21 postfix/qmgr[2873]: 0CEFF11EFCB: from=<root@falcon21.space>, size=545, nrcpt=1 (queue active)
May 7 11:06:19 falcon21 postfix/smtp[2912]: E7EF611EFCD: to=<kazuya@falcon21.space>, relay=127.0.0.1[127.0.0.1]:10025, delay=32, delays=32/0.02/0.02/0.04, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 0CEFF11EFCB)
May 7 11:06:19 falcon21 postfix/smtpd[2913]: disconnect from localhost.localdomain[127.0.0.1]
May 7 11:06:19 falcon21 postfix/qmgr[2873]: E7EF611EFCD: removed
May 7 11:06:19 falcon21 postfix/local[2914]: 0CEFF11EFCB: to=<kazuya@falcon21.space>, relay=local, delay=0.1, delays=0.04/0.02/0/0.04, dsn=2.0.0, status=sent (delivered to maildir)
May 7 11:06:19 falcon21 postfix/qmgr[2873]: 0CEFF11EFCB: removed
---------------
mail コマンド送信
[root@falcon21 ~]# mail kazuya
Subject: test1
テスト送信してみました。これでもか?
.
EOT
----------
ログで確認
[root@falcon21 ~]# tail -10 /var/log/maillog
May 7 11:30:30 falcon21 postfix/qmgr[3947]: C7FC411EF68: from=<root@falcon21.space>, size=485, nrcpt=1 (queue active)
May 7 11:30:30 falcon21 postfix/smtpd[3996]: connect from localhost.localdomain[127.0.0.1]
May 7 11:30:31 falcon21 postfix/smtpd[3996]: 002AC11EF62: client=localhost.localdomain[127.0.0.1]
May 7 11:30:31 falcon21 postfix/cleanup[3993]: 002AC11EF62: message-id=<20170507023030.C7FC411EF68@mail.falcon21.space>
May 7 11:30:31 falcon21 postfix/qmgr[3947]: 002AC11EF62: from=<root@falcon21.space>, size=687, nrcpt=1 (queue active)
May 7 11:30:31 falcon21 postfix/smtpd[3996]: disconnect from localhost.localdomain[127.0.0.1]
May 7 11:30:31 falcon21 postfix/smtp[3995]: C7FC411EF68: to=<kazuya@falcon21.space>, orig_to=<kazuya>, relay=127.0.0.1[127.0.0.1]:10025, delay=0.27, delays=0.1/0.01/0.11/0.04, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 002AC11EF62)
May 7 11:30:31 falcon21 postfix/qmgr[3947]: C7FC411EF68: removed
May 7 11:30:31 falcon21 postfix/local[3999]: 002AC11EF62: to=<kazuya@falcon21.space>, relay=local, delay=0.1, delays=0.04/0.02/0/0.05, dsn=2.0.0, status=sent (delivered to maildir)
May 7 11:30:31 falcon21 postfix/qmgr[3947]: 002AC11EF62: removed
---------
着信メールを読み取る
[hayato@falcon21 ~]$ mail
No mail for hayato
[hayato@falcon21 ~]$ mail -e
No mail for hayato
|
IPアドレス
|
192.168.2.103
|
サブネットマスク
|
/24 (255.255.255.0)
|
ネットワークアドレス
(開始IP)
|
192.168.2.0
|
ホストアドレス
(使用可能IP)
|
192.168.2.1
~
192.168.2.254
|
ブロードキャストアドレス
(終了IP)
|
192.168.2.255
|
アドレス数
|
IPアドレス数:256 (ホストアドレス数:254)
|
IPアドレスクラス
|
クラスC
|
----------------
[root@falcon21 ~]# vi /etc/postfix/master.cf
最後の行へ下記追加
smtp-amavis unix - - n - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-----------------------
[root@falcon21 ~]# vi /etc/postfix/main.cf
最後の行へ下記追加
content_filter=smtp-amavis:[127.0.0.1]:10024
[root@falcon21 ~]# postfix flush
dovecot削除
[root@falcon21 ~]# yum -y remove dovecot
削除しました:
dovecot.i686 1:2.0.9-22.el6
[root@falcon21 ~]# rpm -qa | grep dovecot
[root@falcon21 ~]# locate dovecot | more
/etc/dovecot
/etc/pam.d/dovecot
/etc/pki/dovecot
[root@falcon21 ~]# rm -rf /etc/dovecot
---------------------
dovecotインストール
[root@falcon21 ~]# yum -y install dovecot
SASL 機能が提供できるよう Dovecot を設定
[root@falcon21 ~]# vi /etc/dovecot/dovecot.conf
26 listen = *,
[root@falcon21 ~]# vi /etc/dovecot/conf.d/10-auth.conf
9 disable_plaintext_auth = no
97 auth_mechanisms = plain login //追加
[root@falcon21 ~]# vi /etc/dovecot/conf.d/10-mail.conf
30 mail_location = maildir:~/Maildir
188 valid_chroot_dirs = /home
[root@falcon21 ~]# vi /etc/dovecot/conf.d/10-ssl.conf
7 ssl = no
[root@falcon21 ~]# vi /etc/dovecot/conf.d/10-master.conf
87 # Postfix smtp-auth
88 unix_listener /var/spool/postfix/private/auth {
89 mode = 0666
90 user = postfix
91 group = postfix
92 }
[root@falcon21 ~]# /etc/rc.d/init.d/dovecot start
Dovecot Imap を起動中:
[root@falcon21 ~]# chkconfig dovecot on
[ OK ]
**************************************************
|
暗号化通信ができるよう SSL の設定
SSL証明書を作成 ・・・webサーバーの暗号化で作成済み
/etc/pki/tls/certs/server.key
/etc/pki/tls/certs/server.csr
|
SMTPS は 465/TCP, POP3S は 995/TCP, IMAPS は 993/TCP を使用
********************************************
SMTP認証設定
パスワードにシステムのユーザー名、パスワードを使用
[root@falcon21 ~]# yum -y reinstall cyrus-sasl
[root@falcon21 ~]# /etc/rc.d/init.d/saslauthd restart
saslauthd を停止中: [ OK ]
saslauthd を起動中: [ OK ]
[root@falcon21 ~]# chkconfig --list saslauthd
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|
バーチャルドメイン設定
[root@falcon21 ~]# vi /etc/postfix/main.cf
//追加
698 virtual_alias_domains = anpachi.moe.hm
699 virtual_alias_maps = hash:/etc/postfix/virtual
[root@falcon21 ~]# vi /etc/postfix/virtual
//追加
295 mail.anpachi.me.hm
[root@falcon21 ~]# postmap /etc/postfix/virtual
[root@falcon21 ~]# /etc/rc.d/init.d/postfix reload
postfix を再読み込み中: [ OK ]
|
Postfix + Clamav
[root@falcon21 ~]# yum --enablerepo=epel -y install clamd clamsmtp
インストール:
clamsmtp.i686 0:1.10-7.el6
完了しました!
[root@falcon21 ~]# vi /etc/clamsmtpd.conf
22Listen: 192.168.2.0:10025
28 Header: X-Virus-Scanned: ClamAV using ClamSMTP
34 Action: drop
[root@falcon21 ~]# /etc/rc.d/init.d/clamsmtpd start
Starting ClamSmtpd: [ OK ]
[root@falcon21 ~]# /etc/rc.d/init.d/clamsmtp-clamd start
clamd.clamsmtp を起動中: [ OK ]
[root@falcon21 ~]# chkconfig clamsmtpd on
[root@falcon21 ~]# chkconfig clamsmtp-clamd on
[root@falcon21 ~]# vi /etc/postfix/main.cf
//追加
701 content_filter = scan:127.0.0.1:10025
[root@falcon21 ~]# vi /etc/postfix/master.cf
//最終行へ追加
scan unix - - n - 16 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
127.0.0.1:10026 inet n - n - 16 smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks_style=host
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
[root@falcon21 ~]# /etc/rc.d/init.d/postfix restart
postfix を停止中: [ OK ]
postfix を起動中: [ OK ]
****************
|
sendmail コマンドで確認
pflogsumm
[root@falcon21 ~]# yum -y install postfix-perl-scripts
[root@falcon21 ~]# perl /usr/sbin/pflogsumm -d yesterday /var/log/maillog
Postfix log summaries for Apr 19
Grand Totals
------------
messages
0 received
0 delivered
0 forwarded
0 deferred
0 bounced
0 rejected (0%)
0 reject warnings
0 held
0 discarded (0%)
0 bytes received
0 bytes delivered
0 senders
0 sending hosts/domains
0 recipients
0 recipient hosts/domains
Per-Hour Traffic Summary
time received delivered deferred bounced rejected
--------------------------------------------------------------------
0000-0100 0 0 0 0 0
0100-0200 0 0 0 0 0
0200-0300 0 0 0 0 0
0300-0400 0 0 0 0 0
0400-0500 0 0 0 0 0
0500-0600 0 0 0 0 0
0600-0700 0 0 0 0 0
0700-0800 0 0 0 0 0
0800-0900 0 0 0 0 0
0900-1000 0 0 0 0 0
1000-1100 0 0 0 0 0
1100-1200 0 0 0 0 0
1200-1300 0 0 0 0 0
1300-1400 0 0 0 0 0
1400-1500 0 0 0 0 0
1500-1600 0 0 0 0 0
1600-1700 0 0 0 0 0
1700-1800 0 0 0 0 0
1800-1900 0 0 0 0 0
1900-2000 0 0 0 0 0
2000-2100 0 0 0 0 0
2100-2200 0 0 0 0 0
2200-2300 0 0 0 0 0
2300-2400 0 0 0 0 0
Host/Domain Summary: Message Delivery
sent cnt bytes defers avg dly max dly host/domain
-------- ------- ------- ------- ------- -----------
Host/Domain Summary: Messages Received
msg cnt bytes host/domain
-------- ------- -----------
Senders by message count: none
Recipients by message count: none
Senders by message size: none
Recipients by message size: none
message deferral detail: none
message bounce detail (by relay): none
message reject detail: none
message reject warning detail: none
message hold detail: none
message discard detail: none
smtp delivery failures: none
Warnings: none
Fatal Errors
------------
postfix (total: 22)
10 /etc/postfix/main.cf, line 390: missing '=' after attribute nam...
8 /etc/postfix/main.cf, line 737: missing '=' after attribute nam...
4 /etc/postfix/main.cf, line 421: missing '=' after attribute nam...
sendmail (total: 25)
11 /etc/postfix/main.cf, line 737: missing '=' after attribute nam...
7 /etc/postfix/main.cf, line 390: missing '=' after attribute nam...
3 /etc/postfix/main.cf, line 421: missing '=' after attribute nam...
1 /etc/postfix/main.cf, line 422: missing '=' after attribute nam...
1 /etc/postfix/main.cf, line 423: missing '=' after attribute nam...
1 /etc/postfix/main.cf, line 401: missing '=' after attribute nam...
1 /etc/postfix/main.cf, line 424: missing '=' after attribute nam...
Panics: none
Master daemon messages: none
---------------------------------------------------
[root@falcon21 ~]# crontab -e
bash: crontab: コマンドが見つかりません
[root@falcon21 ~]# yum -y install cronie-noanacron
[root@falcon21 ~]# yum -y remove cronie-anacron
[root@falcon21 ~]# crontab -e
00 01 * * * perl /usr/sbin/pflogsumm -e -d yesterday /var/log/maillog | mail -s 'Logwatch for Postfix' root
|
MailGraph
[root@falcon21 ~]# yum --enablerepo=epel -y install mailgraph
[root@falcon21 ~]# vi /etc/httpd/conf.d/mailgraph.conf
15 Allow from 127.0.0.1 192.168.2.100/24 192.168.0.0/24
[root@falcon21 ~]# /etc/rc.d/init.d/mailgraph start
mailgraph を起動中: [ OK ]
[root@falcon21 ~]# /etc/rc.d/init.d/httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]
[root@falcon21 ~]# chkconfig mailgraph on
http://falcon21.space/mailgraph/
ページ表示できないので、修正
[root@falcon21 ~]# whereis mailgraph
mailgraph: /usr/svi /etc/httpd/conf.d/mailgraph.confbin/mailgraph /usr/share/mailgraph
[root@falcon21 ~]# /usr/sbin/mailgraph
Error opening /var/log/syslog: そのようなファイルやディレクトリはありません at /usr/sbin/mailgraph line 470
参照logファイル部分を修正、/var/log/maillogを参照するようにしてみるが、syslog が無いと不具合みたい。
ーーーーーーーーーーーーー
syslogを使えるようにしてから、再インストール、取りあえず、削除。
[root@falcon21 ~]# yum --enablerepo=epel -y remove mailgraph
vi /etc/httpd/conf.d/mailgraph.conf
syslogを使えるように
centos では、syslogd ではなく、rsyslogd
syslogd/rsyslogd 確認
[root@falcon21 ~]# chkconfig --list | grep syslog
rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@falcon21 ~]# which syslogd
/usr/bin/which: nvi /etc/httpd/conf.d/mailgraph.confo syslogd in (/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/
local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[root@falcon21 ~]# which rsyslogd
/sbin/rsyslogd
設定ファイルは以下。
/etc/rsyslog.conf :共通設定ファイル
/etc/rsyslog.d/*.conf :個別の設定ファイル
/etc/sysconfig/rsyslog :起動オプション
vi /etc/httpd/conf.d/mailgraph.conf
起動オプションの設定
[root@falcon21 ~]# vi /etc/sysconfig/rsyslog
# See rsyslogd(8) for more details
SYSLOGD_OPTIONS="-c 5"
リモートからログを転送する場合
ログの送信元となるホスト機側の設定
# vi /etc/rsyslog.conf
# authpriv.* 認証にvi /etc/httpd/conf.d/mailgraph.conf関するログを centos に転送する場合
authpriv.* @@ホスト:514
# 72行目からのコメントを解除して有効にする
$WorkDirectory /var/lib/rsyslog # where to place spool files
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
$ActionQueueType LinkedList # run asynchronously
$ActionResumeRetryCount -1 # infinite retries if host is down
vi /etc/httpd/conf.d/mailgraph.conf
# service rsyslog restart
Shutting down system logger: [ OK ]# service rsyslog restart
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Starting system logger: [ OK ]
----------168.1
ログ受信側ホスト
[root@falcon21 ~]# vi /etc/rsyslog.conf
16 # Provides TCP syslog reception
17 $ModLoad imtcp
18 $InputTCPServerRun 514
ポート開放、rsyslog 再起動
# rsyslog設定
[root@falcon21 ~]# vi iptables.sh
198 echo "-A INPUT -m state --state NEW -m udp -p udp --dport 514 -j ACCEPT" >> $IPTABLES_CONFIG
199 echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 514 -j ACCEPT" >> $IPTABLES_CONFIG
[root@falcon21 ~]# service iptables restart
iptables: ファイアウォールルールを適用中: [ OK ]
:
rsyslog 再起動
[root@falcon21 ~]# service rsyslog restart
システムロガーを停止中: [ OK ]
システムロガーを起動中: [ OK ]
ログの場所を指定
[root@falcon21 ~]# vi /etc/rsyslog.conf
**************************
MailGraph
[root@falcon21 ~]# yum --enablerepo=epel -y install mailgraph
[root@falcon21 ~]# vi /etc/httpd/conf.d/mailgraph.conf
15 Allow from 127.0.0.1 192.168.2.100/200 192.168.0.0/24
[root@falcon21 ~]# /etc/rc.d/init.d/mailgraph start
mailgraph を起動中: [ OK ]
[root@falcon21 ~]# /etc/rc.d/init.d/httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]
[root@falcon21 ~]# chkconfig mailgraph on
http://falcon21.space/mailgraph/
*************************
バーチャルドメイン設定
・・・これを設定して、アクセス制限 .htaccess を使うと、ウェブページ anpachi.moe.hm が falcon21.spaceに転送されてしまう。
[root@falcon21 ~]# vi /etc/postfix/virtual
//最終行へ追加
anpachi.moe.hm anything
@anpachi.moe.hm @falcon21.space
----------------------