Thursday, March 14, 2013

change sites ip addresses for all domains in a server


Hi Guys,

Here is the simple script to change sites ip addresses in the server. This will be very useful while server migration when the server is having thousands of domains with its dedicated ips.

syntax for setsiteip
---------
/usr/local/cpanel/bin/setsiteip [-u user | domain] ip
---------

This is something looks like below,
---------
# head -3 /root/setip
a.com 1.2.3.4
b.com 1.2.3.5
c.com 1.2.3.6
---------

Also you can get this from old server /etc/domainips list by just running this command

# awk '{print $2" "$1}' /etc/domainips|cut -d : -f1 > /root/setip

Download the setip file to the new server and then run this script on screen

Then run this script in screen

-----------------------
#! /bin/bash
exec < /root/setip
while read line
do
dmn=$(echo $line | awk '{print $1}')
ip=$(echo $line | awk '{print $2}')
/usr/local/cpanel/bin/setsiteip $dmn $ip
done
-----------------------

Thats it. now all the domains will have its own dedicated ips.

No comments:

Post a Comment