Linux

Dovecot 沒有監聽任何埠

  • August 30, 2021

我正在嘗試設置郵件伺服器,但 Dovecot 沒有監聽任何埠。我嘗試過故障排除,但不幸的是遇到了障礙。任何幫助/建議將不勝感激謝謝。

/etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
#smtpd_use_tls=yes
#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_use_tls=yes
smtpd_tls_auth_only = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination

鴿舍-n

# 2.2.13: /etc/dovecot/dovecot.conf
# OS: Linux 3.16.0-4-amd64 x86_64 Debian 8.8 ext4
auth_mechanisms = plain login
mail_location = maildir:/var/mail/vhosts/%d/%n
mail_privileged_group = mail
namespace inbox {
 inbox = yes
 location = 
 mailbox Drafts {
   special_use = \Drafts
 }
 mailbox Junk {
   special_use = \Junk
 }
 mailbox Sent {
   special_use = \Sent
 }
 mailbox "Sent Messages" {
   special_use = \Sent
 }
 mailbox Trash {
   special_use = \Trash
 }
 prefix = 
}
passdb {
 args = /etc/dovecot/dovecot-sql.conf.ext
 driver = sql
}
protocols = imap lmtp
service auth {
 unix_listener /var/spool/postfix/private/auth {
   group = postfix
   mode = 0666
   user = postfix
 }
 unix_listener auth-userdb {
   mode = 0600
   user = vmail
 }
 user = dovecot
}
service imap-login {
 inet_listener imap {
   port = 0
 }
}
service lmtp {
 unix_listener /var/spool/postfix/private/dovecot-lmtp {
   group = postfix
   mode = 0600
   user = postfix
 }
}
ssl = no
userdb {
 args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n
 driver = static
}

服務鴿舍狀態

● dovecot.service - Dovecot IMAP/POP3 email server
  Loaded: loaded (/lib/systemd/system/dovecot.service; enabled)
  Active: active (running) since Fri 2017-06-23 21:33:08 CEST; 13min ago
Main PID: 7688 (dovecot)
  CGroup: /system.slice/dovecot.service
          ├─7688 /usr/sbin/dovecot -F
          ├─7690 dovecot/anvil
          ├─7691 dovecot/log
          └─7693 dovecot/config

Jun 23 21:33:08 spmac1 systemd[1]: Starting Dovecot IMAP/POP3 email server...
Jun 23 21:33:08 spmac1 systemd[1]: Started Dovecot IMAP/POP3 email server.
Jun 23 21:33:08 spmac1 dovecot[7688]: master: Dovecot v2.2.13 starting up for imap, lmtp (core dumps disabled)

netstat -tupln

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      7557/master     
tcp        0      0 0.0.0.0:55171           0.0.0.0:*               LISTEN      463/rpc.statd   
tcp        0      0 0.0.0.0:xxxx            0.0.0.0:*               LISTEN      1274/sshd       
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      964/mysqld      
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      7557/master     
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      454/rpcbind     
tcp6       0      0 :::25                   :::*                    LISTEN      7557/master     
tcp6       0      0 :::52219                :::*                    LISTEN      463/rpc.statd   
tcp6       0      0 :::50122                :::*                    LISTEN      1274/sshd       
tcp6       0      0 :::587                  :::*                    LISTEN      7557/master     
tcp6       0      0 :::111                  :::*                    LISTEN      454/rpcbind     
tcp6       0      0 :::80                   :::*                    LISTEN      643/apache2     
udp        0      0 0.0.0.0:629             0.0.0.0:*                           454/rpcbind     
udp        0      0 127.0.0.1:639           0.0.0.0:*                           463/rpc.statd   
udp        0      0 0.0.0.0:52688           0.0.0.0:*                           463/rpc.statd   
udp        0      0 0.0.0.0:8217            0.0.0.0:*                           391/dhclient    
udp        0      0 0.0.0.0:68              0.0.0.0:*                           391/dhclient    
udp        0      0 0.0.0.0:111             0.0.0.0:*                           454/rpcbind     
udp6       0      0 :::629                  :::*                                454/rpcbind     
udp6       0      0 :::25374                :::*                                391/dhclient    
udp6       0      0 :::34693                :::*                                463/rpc.statd   
udp6       0      0 :::111                  :::*                                454/rpcbind    

尾 /var/log/mail.log

Jun 23 21:20:03 spmac1 dovecot: lmtp(3589): Connect from local
Jun 23 21:20:03 spmac1 dovecot: lmtp(3589): Disconnect from local: Successful quit
Jun 23 21:20:03 spmac1 postfix/qmgr[1264]: 8518441BFC: removed
Jun 23 21:32:43 spmac1 postfix/master[1259]: terminating on signal 15
Jun 23 21:32:43 spmac1 postfix/master[7557]: daemon started -- version 2.11.3, configuration /etc/postfix
Jun 23 21:33:08 spmac1 dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Jun 23 21:33:08 spmac1 dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Jun 23 21:33:08 spmac1 dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Jun 23 21:33:08 spmac1 dovecot: master: Dovecot v2.2.13 starting up for imap, lmtp (core dumps disabled)

正如您在 netstat 的輸出中看到的那樣,找不到 Dovecot。埠 993 或 143 均未打開。我也嘗試過遠端登錄到這些埠,並且可以確認它們實際上已關閉。

對於可能有類似問題的其他人,此特定配置中的關閉埠問題是由以下原因引起的:

service imap-login {
 inet_listener imap {
   port = 0
 }

必須指定埠號(IMAP 為 143)。或者,應該註釋掉“port = 0”行,這將允許 dovecot 回退並使用預設埠值。

此配置的另一個問題是,ssl 被設置為“no”,因為在 postfix 配置中使用了蛇油證書,所以它應該被設置為“required”。因此,這些也應該在 dovecot 配置中使用。

ssl = required
ssl_cert = </etc/ssl/certs/ssl-cert-snakeoil.pem 
ssl_key = </etc/ssl/private/ssl-cert-snakeoil.key

引用自:https://serverfault.com/questions/857601