2012年2月2日 星期四

clint收信驚魂

為了這個搞很久,原本自以為我domain跟mail.domain在dns都指向同一ip,在outlook設定時便在寄件伺服器名稱上寫上domain而已,結果沒辦法寄信,只能收信(收信很乖有寫mail.domain)

如果clint有辦法收信,但無法寄信,或者者寄信時認證錯誤,要確定smtp伺服器名稱(mail.water.twgg.org)要對!!!

如果你偷懶自以為寫(water.twgg.org),縱使dns設定對應ip都一樣,也不行。

簡單來說,你host -t mx domain 168.95.1.1

你的mx對應查到什麼名字就要填什麼名字

2012年2月1日 星期三

Dovecot 機車問題一覽

問題0
vim /etc/dovecot/dovecot.conf
下面加上
protocols = pop3
不然預設沒有開啟pop3 只有imap

-------
問題1(這個出現原因解法不一定正確或對應的起來)

Trying xxx.xxx.xxx.xxx...
Connected to xxx
Escape character is '^]'.
+OK Dovecot ready.
user root
+OK
pass appx4698
Connection closed by foreign host.

確定senmail的/var/spool/mail/有收到信,telnet也能跟我說說幾句話,好像很ok,但為什麼就不給登入?用outlook也不行登入!

看看maillog發現
Error: user ec2-user: Couldn't drop privileges: Mail access for users with UID 222 not permitted (see first_valid_uid in config file).


一切都有了解答,改uid即可


有時候不想用ssl:

vim /etc/dovecot/dovecot.conf
ssl_disable = yes

--------------


問題1-1

登入出現
Escape character is '^]'.
+OK Dovecot ready.
user user
-ERR Plaintext authentication disallowed on non-secure (SSL/TLS) connections.

代表要disable tls連線
vim /etc/dovecot/dovecot.conf
加上這行
disable_plaintext_auth = no
重開dovecot.conf
-------
問題2

maillog中出了這個訊息
Nov 5 15:54:16 test dovecot: pop3(towns): Error: user towns: Initialization failed: mail_location not set and autodetection failed: Mail storage autodetection failed with home=/home/towns
Nov 5 15:54:16 test dovecot: pop3(towns): Error: Invalid user settings. Refer to server log for more information.


vim /etc/dovecot/conf.d/10-mail.conf
找到並修改下行,沒找到就自己加上去,注意/var/spool/mail/這段,請改成自己系統的
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u

----------

問題三

Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Error: chown(/home/andy/mail/.imap/I
NBOX, group=12(mail)) failed: Operation not permitted (egid=501(andy), group based
on /var/spool/mail/andy - see http://wiki2.dovecot.org/Errors/ChgrpNoPerm)
Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Error: mkdir(/home/andy/mail/.imap/I
NBOX) failed: Operation not permitted
Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Error: Couldn't open INBOX: Internal
error occurred. Refer to server log for more information. [2012-02-03 11:07:17]
Feb 3 11:07:17 Paysecure dovecot: pop3(andy): Couldn't open INBOX top=0/0, retr=0/
0, del=0/0, size=0


原因:/var/mail/user 檔案權限不正確
在新增使用者後,/var/mail/ 都會產生一個使用者名稱的 mailbox,但預設的檔案權限為 660,需手動改為 600

處理方式:將 /var/mail/* 全改為 600,並在新增使用者時,手動修改檔案權限
只是這麼做,不就每次都要手動變更

-----問題4

fedora之類的新版本預設會鎖一堆port
到/etc/rc.d/rc.local
開port
下列示範port 53 25 110


/sbin/iptables -I INPUT -p tcp --dport 53 -j ACCEPT
/sbin/iptables -I INPUT -p udp --dport 53 -j ACCEPT

/sbin/iptables -I OUTPUT -p tcp --sport 53 -j ACCEPT
/sbin/iptables -I OUTPUT -p udp --sport 53 -j ACCEPT

/sbin/iptables -I INPUT -p tcp --dport 25 -j ACCEPT
/sbin/iptables -I OUTPUT -p tcp --sport 25 -j ACCEPT

/sbin/iptables -I INPUT -p tcp --dport 110 -j ACCEPT
/sbin/iptables -I OUTPUT -p tcp --sport 110 -j ACCEPT

用好後重開機,可能可以restart某些東西就不用,但我都直接重開機

------

;; connection timed out; no servers could be reached

dns架好後

用# host www.google.com.tw 127.0.0.1
ok
但# host www.google.com.tw 本地ip
會回復
;; connection timed out; no servers could be reached

很明顯本地dns有run起來,可是外面沒辦法呼叫
搞了老半天不是防火牆問題

是/etc/named.conf下的其中兩行在搞鬼

listen-on port 53 { 127.0.0.1; };
allow-query { 127.0.0.1; };

把預設改成any就可以了

listen-on port 53 { any; };
allow-query { any; };