Atjeu
10-14-2004, 02:33 PM
Ok, so you need to re ip a site or a whole server and you want to do it with minimal or no downtime at all. Here are some steps. (Skip to the last FAQ if you want to do this all at your registrar and for sure have no downtime)
There are 2 different things involved in changing ips. One is the ip of the actual website as it is configured on your server in the various places (dns zones and httpd.conf), and the other is the ip of the dns servers that serve that website. If you need to re ip a whole server, then both need to be changed. If you just need to move a site to a new ip you don’t need to change the dns servers.
Changing the IP of a nameserver is done at your registrar and is not something Atjeu can help you with. Your nameservers IPs are not stored on your computer, they are handled by your registrar which are then uploaded daily to the master TLD servers that handle .com .net .org and so on. The individual websites IPs ARE handled on your server in your dns zones and those are something you can change directly on your server.
Ok, lets look at a few different scenarios. For all of the following, lets assume that you have 2 nameservers, ns1.abc.com and ns2.abc.com and that at your registrar you have assigned ns1.abc.com 1.1.1.1 and ns2.abc.com 1.1.1.2. Lets also assume that you have all the websites on your server pointed to ns1.abc.com and ns2.abc.com at your registrar. And finally, lets assume that you have added the new ip to your server either via a control panel or by adding a virtual interface in /etc/sysconfig/network-scripts.
First scenario, you just need to change the IP of a website called test.com from 2.2.2.2 to 3.3.3.3 - this is the most simple ip change. All you need to do are these 2 steps.
1. Go into the dns zone on your server for this website and update all the old ips in the zone for test.com to the new ips. The part of the zone for test.com might look like this:
test.com. 14400 IN NS ns1.abc.com.
test.com. 14400 IN NS ns2.abc.com.
test.com. 14400 IN A 2.2.2.2
www 14400 IN A 2.2.2.2
you can see here all you need to do is replace 2.2.2.2 with 3.3.3.3, save the zone and restart your dns server (ssh in as root and type /etc/init.d/named stop and then /etc/init.d/named start) and that takes care of pointing the dns to the right ip. As a side note, this change takes place immediately. Therefore anyone that tries to go to test.com will from this point foward be directed to the new ip 3.3.3.3 instead of 2.2.2.2. However, since most peoples isp's cache records when they look them up for 12 hours or so, those people who went to the site in the past 12 hours may still go to the old ip 2.2.2.2 until their isps dns servers cache expires. Then their ips’s dns will go out and look for the dns record for test.com again and will get the new ip 3.3.3.3 (If you really want to be advanced you can change your TTL’s so a small value like 30 minutes and then come back the next day and make the changes – that way the isp’s dns should only cache for 30 minutes not 12 hours).
2. Go to your apache config (/etc/httpd/conf/httpd.conf) (for servers with a control panel, go to the control panel and change the sites IP from 2.2.2.2 to 3.3.3.3 and you are done) and find the virtual site section for test.com and change the ip from 2.2.2.2 to 3.3.3.3. Restart apache (/etc/init.d/httpd stop and then /etc/init.d/httpd start) and thats it, you are done. For a cpanel server WHM has a nice button called “change sites IP” so you can do all the above with with one click.
If you are concerned about the people who have been to test.com in the last 12 hours and who, for a few hours, might still be trying to go to the old ip, you can add another virtual conf section in httpd.conf by duplicating the old one for test.com, change the server name in the new virtual conf to *.test.com, then change the iop on one of them to the old ip 2.2.2.2 so you have one with the old ip and one with the new ip, then add the NameVirtualHost directive(if its not already there) for 2.2.2.2 and 3.3.3.3 - that way you will have 2 different virtual confs for test.com, one on the old ip and one on the new one so that apache will catch people coming to either IP... the name based directive tells apache to look at the URL of the requested domain and make sure it matches the server name in the virtual conf. If you do this, you will need to remember to come back in 12 hours and
delete the virtual conf with the old ip as you wont need it.
Those changes should take no more then about a minute per site if that once you get it down. If your sites are name based then they you would do the same thing but also remember to change the NameVirtualHost line to the new ip also. In either case, both ips
Second Scenario, you need to re ip a whole server, nameservers and all. The new ips of the nameservers are 4.4.4.4 and 4.4.4.5 This also is not a big deal as long as you can have both the old and new ips up at the same time. Please note that in place of doing everything below you could register new nameservers like ns3.abc.com and ns4.abc.com (of course on the new ips) and then repoint your domains to your new nameservers at your registrar – this is by far the easiest method and there is ZERO downtime with this method.
1. Go to your registrar and update the "host" records for your nameservers - basically you are telling your host that ns1.abc.com is now 4.4.4.4 and ns2.abc.com is now 4.4.4.5 - once you make this update at your registrar it is NOT instantly active. This usually takes 24 to 48 hrs depending on your registrar so keep that in mind.
2. On your server, go to the dns zone for abc.com and update the ips. Before the zone for abc.com might have looked like this
abc.com. 14400 IN NS ns1.abc.com.
abc.com. 14400 IN NS ns2.abc.com.
abc.com. 14400 IN A 1.1.1.1
www 14400 IN A 1.1.1.1
ns1 14440 IN A 1.1.1.1
ns2 14440 IN A 1.1.1.2
and you just need to change the ips to the new ones so it looks like this
abc.com. 14400 IN NS ns1.abc.com.
abc.com. 14400 IN NS ns2.abc.com.
abc.com. 14400 IN A 4.4.4.4
www 14400 IN A 4.4.4.4
ns1 14440 IN A 4.4.4.4
ns2 14440 IN A 4.4.4.5
and thats it. Now you have updated your nameservers on your server.
2. Now, you just need to change the IP's on your websites as outlined in the first scenario and you are all done. Again, this can all be done with no downtime at all as long as you are able to have both the old ips and new ips on your server at the same time. That way anyone coming from an old cached dns lookup will get there using the old ip until their isp’s dns updates, and anyone coming to your site using a more recent non-cached lookup will get to your sites using the new ips.
FAQ.
Q. I did all this an hour ago but I still get the old ip when I do an nslookup on my server.
A. Thats because you are probably using your isp’s dns which has cached the old ips. To get around this you can either wait for the cache to expire, or you can go into your network settings on your computer at home/work and you can set the dns servers it uses to your server at Atjeu - just put in the ip(s) of your nameservers on your server at Atjeu - in the above scenarios, you would put in ns1.abc.com and ns2.abc.com and the respective ips. Then from that point on you are using the dns on your server at Atjeu do do your lookups from your home/work computer, and you will see any changes you make in your server at Atjeu instantly!! Neat trick.
Q. What about the method of making new nameservers – is there an easy step by step and this really has no downtime?
A. Yes, this method really has no downtime and the work is all done at the registrar rather then on your server.
For a step by step:
1. Go to your registrar and make 2 new nameservers for your existing domain that has your nameservers and make sure to use the new ips – like ns3.abc.com and ns4.abc.com (if you were already using ns1.abc.com and ns2.abc.com).
2. Go to the abc.com zone on your server and add 2 “A” record entries for ns3 and ns4.
ns3 14440 IN A 4.4.4.4
ns4 14440 IN A 4.4.4.5
3. Wait a day or two for the new nameservers to be active
4. At your registrar, edit your domains and point them to ns3.abc.com and ns4.abc.com as the primary and secondary dns for the domains and wait a day or two for all to propagate
That’s it… when your done you can either decommission ns1.abc.com and ns2.abc.com or you can then change the ips of those at your registrar to new ips and still continue to use them and just have 4 nameservers on your server – no big deal smile.gif
There are 2 different things involved in changing ips. One is the ip of the actual website as it is configured on your server in the various places (dns zones and httpd.conf), and the other is the ip of the dns servers that serve that website. If you need to re ip a whole server, then both need to be changed. If you just need to move a site to a new ip you don’t need to change the dns servers.
Changing the IP of a nameserver is done at your registrar and is not something Atjeu can help you with. Your nameservers IPs are not stored on your computer, they are handled by your registrar which are then uploaded daily to the master TLD servers that handle .com .net .org and so on. The individual websites IPs ARE handled on your server in your dns zones and those are something you can change directly on your server.
Ok, lets look at a few different scenarios. For all of the following, lets assume that you have 2 nameservers, ns1.abc.com and ns2.abc.com and that at your registrar you have assigned ns1.abc.com 1.1.1.1 and ns2.abc.com 1.1.1.2. Lets also assume that you have all the websites on your server pointed to ns1.abc.com and ns2.abc.com at your registrar. And finally, lets assume that you have added the new ip to your server either via a control panel or by adding a virtual interface in /etc/sysconfig/network-scripts.
First scenario, you just need to change the IP of a website called test.com from 2.2.2.2 to 3.3.3.3 - this is the most simple ip change. All you need to do are these 2 steps.
1. Go into the dns zone on your server for this website and update all the old ips in the zone for test.com to the new ips. The part of the zone for test.com might look like this:
test.com. 14400 IN NS ns1.abc.com.
test.com. 14400 IN NS ns2.abc.com.
test.com. 14400 IN A 2.2.2.2
www 14400 IN A 2.2.2.2
you can see here all you need to do is replace 2.2.2.2 with 3.3.3.3, save the zone and restart your dns server (ssh in as root and type /etc/init.d/named stop and then /etc/init.d/named start) and that takes care of pointing the dns to the right ip. As a side note, this change takes place immediately. Therefore anyone that tries to go to test.com will from this point foward be directed to the new ip 3.3.3.3 instead of 2.2.2.2. However, since most peoples isp's cache records when they look them up for 12 hours or so, those people who went to the site in the past 12 hours may still go to the old ip 2.2.2.2 until their isps dns servers cache expires. Then their ips’s dns will go out and look for the dns record for test.com again and will get the new ip 3.3.3.3 (If you really want to be advanced you can change your TTL’s so a small value like 30 minutes and then come back the next day and make the changes – that way the isp’s dns should only cache for 30 minutes not 12 hours).
2. Go to your apache config (/etc/httpd/conf/httpd.conf) (for servers with a control panel, go to the control panel and change the sites IP from 2.2.2.2 to 3.3.3.3 and you are done) and find the virtual site section for test.com and change the ip from 2.2.2.2 to 3.3.3.3. Restart apache (/etc/init.d/httpd stop and then /etc/init.d/httpd start) and thats it, you are done. For a cpanel server WHM has a nice button called “change sites IP” so you can do all the above with with one click.
If you are concerned about the people who have been to test.com in the last 12 hours and who, for a few hours, might still be trying to go to the old ip, you can add another virtual conf section in httpd.conf by duplicating the old one for test.com, change the server name in the new virtual conf to *.test.com, then change the iop on one of them to the old ip 2.2.2.2 so you have one with the old ip and one with the new ip, then add the NameVirtualHost directive(if its not already there) for 2.2.2.2 and 3.3.3.3 - that way you will have 2 different virtual confs for test.com, one on the old ip and one on the new one so that apache will catch people coming to either IP... the name based directive tells apache to look at the URL of the requested domain and make sure it matches the server name in the virtual conf. If you do this, you will need to remember to come back in 12 hours and
delete the virtual conf with the old ip as you wont need it.
Those changes should take no more then about a minute per site if that once you get it down. If your sites are name based then they you would do the same thing but also remember to change the NameVirtualHost line to the new ip also. In either case, both ips
Second Scenario, you need to re ip a whole server, nameservers and all. The new ips of the nameservers are 4.4.4.4 and 4.4.4.5 This also is not a big deal as long as you can have both the old and new ips up at the same time. Please note that in place of doing everything below you could register new nameservers like ns3.abc.com and ns4.abc.com (of course on the new ips) and then repoint your domains to your new nameservers at your registrar – this is by far the easiest method and there is ZERO downtime with this method.
1. Go to your registrar and update the "host" records for your nameservers - basically you are telling your host that ns1.abc.com is now 4.4.4.4 and ns2.abc.com is now 4.4.4.5 - once you make this update at your registrar it is NOT instantly active. This usually takes 24 to 48 hrs depending on your registrar so keep that in mind.
2. On your server, go to the dns zone for abc.com and update the ips. Before the zone for abc.com might have looked like this
abc.com. 14400 IN NS ns1.abc.com.
abc.com. 14400 IN NS ns2.abc.com.
abc.com. 14400 IN A 1.1.1.1
www 14400 IN A 1.1.1.1
ns1 14440 IN A 1.1.1.1
ns2 14440 IN A 1.1.1.2
and you just need to change the ips to the new ones so it looks like this
abc.com. 14400 IN NS ns1.abc.com.
abc.com. 14400 IN NS ns2.abc.com.
abc.com. 14400 IN A 4.4.4.4
www 14400 IN A 4.4.4.4
ns1 14440 IN A 4.4.4.4
ns2 14440 IN A 4.4.4.5
and thats it. Now you have updated your nameservers on your server.
2. Now, you just need to change the IP's on your websites as outlined in the first scenario and you are all done. Again, this can all be done with no downtime at all as long as you are able to have both the old ips and new ips on your server at the same time. That way anyone coming from an old cached dns lookup will get there using the old ip until their isp’s dns updates, and anyone coming to your site using a more recent non-cached lookup will get to your sites using the new ips.
FAQ.
Q. I did all this an hour ago but I still get the old ip when I do an nslookup on my server.
A. Thats because you are probably using your isp’s dns which has cached the old ips. To get around this you can either wait for the cache to expire, or you can go into your network settings on your computer at home/work and you can set the dns servers it uses to your server at Atjeu - just put in the ip(s) of your nameservers on your server at Atjeu - in the above scenarios, you would put in ns1.abc.com and ns2.abc.com and the respective ips. Then from that point on you are using the dns on your server at Atjeu do do your lookups from your home/work computer, and you will see any changes you make in your server at Atjeu instantly!! Neat trick.
Q. What about the method of making new nameservers – is there an easy step by step and this really has no downtime?
A. Yes, this method really has no downtime and the work is all done at the registrar rather then on your server.
For a step by step:
1. Go to your registrar and make 2 new nameservers for your existing domain that has your nameservers and make sure to use the new ips – like ns3.abc.com and ns4.abc.com (if you were already using ns1.abc.com and ns2.abc.com).
2. Go to the abc.com zone on your server and add 2 “A” record entries for ns3 and ns4.
ns3 14440 IN A 4.4.4.4
ns4 14440 IN A 4.4.4.5
3. Wait a day or two for the new nameservers to be active
4. At your registrar, edit your domains and point them to ns3.abc.com and ns4.abc.com as the primary and secondary dns for the domains and wait a day or two for all to propagate
That’s it… when your done you can either decommission ns1.abc.com and ns2.abc.com or you can then change the ips of those at your registrar to new ips and still continue to use them and just have 4 nameservers on your server – no big deal smile.gif