歡迎您光臨本站 註冊首頁

如何禁止postfix的smtp而只是用esmtp

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

如何禁止postfix的smtp而只是用esmtp

正在弄一個postfix的mailserver 看了marion 的文檔,編譯安裝。裝完測試發現一些問題,foxmail不管是否勾選通過smtp認證都可以發出郵件,看日誌然後telnet感覺esmtp是有的,但是smtp沒有禁止。不知如何禁止。下面是日誌,希望碰到過同類問題的朋友們幫忙

不勾選認證的日誌
Sep  5 23:58:39 ****** postfix/smtpd: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Sep  5 23:58:39 ****** postfix/smtpd: warning: 58.33.157.147: address not listed for hostname 147.157.33.58.broad.xw.sh.dynamic.163data.com.cn
Sep  5 23:58:39 ****** postfix/smtpd: connect from unknown
Sep  5 23:58:39 ****** postfix/trivial-rewrite: warning: do not list domain test.com in BOTH mydestination and virtual_mailbox_domains
Sep  5 23:58:39 ****** postfix/smtpd: NOQUEUE: reject: RCPT from unknown: 504 5.5.2 <PC-200908251556>: Helo command rejected: need fully-qualified hostname; from=<test@test.com> to=<test@gmail.com> proto=SMTP helo=<PC-200908251556>
Sep  5 23:58:39 ****** postfix/smtpd: lost connection after RCPT from unknown
Sep  5 23:58:39 ****** postfix/smtpd: disconnect from unknown
Sep  5 23:58:39 ****** postfix/smtpd: warning: 58.33.157.147: address not listed for hostname 147.157.33.58.broad.xw.sh.dynamic.163data.com.cn
Sep  5 23:58:39 ****** postfix/smtpd: connect from unknown
Sep  5 23:58:39 ****** postfix/smtpd: 9FA60F270032: client=unknown, sasl_method=LOGIN, sasl_username=test@test.com
Sep  5 23:58:39 ****** postfix/cleanup: 9FA60F270032: message-id=<>
Sep  5 23:58:39 ****** postfix/qmgr: 9FA60F270032: from=<test@test.com>, size=643, nrcpt=1 (queue active)
Sep  5 23:58:39 ****** postfix/smtpd: disconnect from unknown
Sep  5 23:58:44 ****** postfix/smtp: 9FA60F270032: to=<test@gmail.com>, relay=gmail-smtp-in.l.google.com:25, delay=5, delays=0.1/0/2.5/2.5, dsn=2.0.0, status=sent (250 2.0.0 OK 1252166324 12si7091801pzk.74)
Sep  5 23:58:44 ****** postfix/qmgr: 9FA60F270032: removed


勾選后的日誌

Sep  6 00:16:16 ****** postfix/smtpd: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Sep  6 00:16:16 ****** postfix/smtpd: warning: 58.33.157.147: address not listed for hostname 147.157.33.58.broad.xw.sh.dynamic.163data.com.cn
Sep  6 00:16:16 ****** postfix/smtpd: connect from unknown
Sep  6 00:16:17 ****** postfix/trivial-rewrite: warning: do not list domain test.com in BOTH mydestination and virtual_mailbox_domains
Sep  6 00:16:17 ****** postfix/smtpd: 070C7F270032: client=unknown, sasl_method=LOGIN, sasl_username=test@test.com
Sep  6 00:16:17 ****** postfix/cleanup: 070C7F270032: message-id=<>
Sep  6 00:16:17 ****** postfix/qmgr: 070C7F270032: from=<test@test.com>, size=643, nrcpt=1 (queue active)
Sep  6 00:16:17 ****** postfix/smtpd: disconnect from unknown
Sep  6 00:16:21 ****** postfix/smtp: 070C7F270032: to=<test@gmail.com>, relay=gmail-smtp-in.l.google.com:25, delay=4.4, delays=0.1/0/1.7/2.6, dsn=2.0.0, status=sent (250 2.0.0 OK 1252167381 12si7096839pzk.6)
Sep  6 00:16:21 ****** postfix/qmgr: 070C7F270032: removed

