Postfix Assign User Account IP For Outgoing Mail Sending – CWP/CentOS/Ubuntu
Hi in this tutorial I’ll show you how you can assign user account ip for mail sending under postfix mail server. It will be good if you’re providing mail services to your use.
Suppose you’ve one ip configured for mail server and a user who sends lots of spam or his/her website got infected and sending spam from the infected scripts this leads to main mail ip for email sending will quickly get into blacklisted and all other genuine users who are using safe practices for mail sending will suffer because of that bad user. To cope with this situation you need to have per ip basis configuration for user if one user ip get blacklisted then other users will not be affected and you can bait that bad user by disabling mail sending.
Lets get started with the configuration before you configure ensure you’ve Multi ips are attached in your server network.
Create file called sdd_transport_maps.regexp
in /etc/postfix/
:
/@user1-domain\.tld$/ user1: /@user2-domain\.tld$/ user2: /@user3-domain\.tld$/ user3:
replace /@user1-domain\.tld$/
with domain.tld eg : /@mysterydata\.com$/
replace user1
with account username mysterydata
you can add like this for multi users and domains.
Now In /etc/postfix/master.cf
create special transport called user1, user2, user3 and more user as per need :
user1 unix - - n - - smtp -o smtp_bind_address=10.10.10.1 -o smtp_helo_name=user1-domain.tld -o syslog_name=postfix-user1 user2 unix - - n - - smtp -o smtp_bind_address=10.10.10.2 -o smtp_helo_name=user2-domain.tld -o syslog_name=postfix-user2 user3 unix - - n - - smtp -o smtp_bind_address=10.10.10.3 -o smtp_helo_name=user3-domain.tld -o syslog_name=postfix-user3
Replace smtp_bind_address
ip with the dedicated ip
for the user account.
eg :
mysterydata unix - - n - - smtp -o smtp_bind_address=10.10.10.1 -o smtp_helo_name=mysterydata.com -o syslog_name=postfix-mysterydata
In /etc/postfix/main.cf
add sender_dependent_default_transport_maps
line:
sender_dependent_default_transport_maps = regexp:/etc/postfix/sdd_transport_maps.regexp
reload/ restart postfix
service postfix restart
that’s it you’re done configuring it test by sending email.