الجمعة، 28 مايو 2010

Permit an IP to relay through the mail server

You have often seen the following errors:
aa.bb.cc.ddd does not like recipient.
Remote host said:
550-xxx.yyy.com [192.168.1.1] is currently not permitted to
550-relay through this server. Perhaps you have not logged into the pop/imap
550-server in the last 30 minutes or do not have SMTP Authentication turned on
550 in your email client. Giving up on aa.bb.cc.ddd.

The error says that the server xxx.yyy.com is not permitted to relay through the mail server aa.bb.cc.ddd

The exim uses a mechanism to allow pop-before-smtp relaying for sending outgoing emails. The IPs allowed to relay on the server are added dynamically to the file /etc/relayhosts by the antirelayd daemon.

The exim configuration for this:
/etc/exim.conf:
hostlist relay_hosts = lsearch;/etc/relayhosts :
localhost


antirelayd is a daemon that checks /var/log/maillog for pop3/imap logins and keeps track of valid ones for use with smtp relaying. It manages the /etc/relayhosts file automatically so if you are trying to add a static IP in that file it will be cleaned up by antirelayd.

So how can we whitelist some IP and add it permanently to the allowed hosts to relay mail using the server?

You have to create a file (if no such file exists) called alwaysrelay in /etc and add the IPs you always want to be allowed to relay outgoing mails on the server. Normally /etc/alwaysrelay will not exist, but if it does just edit the file and append the needed IPs.
/etc/alwaysrelay
192.168.0.100
192.168.0.101


and add each IP on a separate line. After this either restart antirelayd or wait for a little while and it will automatically include these IPs in /etc/relayhosts and they will not be cleaned any more (permanent relay).

The same result can be achieved by creating a different file (for ex. /etc/staticrelay) and including it in the exim configuration (in the relay_hosts config similar to /etc/relayhosts). This file will be manually maintained and not cleaned up by antirelayd so the result is the same. Choose the method that you prefer (either antirelayd or exim.conf)

ليست هناك تعليقات:

إرسال تعليق