在上面的日誌里也沒看到用esmtp協議的樣子,只有更sasl_method的login認證
自己也剛接觸postfix,覺得如果客戶端勾選esmtp認證的話在日誌里應該會出現相應的字元才對。就像不是用出現smtp一樣。

自己配的main.cf
broken_sasl_auth_clients = yes
command_directory = /usr/local/postfix/sbin
config_directory = /etc/postfix
daemon_directory = /usr/local/postfix/libexec
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = /var/www/postfix_html
inet_interfaces = all
mail_owner = vmail
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/postfix/man
message_size_limit = 14336000
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = test.com
myhostname = mail.test.com
mynetworks = 127.0.0.1
newaliases_path = /usr/bin/newaliases
queue_directory = /home/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
unknown_local_recipient_reject_code = 550
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:1000
virtual_mailbox_base = /home/domains
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 20971520
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = virtual
virtual_uid_maps = static:1000

不知道問題出在哪裡。
《解決方案》

原帖由 minmig 於 2009-9-6 00:44 發表 http://bbs2.chinaunix.net/images/common/back.gif
正在弄一個postfix的mailserver 看了marion 的文檔,編譯安裝。裝完測試發現一些問題,foxmail不管是否勾選通過smtp認證都可以發出郵件,看日誌然後telnet感覺esmtp是有的,但是smtp沒有禁止。不知如何禁止。下 ...

別用foxmail測試,太智能了。
《解決方案》

多謝樓上回復



現在換用outlook explore測試

果然需要通過選中需要身份驗證才能發件

看了一下日誌和error信息。



不選身份驗證如下:

outlook error信息是Helo command rejected: need fully-qualified hostnamepostfix日誌是:Sep  7 10:09:03 ****** postfix/smtpd: connect from unknown[*.*.*.*]
Sep  7 10:09:03 ****** postfix/trivial-rewrite: warning: do not list domain test.com in BOTH mydestination and virtual_mailbox_domains
Sep  7 10:09:03 ****** postfix/smtpd: NOQUEUE: reject: RCPT from unknown[*.*.*.*]: 504 5.5.2 <PC200908251556>: Helo command rejected: need fully-qualified hostname; from=<test@test.com> to=<minmig@gmail.com> proto=SMTP helo=<PC200908251556>
Sep  7 10:09:03 ****** postfix/smtpd: NOQUEUE: reject: RCPT from unknown[*.*.*.*]: 504 5.5.2 <PC200908251556>: Helo command rejected: need fully-qualified hostname; from=<test@test.com> to=<minmig@gmail.com> proto=SMTP helo=<PC200908251556>
Sep  7 10:09:03 ****** postfix/smtpd: disconnect from unknown[*.*.*.*]根據以上日誌感覺是 沒有點認證時,沒有獲取fqdn,從而在無法再mysql資料庫找到相應記錄所以檢測不過。而不是因為ESMTP認證不過造成的。

自己感覺,希望樓上指正。



