Jump to content

Postfix add Dedicated Static IP per user for mail sending out CWP Linux Ubuntu

Featured Replies

Posted

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$/       username1:
/@user2-domain\.tld$/       username2:
/@user3-domain\.tld$/       username3:


replace /@user1-domain\.tld$/ with domain.tld eg : /@alphagnu\.com$/
replace username1 with account username alphagnu
you can add like this for multi users and domains.

Now In /etc/postfix/master.cf create and add special transport lines called user1, user2, user3 and more user as per need :

username1  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.1
   -o smtp_helo_name=user1-domain.tld
   -o syslog_name=postfix-username1

username2  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.2
   -o smtp_helo_name=user2-domain.tld
   -o syslog_name=postfix-username2

username3  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.3
   -o smtp_helo_name=user3-domain.tld
   -o syslog_name=postfix-username3


Replace smtp_bind_address ip with the dedicated ip for the user account.

eg :

alphagnu  unix -       -       n       -       -       smtp
   -o smtp_bind_address=10.10.10.1
   -o smtp_helo_name=alphagnu.com
   -o syslog_name=postfix-alphagnu


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.

Nice, thank you so much!

P.S.: can to be make it one site (account) in CWP to use independent IP? Example: all server use 1.2.3.4 but only domainame.com use 1.2.3.5 ...

  • Author
9 hours ago, torettos said:

Nice, thank you so much!

P.S.: can to be make it one site (account) in CWP to use independent IP? Example: all server use 1.2.3.4 but only domainame.com use 1.2.3.5 ...

yes its possible 

Create an account or sign in to comment