How To Rotate IP Address Pool In Linux (Redhat / Centos / Ubuntu / Debian)

How To Rotate IP Address Pool In Linux (Redhat / Centos / Ubuntu / Debian)

Hi Everyone ……..

Today I have received a mail and the user asked me a question.

<<< I have a Postfix( Version 2.8) mail server & 8 Public IP address pool. But by default Postfix uses IP address of eth0 Lan card on every email so only one IP address is used as source of every mail.

So can you help me how to rotate my Ip address pool with postfix so that every time the source address will be different on each mail or bunch of 20/30 email. >>>

 

Here is the answer:—-

You can rotate your Server IP address pool  in Linux server by using iptable NAT Postrouting.

I assume you have 8 public IP addresses (x.x.x.1 TO x.x.x.8) configure on Linux postfix server.

Now we rotate only SMPT (port no. 25) traffic, every time SMTP services use different IP address.  All 8 IP rotate automatically when your mail server send mail to other user, Every time Linux mail server generate different source address.

 

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source  x.x.x.1

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source x.x.x.2

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source x.x.x.3

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source x.x.x.4

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source x.x.x.5

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source x.x.x.6

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source x.x.x.7

# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 8 --packet 0 -j SNAT --to-source x.x.x.8


So as per requirement of services you can rotate your whole IP address  pool or multiple ip address with different different service port number.

Now if you send 8 mail then all 8 mail  have different source address and then it roll over again in the sequence  of  1 to 8.

{#moods_dlg.WellDone}

 

Leave a Reply

Time limit is exhausted. Please reload the CAPTCHA.