下面是勾選了smtp認證的日誌Sep  7 10:27:34 ****** postfix/smtpd: connect from unknown[*.*.*.*]
Sep  7 10:27:34 ****** authdaemond: received auth request, service=smtp, authtype=login
Sep  7 10:27:34 ****** authdaemond: authmysql: trying this module
Sep  7 10:27:34 ****** authdaemond: authmysqllib: connected. Versions: header 50045, client 50045, server 50045
Sep  7 10:27:34 ****** authdaemond: SQL query: SELECT username, password, "", '1000', '1000', concat('/home/domains/',maildir), concat('/home/domains/',maildir), "", name, "" FROM mailbox WHERE username = 'test@test.com'
Sep  7 10:27:34 ****** authdaemond: password matches successfully
Sep  7 10:27:34 ****** authdaemond: authmysql: sysusername=<null>, sysuserid=1000, sysgroupid=1000, homedir=/home/domains/test.com/test/Maildir/, address=test@test.com, fullname=test, maildir=/home/domains/test.com/test/Maildir/, quota=<null>, options=<null>
Sep  7 10:27:34 ****** authdaemond: authmysql: clearpasswd=<null>, passwd=$1$Xb14kEH9$lpc6pMVcskOs0ZEGri/We0
Sep  7 10:27:34 ****** authdaemond: Authenticated: sysusername=<null>, sysuserid=1000, sysgroupid=1000, homedir=/home/domains/test.com/test/Maildir/, address=test@test.com, fullname=test, maildir=/home/domains/test.com/test/Maildir/, quota=<null>, options=<null>
Sep  7 10:27:34 ****** authdaemond: Authenticated: clearpasswd=test, passwd=********
Sep  7 10:27:34 ****** postfix/trivial-rewrite: warning: do not list domain test.com in BOTH mydestination and virtual_mailbox_domains
Sep  7 10:27:34 ****** postfix/smtpd: 1B8CCF270034: client=unknown[*.*.*.*], sasl_method=LOGIN, sasl_username=test@test.com
Sep  7 10:27:34 ****** postfix/cleanup: 1B8CCF270034: message-id=<5D4AEE77B429461FAE6BBE79F869C90E@PC200908251556>
Sep  7 10:27:34 ****** postfix/qmgr: 1B8CCF270034: from=<test@test.com>, size=1401, nrcpt=1 (queue active)
Sep  7 10:27:34 ****** postfix/smtpd: 2E4CCF270035: client=unknown[*.*.*.*], sasl_method=LOGIN, sasl_username=test@test.com
Sep  7 10:27:34 ****** postfix/cleanup: 2E4CCF270035: message-id=<0B8F6BBFDBA048B2870B6BF359D2E35B@PC200908251556>
Sep  7 10:27:34 ****** postfix/qmgr: 2E4CCF270035: from=<test@test.com>, size=2179, nrcpt=1 (queue active)
Sep  7 10:27:34 ****** postfix/smtpd: 3970FF270036: client=unknown[*.*.*.*], sasl_method=LOGIN, sasl_username=test@test.com
Sep  7 10:27:34 ****** postfix/cleanup: 3970FF270036: message-id=<562C77B577B04EA484DE796B76BDFA52@PC200908251556>
Sep  7 10:27:34 ****** postfix/qmgr: 3970FF270036: from=<test@test.com>, size=2179, nrcpt=1 (queue active)
Sep  7 10:27:34 ****** postfix/smtpd: disconnect from unknown[*.*.*.*]
Sep  7 10:27:36 ****** postfix/smtp: 3970FF270036: to=<minmig@gmail.com>, relay=gmail-smtp-in.l.google.com:25, delay=2.8, delays=0.04/0/1.6/1.1, dsn=2.0.0, status=sent (250 2.0.0 OK 1252290456 15si14450451pzk.92)
Sep  7 10:27:36 ****** postfix/qmgr: 3970FF270036: removed
Sep  7 10:27:37 ****** postfix/smtp: 2E4CCF270035: to=<minmig@gmail.com>, relay=gmail-smtp-in.l.google.com:25, delay=3.7, delays=0.03/0/2.6/1, dsn=2.0.0, status=sent (250 2.0.0 OK 1252290457 15si14651865pzk.58)
Sep  7 10:27:37 ****** postfix/qmgr: 2E4CCF270035: removed
Sep  7 10:27:37 ****** postfix/smtp: 1B8CCF270034: to=<minmig@gmail.com>, relay=gmail-smtp-in.l.google.com:25, delay=3.8, delays=0.08/0/1.9/1.8, dsn=2.0.0, status=sent (250 2.0.0 OK 1252290457 15si14651774pzk.58)
Sep  7 10:27:37 ****** postfix/qmgr: 1B8CCF270034: removed弄了那麼就對postfix的ESMTP認真模塊的流程還是有點模糊



