Linux操作sendmail卡住、等待問題的解決

启动sendmail竟然需要很长时间,网上查了查,有很多人碰到类似问题,但是一般都是关掉sendmail服务或者关掉dns了事,咱们现在要用它,自然不能关掉了事,dns也不能关,关了服务器没法解析域名
毫无疑问,sendmail去做dns lookup,并且无法lookup到域名,在等待解析超时!
这里我的主机名叫mymachinename,里面也指定了nameserver,应该能正常做dns解析了,既然他无法解析域名,自然这是个本地域名,难道是hosts里面的问题,查看了一下hosts文件:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.1.28 mymachinename
好像也没发现啥不对的,他在解析啥呢,看看log去,找到/var/log/maillog(也可能在messages),看到如下内容:
Dec 11 14:25:01 mymachinename sendmail[22710]: starting daemon (8.13.8): SMTP+queueing@01:00:00 Dec 11 14:25:01 mymachinename sm-msp-queue[22717]: My unqualified host name (mymachinename) unknown; sleeping for retry Dec 11 14:28:08 mymachinename sendmail[22803]: My unqualified host name (mymachinename) unknown; sleeping for retry Dec 11 14:35:23 mymachinename sendmail[22944]: My unqualified host name (mymachinename) unknown; sleeping for retry Dec 11 14:35:57 mymachinename sendmail[22962]: My unqualified host name (mymachinename) unknown; sleeping for retry Dec 11 14:36:54 mymachinename sendmail[22979]: My unqualified host name (mymachinename) unknown; sleeping for retry
竟然是无法解析mymachinename,有点意思,直接去ping mymachinename自然是没问题,突然想到好像FQDN里面规定域名必须用”.”结尾,难道是hosts里面少了一个”.”,尝试修改hosts文件:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.1.28 mymachinename. mymachinename
启动sendmail,刷一下就启动了。
回头想想,问题其实很简单,但是在网上却没找到什么好的方案,说明都挺懒的,能绕都绕过去了。