Tuesday, June 25, 2013

Exim Ip rotation script

/etc/eximserverip
/etc/eximiprotate
/etc/script_eximrotate

Sample script . Please don't use this of you don't know what you are doing . Please contact me if you need assistance .
# cat /etc/eximserverip
15

xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx

 xxx.xxx.xxx.xxx

  [~]# cat /etc/eximiprotate

#/bin/bash
#IP Selcetor

ipnumber=$(head -n 1 /etc/eximserverip)
if [ "$ipnumber" -eq 16 ]; then
ipnumber=2;
fi

#IP to be used for changing
head -$ipnumber /etc/eximserverip |tail -1
#Increamenting the no of Ip to be used .
ipnumber=$(($ipnumber+1))
sed -i -e '1 s/\S\+/'"${ipnumber}"'/' /etc/eximserverip

cat /etc/script_eximrotate
#script to change the exim IP

interface=0
interface="interface = $(sh /etc/eximiprotate)"
echo $interface;
sed -i -e '1666 s/.*/'"${interface}"'/1' /etc/exim.conf
/etc/init.d/exim restart

No comments:

Post a Comment