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

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.

 

This entry was posted in Exim, Linux, Mail server, Plesk, Postfix. Bookmark the permalink.

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

  1. Success mart says:

    How i will check if ip rotation is working?
    I tried on centos .
    Is there any command or website or software through which i can check if ip rotation is working for emails i am sending?

Leave a Reply

Your email address will not be published.