感覺是  outlook -->  smtpd --> sasl2 --> authlib --> mysql 。不知道對不對,Esmtp在哪裡來獲得支持,是smtpd還是sasl2還是authlib。感覺是在sasl上面做的,但是又不知道在哪裡設置。

還有一點是當初在編譯postfix的時候就直接支持mysql ,為什麼還需要用通過authlib來連接mysql呢?

希望大牛或碰到過相關問題的朋友幫忙。

[ 本帖最後由 minmig 於 2009-9-7 11:03 編輯 ]
《解決方案》

原帖由 minmig 於 2009-9-7 10:59 發表 http://bbs2.chinaunix.net/images/common/back.gif
多謝樓上回復



現在換用outlook explore測試

果然需要通過選中需要身份驗證才能發件

看了一下日誌和error信息。



不選身份驗證如下:

outlook error信息是Helo command rejected: need fu ...



如果你的mynetworks參數包括你的網段,勾不勾選需要認證都可以發信收信的

還有一點是當初在編譯postfix的時候就直接支持mysql ,為什麼還需要用通過authlib來連接mysql呢?
-------這個是起橋樑作用吧,postfix編譯支持mysql只是支持這個backend而已
《解決方案》

原帖由 ruochen 於 2009-9-7 12:17 發表 http://bbs2.chinaunix.net/images/common/back.gif




如果你的mynetworks參數包括你的網段,勾不勾選需要認證都可以發信收信的

還有一點是當初在編譯postfix的時候就直接支持mysql ,為什麼還需要用通過authlib來連接mysql呢?
-------這個是起橋樑作用 ...


伺服器是放在機房要加強安全,所以準備加ESMTP認證。要不要那個機器中毒了亂髮郵件。雖然如果帳號泄密也會亂髮郵件,如果用ESMTP在事後查起來能相對好一點。還有看到網上一些人利用mynetworks 的漏洞吧自己ip偽造成127.0.0.X 或 192.168.0.X吧伺服器當成open relay。不知道是真是假。
第二個問題多謝版主。
《解決方案》

還有一點是當初在編譯postfix的時候就直接支持mysql ,為什麼還需要用通過authlib來連接mysql呢?

這個理解不太對。你的postfix是通過sasl認證的吧。sasl是調用的authlib來做認證的吧。那就是authlib讀Mysql來認證的
《解決方案》

原帖由 scyzxp 於 2009-9-7 13:53 發表 http://bbs2.chinaunix.net/images/common/back.gif


這個理解不太對。你的postfix是通過sasl認證的吧。sasl是調用的authlib來做認證的吧。那就是authlib讀Mysql來認證的

那就是說在編譯postfix時不用加入mysql的目錄在日後也能通過authlib來用mysql認證?
還有那個sals如何強制esmtp的問題...
《解決方案》

原帖由 minmig 於 2009-9-7 14:20 發表 http://bbs2.chinaunix.net/images/common/back.gif


那就是說在編譯postfix時不用加入mysql的目錄在日後也能通過authlib來用mysql認證?
還有那個sals如何強制esmtp的問題...


postfix+mysql與驗證沒有任何關係。
《解決方案》

原帖由 scyzxp 於 2009-9-7 14:41 發表 http://bbs2.chinaunix.net/images/common/back.gif



postfix+mysql與驗證沒有任何關係。

這個是另外一個問題,我有點疑問隨口問的。
認證的問題還是要看sasl哪裡配,讓他體現出來。

[火星人 ] 如何禁止postfix的smtp而只是用esmtp已經有961次圍觀

http://coctec.com/docs/service/show-post-20841.html