How to configure the IP addresses of outbound emails in Postfix?

From EN Ikoula wiki
⧼vector-jumptonavigation⧽ ⧼vector-jumptosearch⧽

en:How to configure the IP addresses of outbound emails in Postfix? he:כיצד להגדיר תצורת כתובות ה-IP של מיילים היוצאים ב Postfix? ru:Как настроить IP-адреса исходящих писем в Postfix? ja:後置の発信メールの IP アドレスを構成する方法か。 ar:كيفية تكوين عناوين IP لرسائل البريد الإلكتروني الصادرة في Postfix؟ zh:如何在后缀中配置出站邮件的 IP 地址? ro:Cum se configurează adresele IP de ieşire mesajele de poştă electronică în Postfix? pl:Jak skonfigurować adresy IP wychodzących wiadomości e-mail w Postfix? de:Gewusst wie: Konfigurieren von IP-Adressen der ausgehenden e-Mails in Postfix? nl:Het configureren van de IP-adressen van uitgaande e-mails in Postfix? it:Come configurare gli indirizzi IP dei messaggi di posta elettronica in uscita in Postfix? pt:Como configurar os endereços IP de e-mails de saída no Postfix? es:¿Cómo configurar las direcciones IP de los correos electrónicos salientes en Postfix? fr:Comment configurer les adresses IP des mails sortants dans Postfix ?

This article has been created by an automatic translation software. You can view the article source here.

Symptoms

I want to modify the outgoing messages for Postfix email addresses. You may need this when the main server IP address is blacklisted and outbound emails are rejected by the third-party mail servers.

Causes

In the backend Odin Plesk Panel (formerly Parallels Plesk Panel), it is hardcoded that IP address of outgoing emails in Postfix configuration files (/etc/postfix/master.cf) is identical to that of the IP of the interface that listens to Postfix. The configuration looks like this :

plesk-XXXXXX-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=XXXXXX
plesk-XXXXXX-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=XXXXXX


Resolution

Odin provides for the addition of an affordable option from the Plesk interface to change the IP address of output for a given domain. However no date is yet scheduled for the arrival of this patch.


Temporary solutions

Change of IP for the entire server

  • Edit the file /etc/postfix/master.cf and replace smtp_bind_address=XXX.XXX.XXX.XXX by smtp_bind_address=YYY. YYY. YYY. YYY.
  • Reloaded the configuration of Postfix.

XXX.XXX.XXX.XXX : represents your current IP
YYY. YYY. YYY. : represents the IP which you want your e-mails out

Important : Plesk automatically reconfigures the file /etc/postfix/master.cf mail from the interface change to (creation/modification of box, Setup options, etc.). It must therefore consider creating a scheduled task to substitute your custom file. Here is the script to use for the scheduled task :

#!/bin/bash

<!--T:6-->
/bin/grep 'smtp_bind_address=XXX.XXX.XXX.XXX' /etc/postfix/master.cf
if [ $? -ne 1 ]; then
/bin/sed -i 's/smtp_bind_address=XXX.XXX.XXX.XXX/smtp_bind_address=YYY.YYY.YYY.YYY/g' /etc/postfix/master.cf
/etc/init.d/postfix reload
fi
exit 0


In the case of multiple additional IP used for different domains on the same machine, need to go through another method of replacement. After manually editing the file, performing a copy :

cp /etc/postfix/master.cf /etc/postfix/master.cf.bak


The scheduled task will no longer edit the current file, but replace the master.cf with your master.cf.bak file.

#!/bin/bash
	
cp /etc/postfix/master.cf.bak /etc/postfix/master.cf
/etc/init.d/postfix reload
exit 0


In a next update of Odin Plesk PanelPostfix parameters should not be crushed during the reconfiguration of messaging.


A dedicated domain ip change

In the case, or you want to change the sending ip of the mail for a single domain with its own dedicated ip, you need to set up the next scheduled task :

#!/bin/bash

<!--T:10-->
/bin/grep 'plesk-exemple.com-XX.XX.XX.XX' /etc/postfix/master.cf
if [ $? -ne 1 ]; then
/bin/sed -i 's/plesk-exemple.com-XX.XX.XX.XX- unix - n n - - smtp -o smtp_bind_address=XX.XX.XX.XX/plesk-exemple.com-XX.XX.XX.XX- unix - n n - - smtp -o smtp_bind_address=YY.YY.YY.YY/g' /etc/postfix/master.cf
/etc/init.d/postfix reload
fi
exit 0



Article reference : http://kb.odin.com/fr/114491


This article seemed you to be u ?

0



You are not allowed to post comments.