我有两台虚拟机,都运行着 Ubuntu 服务器。我应该能够使用 从 lab2 向 lab1 发送电子邮件mail
。lab2 正在运行exim4
,lab1 正在postfix
监听端口 25。我应该在 lab2 上配置 exim,以便它将发往 lab1 的电子邮件发送给 lab1,将发往 lab2 的电子邮件发送给 lab2。当我从mail
lab2 向 lab2 发送电子邮件时,它工作正常,但从 lab2 向 lab1 发送电子邮件时出现错误。据我所知,exim
应该作为 lab1 的中继工作?我收到的错误是R=dnslookup_relay_to_domains defer (-1): host lookup did not complete
,下面有更多详细信息。
我可以在 lab2ping
和ssh
lab1 之间切换。有人能帮我理解我做错了什么吗?我尝试过更改 exim 的配置,但我确信这里有些东西我不明白...
在实验室1
lab1的ip地址:
user@lab1:~$ ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:d5:ec:9a
inet addr:10.0.2.5 Bcast:10.0.2.255 Mask:255.255.255.0
Postfix 正在监听端口 25:
user@lab1:~$ netstat -tulpn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN -
在实验室2
内容/etc/hosts
:
user@lab2:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 lab2
10.0.2.5 lab1
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
部分内容/var/lib/exim4/config.autogenerated
:
# the following macro definitions were created
# dynamically by /usr/sbin/update-exim4.conf
.ifndef MAIN_LOCAL_INTERFACES
MAIN_LOCAL_INTERFACES=<; 127.0.0.1; 10.0.2.6
.endif
.ifndef MAIN_PACKAGE_VERSION
MAIN_PACKAGE_VERSION=4.86.2-2ubuntu2.3
.endif
.ifndef MAIN_LOCAL_DOMAINS
MAIN_LOCAL_DOMAINS=@:localhost:lab2: localhost
.endif
.ifndef MAIN_RELAY_TO_DOMAINS
MAIN_RELAY_TO_DOMAINS=lab1
.endif
.ifndef ETC_MAILNAME
ETC_MAILNAME=lab2
.endif
.ifndef LOCAL_DELIVERY
LOCAL_DELIVERY=maildir_home
.endif
.ifndef MAIN_RELAY_NETS
MAIN_RELAY_NETS=10.0.2.0/8 : 127.0.0.1 : ::::1
.endif
.ifndef DCreadhost
DCreadhost=empty
.endif
.ifndef DCsmarthost
DCsmarthost=mail.lab2
.endif
.ifndef DC_eximconfig_configtype
DC_eximconfig_configtype=internet
.endif
.ifndef DCconfig_internet
DCconfig_internet=1
.endif
从实验室2向实验室1上的用户发送电子邮件:
user@lab2:~$ echo "test" | mail -s test user@lab1
输出/var/log/exim4/mainlog
:
2019-01-26 01:31:24 1gnBsa-0000PD-2b <= user@lab2 U=user P=local S=310
2019-01-26 01:31:24 1gnBsa-0000PD-2b == user@lab1 R=dnslookup_relay_to_domains defer (-1): host lookup did not complete
答案1
我尝试了很多方法,但配置有点混乱。最后终于解决了,下面是正确的配置/etc/exim4/update-exim4.conf.conf
dc_eximconfig_configtype='smarthost'
dc_other_hostnames='lab2; localhost'
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='lab1'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'
基本上,sudo dpkg-reconfigure exim4-config
我必须选择该mail sent by smarthost
选项,然后设置lab1
为智能主机。