imran_k

Registered
Mar 10, 2014
3
1
1
cPanel Access Level
Root Administrator
Hello,

I want to rotate IP Address every two hours to send mail from the WHM/cPanel server.
My WHM/cPanel version is 11.42 and exim version is 4.82. Please provide me the step by step procedure to do this automatically.

Thanks,
Imran Khan.
 
  • Like
Reactions: Gino Viroli

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello :)

Could you elaborate on the purpose of alternating your IP address? For instance, do you mean you want to send from a different IP address every two hours? Is your server's IP becoming blocked by spam lists?

Thank you.
 

imran_k

Registered
Mar 10, 2014
3
1
1
cPanel Access Level
Root Administrator
Hello,

Yes I want to send mails from different IP Address every hours. I want to maintain reputation of all the IP address which are in the servers.

Thanks,
Imran Khan.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
I'm not sure I understand how changing the IP addresses is going to make a difference. If SPAM is sent out, it could still result in an IP address getting added to a blacklist. However, by changing the IP address, you ensure the domain name that did not send out the SPAM is blacklisted instead of the domain name that sent it out.

I recommend taking steps to prevent email abuse on your server. The following document is a good place to start:

cPanel - Prevent Email Abuse

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Yes I want to send mails from different IP Address every hours. How to do this?
There are no native features that would allow you to rotate the IP addresses used for sending out email. The options included with cPanel/WHM only allow for the permanent change of the IP addresses used for sending. You would have to develop a script that makes the changes listed here automatically. That being said, please see my previous response on this thread, as it seems like this type of setup might not be a good idea.

Thank you.
 

vanessa

Well-Known Member
PartnerNOC
Sep 26, 2006
959
76
178
Virginia Beach, VA
cPanel Access Level
DataCenter Provider
I wrote this a while back for someone else, maybe it can help you. It's intended to run via cron. Just put your IPs in /etc/mailipaddrpool, one on each line.

Code:
#!/bin/bash
# Exim Outgoing IP address rotator
# The cPanel Admin 5/9/11
# Files: /etc/mailipaddrpool : list of IP addresses to use for mail

ipfile=/etc/mailipaddrpool
curip=$(grep "*:" /etc/mailips |awk '{print $2}')

if [[ "$curip" == "" ]] || ! grep $curip $ipfile >/dev/null ; then
	curip=$(tail -1 $ipfile)
fi

nextipct=$(cat $ipfile |grep -A 1 $curip |wc -l)

if [ "$nextipct" == "1" ];then
	nextip=$(head -1 $ipfile)
else
	nextip=$(cat $ipfile |grep -A 1 $curip | tail -1)
fi

sed '/*:/d' -i /etc/mailips
sed '/^$/d' -i /etc/mailips
echo "*: $nextip" >> /etc/mailips
It's not the prettiest, but it does the job. To add on to cPanelMichael's point, you may want to add measures to limit how many rotations are done within a certain period of time. If someone is spamming from your server and you're changing the IP, every IP you change to will get blacklisted.
 

TeqExperts

Registered
May 11, 2014
1
0
1
cPanel Access Level
Root Administrator
I have found script do Ip rotation but, need someone explain step by step cause i need it too

/http://jackal777.wordpress.com/2012/08/26/script-to-rotate-ip-of-a-cpanel-domain/
Script to rotate IP of a cpanel domain
 

slideloft

Member
May 8, 2013
8
0
1
cPanel Access Level
Root Administrator
this is what i found from the link
should i add like this
# Files: /etc/mailipaddrpool : 1.0.02,1.0.03,1.0.0.4
Assuming the ip are 1.0.02,1.0.03,1.0.0.4

#!/bin/bash
# Exim Outgoing IP address rotator
# The cPanel Admin 5/9/11
# Files: /etc/mailipaddrpool : list of IP addresses to use for mail

ipfile=/etc/mailipaddrpool
curip=$(grep "*:" /etc/mailips |awk '{print $2}')

if [[ "$curip" == "" ]] || ! grep $curip $ipfile >/dev/null ; then
curip=$(tail -1 $ipfile)
fi

nextipct=$(cat $ipfile |grep -A 1 $curip |wc -l)

if [ "$nextipct" == "1" ];then
nextip=$(head -1 $ipfile)
else
nextip=$(cat $ipfile |grep -A 1 $curip | tail -1)
fi

sed '/*:/d' -i /etc/mailips
sed '/^$/d' -i /etc/mailips
echo "*: $nextip" >> /etc/mailips
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello,

Yes, however ensure the IP addresses are on separate lines in the /etc/mailipaddrpool file. EX:

Code:
1.1.1.1
2.2.2.2
3.3.3.3
Thank you.
 
Thread starter Similar threads Forum Replies Date
A Email 1
B Email 6
Osama Tariq Email 1
A Email 1
V Email 1