Change IP / move to new datacenter

Guillermo

Verified User
Joined
May 20, 2006
Messages
95
Location
The Netherlands
My server is going to be placed in a new datacenter tonight, so i have to change the IP and DNS settings.
Now, when i go to DNS administration in the DA panel, i see i have to change all the A records for each domain manually :(. Is there a way to change it automatically for each domain?
 
Code:
cd /var/named
perl -pi -e 's/OLD_IP/NEW_IP/' *.db
service named restart
 
http://help.directadmin.com/item.php?id=87

When changing the IP of a domain, end users will have the old IP of the domain cached at their ISP's nameservers for a duration of the TTL (time to live). The default value is 14400 seconds (4 hours). This means, that when you change the IP of the sever, the worst case, is the end users will be using the wrong IP for 4 hours before the cache expires and the IP is recached with the correct value.

The simple way to minimize this propogation error is to lower the TTL. We'll change the TTL from 14400 to 100 seconds for all domains on your system (assuming server move). Run the following:

cd /usr/local/directadmin/data/templates
perl -pi -e 's/14400/100/' named.db
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
Wait about a minute or 2. Check your /var/named/*.db files.. the TTL should now be 100 instead of 14400. Once complete, do the same thing, but replace 100 with 14400 and 14400 with 100 in the perl command.

If you are running the for just one domain, then run the perl command in /var/named/domain.com.db, instead of the named.db file and restart named.

In both cases, you'll want to do this at least 4 hours before you actually do the IP change so that all cached values are stored for no more than 100 seconds. The nameservers will then query for the new IP every 100 seconds (instead of 4 hours), giving the end user the new IP much quicker.

John

--
http://www.directadmin.com/change_ip.txt

Steps for changing server ip and creating images.

**** Change server ip ****
Boot the server with the new server ip. (the new one you want to use)
DirectAdmin will not be running, as the license file will be invalid.
Contact DirectAdmin to obtain a new license file. They will change the ip in the license.
Get the new license file:

cd /usr/local/directadmin/scripts
./getLicense.sh UID LID

Where UID and LID are your client ID and your license id.
Ensure the license downloaded properly by making sure the file contains no error messages.
Start DirectAdmin with the new license:

service directadmin restart

(The taskq may have already started it, thus the restart instead of just "start")

Download the ipswap.sh script from directadmin:

wget http://www.directadmin.com/ipswap.sh
chmod 755 ipswap.sh

Execute that script with the old and and the new ip. Example:

./ipswap.sh 1.2.3.4 4.3.2.1

where 1.2.3.4 is your old ip and 4.3.2.1 is the new ip.
This script can be run on any ip, so if you want to change all ips with new ones, just run this script for each old ip with the new ip. Just ensure that you match the new server ip with the old one.

Restart everything:

service httpd restart
service proftpd restart
service exim restart
service vm-pop3d restart
...

Make sure they are correctly binding to the new ports by testing them.

You'll need to update the users list cache so that you see the new results in the show users lists:

echo "action=cache&value=showallusers" >> /usr/local/directadmin/data/task.queue

That's it :)




**** Creating an Image ****

Install whatever additional services you want on the server (if you need up2date, this would be a good time)

Install a default copy of DirectAdmin on a server.
Be sure to install the customapache script.

Delete the license (doesn't really matter.. just so that nobody else gets a hold of it)

Create the image using whatever method you would like.


*** copy the image to the new server

Run the scripts you would normally run to setup the image properly.
Instead of manually changing the ip through DirectAdmin (as above), you can use the ipswap.sh script as decribed above to swap all instances of the IPs.

When you need to use the server, contact DirectAdmin, order a license using the new server's ip.
Once activated, use the getLicense.sh (see above) to download the license for this system.

Restart DirectAdmin and you should be up and running.

--
 
Thanks for the help.

This is the first time i change the server IP and DNS values, and i need to know which files/configs i have to modify.

I know i have to modify the following files:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network
/usr/local/directadmin/data/users/XXXXX/httpd.conf
/etc/httpd/conf/httpd.conf
/var/named/*.db's
/etc/resolv.conf
/etc/hosts
/etc/named.conf


What else? Did i forget something?
 
Last edited:
Thanks for the help.

This is the first time i change the server IP and DNS values, and i need to know which files/configs i have to modify.

I know i have to modify the following files:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network
/usr/local/directadmin/data/users/XXXXX/httpd.conf
/etc/httpd/conf/httpd.conf
/var/named/*.db's
/etc/resolv.conf
/etc/hosts
/etc/named.conf


What else? Did i forget something?

Just change ip for your network interface
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network
/etc/resolv.conf

And the rest ipswap.sh will do for you
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/ips.conf
/etc/proftpd.conf
/etc/proftpd.vhosts.conf
/etc/hosts
/usr/local/directadmin/scripts/setup.txt
/usr/local/directadmin/data/admin/ip.list
/usr/local/directadmin/data/users/*/user.conf
/usr/local/directadmin/data/users/*/httpd.conf
/usr/local/directadmin/data/users/*/ip.list
/usr/local/directadmin/data/users/*/domains/*.conf
/usr/local/directadmin/data/users/*/domains/*.ftp
/etc/namedb/*.db
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
echo "action=cache&value=showallusers" >> /usr/local/directadmin/data/task.queue
 
Just change ip for your network interface
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network
/etc/resolv.conf

And the rest ipswap.sh will do for you
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/ips.conf
/etc/proftpd.conf
/etc/proftpd.vhosts.conf
/etc/hosts
/usr/local/directadmin/scripts/setup.txt
/usr/local/directadmin/data/admin/ip.list
/usr/local/directadmin/data/users/*/user.conf
/usr/local/directadmin/data/users/*/httpd.conf
/usr/local/directadmin/data/users/*/ip.list
/usr/local/directadmin/data/users/*/domains/*.conf
/usr/local/directadmin/data/users/*/domains/*.ftp
/etc/namedb/*.db
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
echo "action=cache&value=showallusers" >> /usr/local/directadmin/data/task.queue

Great, will do that!
 
I have some problems with my DNS server after the IP change / ipswap.

Named is running, but when i look at the status i see:

]# service named status
rndc: connection to remote host closed
This may indicate that the remote server is using an older version of
the command protocol, this host is not authorized to connect,
or the key is invalid.


Also, i can't access my websites anymore since one hour ago, everything was working well, and all in a sudden it doesn't.
 
1. Check if you have firewall, ip in firewall rules must match the new one.
2. Check if your named use forward dns to old isp, or bind to old ip address.
 
Back
Top