0

I have two virtual machines and both running Ubuntu server. I should be able to send emails from lab2 to lab1 using mail. lab2 is running exim4and lab1 has postfix listening on port 25. I should configure exim on lab2, so that it delivers the emails that are for lab1 to lab1, and for lab2 to lab2. It works fine when I send emails with mail from lab2 to lab2, but I get an error when sending from lab2 to lab1. As I understand exim should work as a relay for lab1? The error I get is R=dnslookup_relay_to_domains defer (-1): host lookup did not complete, below more details.

From lab2 I can ping and ssh to lab1. Can anybody help me understanding what I am doing wrong? I have tried changing the configuration of exim but I am sure there is something I am not understanding here...

On lab1

The ip address of lab1:

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 is listening on port 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      -  

On lab2

The content of /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

Part of the content of /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

Sending the email from lab2 to user on lab1:

user@lab2:~$ echo "test" | mail -s test user@lab1

Output of /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
0

I had been trying many things and got a bit messed up with the configuration. Finally sorted it out and here is the correct configuration from /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'

Basically using sudo dpkg-reconfigure exim4-config I had to choose the mail sent by smarthost option and then set lab1 as smarthost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.