Author Topic: How to change your server IP address and change ttl zonefile dns on directadmin  (Read 12454 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2145
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
How to change your server IP address and change ttl zonefile dns on directadmin
« on: สิงหาคม 08, 2012, 04:11:03 PM »
If your server requires a new server IP due to server move, or network restructuring, follow the following steps to update your license and system.

1) Contact DirectAdmin ahead of the move to notify them of the new IP address.  Include the old IP, and license ID.  Note that if you have an internal license, you must be the datacenter to make this request.  If you cannot view your license from your clients section then you do not have authority to issue the request.   Note that DirectAdmin will continue to run even after we change the IP.  You just can't update the license or DA at this time.  Also ensure you have enough time before the license expires (eg: more than a day).

2) Boot the server with the new server ip.  Do this the same way you did originally for the old server IP.  This should be done in your system's network settings and not in DirectAdmin (yet).  Do not add the IP to DA through the IP Manager.

DirectAdmin will not be running, as the license file will be invalid.

Assuming we got your email and processed the request in step 1), you should now be able to get the new license file:

Quote
cd /usr/local/directadmin/scripts
./getLicense.sh 1234 56789

and replace 1234 with your client ID number, and replace 56789 with your license ID number.   See this guide for more information on downloading the license.key.


3) Start DirectAdmin with the new license:

Quote
/etc/init.d/directadmin restart

The dataskq may have already started it, thus the restart instead of just "start".

4) Run the ipswap.sh script to replace the old server IP (1.2.3.4) with the new server IP (4.3.2.1)

Quote
cd /usr/local/directadmin/scripts  
./ipswap.sh 1.2.3.4 4.3.2.1


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.   As mentioned before, you must not add the new IP do DA through the IP Manager.  The new server IP is to be added using the ipswap.sh script.  It will remove the old IP as well automatically.

Restart everything:

Quote
/etc/init.d/httpd restart
/etc/init.d/proftpd restart
/etc/init.d/exim restart
/etc/init.d/dovecot restart
etc.


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

Note for any domain that will have it's IP change, you may notice dns propogation delay.  See the Related Guides below to lower the TTL before doing the move, and also why you may be seeing the apache or shared IP page after an IP change.


###Reduce TTL on zonefile in server use directadmin

How to lower your TTL just before an IP change   Last Modified: Apr 20, 2012, 2:03 pm
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:

Quote

#cd /usr/local/directadmin/data/templates
#perl -pi -e 's/14400/300/' 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 300 instead of 14400.  Once complete, do the same thing, but replace 300 with 14400 and 14400 with 300 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 300 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.

*** Note: On Debian systems, replace /var/named with /etc/bind.
On FreeBSD systems, replace /var/named with /etc/namedb.
« Last Edit: สิงหาคม 08, 2012, 04:14:43 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2145
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: How to change your server IP address and change ttl zonefile dns on directadmin
« Reply #1 on: สิงหาคม 08, 2012, 04:14:12 PM »
เมื่อเปลี่ยน TTL เสร็จแล้วหลังจากที่ เปลี่ยน ip เป็น ip ใหม่เรียบร้อยแล้วให้ทำการปรับค่า TTL คืนเป็น 14400 sec (4 ชม) ดังนี้ ครับ

#cd /usr/local/directadmin/data/templates
#perl -pi -e 's/300/14400/' named.db
#echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
« Last Edit: สิงหาคม 08, 2012, 04:17:40 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2145
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email