Moving many sites to new server - whats the quickest way to update their DNS records?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm planning on migrating a large-ish amount of websites (approx 100) to a new server and I'm in the migration planning process.



A typical DNS zone for each website has two A records pointing to the web server IP, one for domain.com and one for the www subdomain.



When we're all setup and ready to launch the new server to production, changing 100x2 DNS records will be time-consuming so I'm searching a way to make this quicker. In a couple cases I read about creating a bash script that iterates the DNS records and performs a find-replace with the new IP.
In other topics I've read suggestions about adding A records with the new IP so that when the current server is no longer available, the DNS server will point the requests to the next record, that containing the new IP.



Apart from these, is there any scenario in which I could replace the A records with some other type of DNS entry ie a hostname so that, when the time comes, I can only change the IP of the hostname with the new one and have all websites point to the new server? I'm sure 'hostname' is not the right term, I hope you all get the idea though.










share|improve this question







New contributor




bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • What DNS server / service are you using? When you do make the change you could consider using a CNAME rather than A record then if you move server again you only have a single A record to update
    – Phil
    36 mins ago










  • We're using WHM for managing our DNS. Good point about the CNAME, I'm going to use your suggestion.
    – bikey77
    20 mins ago














up vote
1
down vote

favorite












I'm planning on migrating a large-ish amount of websites (approx 100) to a new server and I'm in the migration planning process.



A typical DNS zone for each website has two A records pointing to the web server IP, one for domain.com and one for the www subdomain.



When we're all setup and ready to launch the new server to production, changing 100x2 DNS records will be time-consuming so I'm searching a way to make this quicker. In a couple cases I read about creating a bash script that iterates the DNS records and performs a find-replace with the new IP.
In other topics I've read suggestions about adding A records with the new IP so that when the current server is no longer available, the DNS server will point the requests to the next record, that containing the new IP.



Apart from these, is there any scenario in which I could replace the A records with some other type of DNS entry ie a hostname so that, when the time comes, I can only change the IP of the hostname with the new one and have all websites point to the new server? I'm sure 'hostname' is not the right term, I hope you all get the idea though.










share|improve this question







New contributor




bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • What DNS server / service are you using? When you do make the change you could consider using a CNAME rather than A record then if you move server again you only have a single A record to update
    – Phil
    36 mins ago










  • We're using WHM for managing our DNS. Good point about the CNAME, I'm going to use your suggestion.
    – bikey77
    20 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm planning on migrating a large-ish amount of websites (approx 100) to a new server and I'm in the migration planning process.



A typical DNS zone for each website has two A records pointing to the web server IP, one for domain.com and one for the www subdomain.



When we're all setup and ready to launch the new server to production, changing 100x2 DNS records will be time-consuming so I'm searching a way to make this quicker. In a couple cases I read about creating a bash script that iterates the DNS records and performs a find-replace with the new IP.
In other topics I've read suggestions about adding A records with the new IP so that when the current server is no longer available, the DNS server will point the requests to the next record, that containing the new IP.



Apart from these, is there any scenario in which I could replace the A records with some other type of DNS entry ie a hostname so that, when the time comes, I can only change the IP of the hostname with the new one and have all websites point to the new server? I'm sure 'hostname' is not the right term, I hope you all get the idea though.










share|improve this question







New contributor




bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm planning on migrating a large-ish amount of websites (approx 100) to a new server and I'm in the migration planning process.



A typical DNS zone for each website has two A records pointing to the web server IP, one for domain.com and one for the www subdomain.



When we're all setup and ready to launch the new server to production, changing 100x2 DNS records will be time-consuming so I'm searching a way to make this quicker. In a couple cases I read about creating a bash script that iterates the DNS records and performs a find-replace with the new IP.
In other topics I've read suggestions about adding A records with the new IP so that when the current server is no longer available, the DNS server will point the requests to the next record, that containing the new IP.



Apart from these, is there any scenario in which I could replace the A records with some other type of DNS entry ie a hostname so that, when the time comes, I can only change the IP of the hostname with the new one and have all websites point to the new server? I'm sure 'hostname' is not the right term, I hope you all get the idea though.







domain-name-system migration dns-zone






share|improve this question







New contributor




bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 59 mins ago









bikey77

1062




1062




New contributor




bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






bikey77 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • What DNS server / service are you using? When you do make the change you could consider using a CNAME rather than A record then if you move server again you only have a single A record to update
    – Phil
    36 mins ago










  • We're using WHM for managing our DNS. Good point about the CNAME, I'm going to use your suggestion.
    – bikey77
    20 mins ago
















  • What DNS server / service are you using? When you do make the change you could consider using a CNAME rather than A record then if you move server again you only have a single A record to update
    – Phil
    36 mins ago










  • We're using WHM for managing our DNS. Good point about the CNAME, I'm going to use your suggestion.
    – bikey77
    20 mins ago















What DNS server / service are you using? When you do make the change you could consider using a CNAME rather than A record then if you move server again you only have a single A record to update
– Phil
36 mins ago




What DNS server / service are you using? When you do make the change you could consider using a CNAME rather than A record then if you move server again you only have a single A record to update
– Phil
36 mins ago












We're using WHM for managing our DNS. Good point about the CNAME, I'm going to use your suggestion.
– bikey77
20 mins ago




We're using WHM for managing our DNS. Good point about the CNAME, I'm going to use your suggestion.
– bikey77
20 mins ago










2 Answers
2






active

oldest

votes

















up vote
4
down vote













The term you're looking for is CNAME, and the answer to your question is both yes and no.



First, here's an example of how a CNAME works in a zone file.



example.se IN SOA ns1.example.se. hostmaster.example.se. (
[....]
)

server1 A 10.1.2.3
www CNAME server1


Now you just need to update the server1 record in order to move both server1 and www to the new IP address.



The CNAME doesn't have to point to an address within the same domain; it could also look like this:



example.se IN SOA ns1.example.se. hostmaster.example.se. (
[....]
)

www CNAME server1.example.org.


Now, when you update the A record for server1 in the zone example.org, the record for www.example.se will follow along without any further configuration.



The bad part, from your point of view, is that this does not work for the apex record - that means the "bare" domain. In other words, you can make www.example.com into a CNAME, but you can't do that with example.com. This is because when you use a CNAME record, you can't have any additional records for that entry - meaning that you can't have mail server records, or name server records... meaning that the domain will stop working.



The best-practice solution is to use some kind of configuration management software, such as puppet, chef or ansible, to generate the zone files from a template. If, for some reason, that is not possible for you, then I'd use a script to replace the IP addresses in all files.



You'll also want to reduce the TTL value for the domain in due time before the migration. (And don't forget to update the serial number of the zone file - I have, and it's very embarrassing...)






share|improve this answer



























    up vote
    0
    down vote













    If I get this right the old server has a single IP address and the new one has only one, too.



    So what you could do is to set up the new server and on it just route all relevant http/https/ftp/whatever traffic to the old IP and then update the DNS records to show the new IP.



    If you only have one IP you can use a simple find/replace to change all IPs in the DNS (don't forget to update the serial number) at once and wait for your current TTL to run out. Once the TTL has run out you can just remove the routes on the new server and adjust your other settings, so that it serves the sites directly instead of redirecting.



    Before removing the routes the websites should have been moved to the new location obviously. This has the advantage that you don't have to rely on other DNS servers to update their records in time you can just "wait it out". To shorten that period you can reduce the TTL but be aware that some DNS caches out there ignore the TTL settings, that's why I don't rely on TTLs any more.






    share|improve this answer






















    • Care to explain a bit more about the routes you mentioned? What type/form do they have?
      – bikey77
      17 mins ago










    • I had to explain it a bit broader since you didn't mention which type of server you're using to serve your sites. E.g. in iptables (Linux) you could use Prerouting and masquerading to redirect traffic to a new location, see here: debuntu.org/… The problem with a DNS only approach is that you can't rely on when the DNS caches of your site's visitors update. With the routing approach you determine the time of the switch, minimizing potential downtimes.
      – Broco
      12 mins ago











    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "2"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    bikey77 is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f932945%2fmoving-many-sites-to-new-server-whats-the-quickest-way-to-update-their-dns-rec%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote













    The term you're looking for is CNAME, and the answer to your question is both yes and no.



    First, here's an example of how a CNAME works in a zone file.



    example.se IN SOA ns1.example.se. hostmaster.example.se. (
    [....]
    )

    server1 A 10.1.2.3
    www CNAME server1


    Now you just need to update the server1 record in order to move both server1 and www to the new IP address.



    The CNAME doesn't have to point to an address within the same domain; it could also look like this:



    example.se IN SOA ns1.example.se. hostmaster.example.se. (
    [....]
    )

    www CNAME server1.example.org.


    Now, when you update the A record for server1 in the zone example.org, the record for www.example.se will follow along without any further configuration.



    The bad part, from your point of view, is that this does not work for the apex record - that means the "bare" domain. In other words, you can make www.example.com into a CNAME, but you can't do that with example.com. This is because when you use a CNAME record, you can't have any additional records for that entry - meaning that you can't have mail server records, or name server records... meaning that the domain will stop working.



    The best-practice solution is to use some kind of configuration management software, such as puppet, chef or ansible, to generate the zone files from a template. If, for some reason, that is not possible for you, then I'd use a script to replace the IP addresses in all files.



    You'll also want to reduce the TTL value for the domain in due time before the migration. (And don't forget to update the serial number of the zone file - I have, and it's very embarrassing...)






    share|improve this answer
























      up vote
      4
      down vote













      The term you're looking for is CNAME, and the answer to your question is both yes and no.



      First, here's an example of how a CNAME works in a zone file.



      example.se IN SOA ns1.example.se. hostmaster.example.se. (
      [....]
      )

      server1 A 10.1.2.3
      www CNAME server1


      Now you just need to update the server1 record in order to move both server1 and www to the new IP address.



      The CNAME doesn't have to point to an address within the same domain; it could also look like this:



      example.se IN SOA ns1.example.se. hostmaster.example.se. (
      [....]
      )

      www CNAME server1.example.org.


      Now, when you update the A record for server1 in the zone example.org, the record for www.example.se will follow along without any further configuration.



      The bad part, from your point of view, is that this does not work for the apex record - that means the "bare" domain. In other words, you can make www.example.com into a CNAME, but you can't do that with example.com. This is because when you use a CNAME record, you can't have any additional records for that entry - meaning that you can't have mail server records, or name server records... meaning that the domain will stop working.



      The best-practice solution is to use some kind of configuration management software, such as puppet, chef or ansible, to generate the zone files from a template. If, for some reason, that is not possible for you, then I'd use a script to replace the IP addresses in all files.



      You'll also want to reduce the TTL value for the domain in due time before the migration. (And don't forget to update the serial number of the zone file - I have, and it's very embarrassing...)






      share|improve this answer






















        up vote
        4
        down vote










        up vote
        4
        down vote









        The term you're looking for is CNAME, and the answer to your question is both yes and no.



        First, here's an example of how a CNAME works in a zone file.



        example.se IN SOA ns1.example.se. hostmaster.example.se. (
        [....]
        )

        server1 A 10.1.2.3
        www CNAME server1


        Now you just need to update the server1 record in order to move both server1 and www to the new IP address.



        The CNAME doesn't have to point to an address within the same domain; it could also look like this:



        example.se IN SOA ns1.example.se. hostmaster.example.se. (
        [....]
        )

        www CNAME server1.example.org.


        Now, when you update the A record for server1 in the zone example.org, the record for www.example.se will follow along without any further configuration.



        The bad part, from your point of view, is that this does not work for the apex record - that means the "bare" domain. In other words, you can make www.example.com into a CNAME, but you can't do that with example.com. This is because when you use a CNAME record, you can't have any additional records for that entry - meaning that you can't have mail server records, or name server records... meaning that the domain will stop working.



        The best-practice solution is to use some kind of configuration management software, such as puppet, chef or ansible, to generate the zone files from a template. If, for some reason, that is not possible for you, then I'd use a script to replace the IP addresses in all files.



        You'll also want to reduce the TTL value for the domain in due time before the migration. (And don't forget to update the serial number of the zone file - I have, and it's very embarrassing...)






        share|improve this answer












        The term you're looking for is CNAME, and the answer to your question is both yes and no.



        First, here's an example of how a CNAME works in a zone file.



        example.se IN SOA ns1.example.se. hostmaster.example.se. (
        [....]
        )

        server1 A 10.1.2.3
        www CNAME server1


        Now you just need to update the server1 record in order to move both server1 and www to the new IP address.



        The CNAME doesn't have to point to an address within the same domain; it could also look like this:



        example.se IN SOA ns1.example.se. hostmaster.example.se. (
        [....]
        )

        www CNAME server1.example.org.


        Now, when you update the A record for server1 in the zone example.org, the record for www.example.se will follow along without any further configuration.



        The bad part, from your point of view, is that this does not work for the apex record - that means the "bare" domain. In other words, you can make www.example.com into a CNAME, but you can't do that with example.com. This is because when you use a CNAME record, you can't have any additional records for that entry - meaning that you can't have mail server records, or name server records... meaning that the domain will stop working.



        The best-practice solution is to use some kind of configuration management software, such as puppet, chef or ansible, to generate the zone files from a template. If, for some reason, that is not possible for you, then I'd use a script to replace the IP addresses in all files.



        You'll also want to reduce the TTL value for the domain in due time before the migration. (And don't forget to update the serial number of the zone file - I have, and it's very embarrassing...)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 37 mins ago









        Jenny D

        22.9k115789




        22.9k115789






















            up vote
            0
            down vote













            If I get this right the old server has a single IP address and the new one has only one, too.



            So what you could do is to set up the new server and on it just route all relevant http/https/ftp/whatever traffic to the old IP and then update the DNS records to show the new IP.



            If you only have one IP you can use a simple find/replace to change all IPs in the DNS (don't forget to update the serial number) at once and wait for your current TTL to run out. Once the TTL has run out you can just remove the routes on the new server and adjust your other settings, so that it serves the sites directly instead of redirecting.



            Before removing the routes the websites should have been moved to the new location obviously. This has the advantage that you don't have to rely on other DNS servers to update their records in time you can just "wait it out". To shorten that period you can reduce the TTL but be aware that some DNS caches out there ignore the TTL settings, that's why I don't rely on TTLs any more.






            share|improve this answer






















            • Care to explain a bit more about the routes you mentioned? What type/form do they have?
              – bikey77
              17 mins ago










            • I had to explain it a bit broader since you didn't mention which type of server you're using to serve your sites. E.g. in iptables (Linux) you could use Prerouting and masquerading to redirect traffic to a new location, see here: debuntu.org/… The problem with a DNS only approach is that you can't rely on when the DNS caches of your site's visitors update. With the routing approach you determine the time of the switch, minimizing potential downtimes.
              – Broco
              12 mins ago















            up vote
            0
            down vote













            If I get this right the old server has a single IP address and the new one has only one, too.



            So what you could do is to set up the new server and on it just route all relevant http/https/ftp/whatever traffic to the old IP and then update the DNS records to show the new IP.



            If you only have one IP you can use a simple find/replace to change all IPs in the DNS (don't forget to update the serial number) at once and wait for your current TTL to run out. Once the TTL has run out you can just remove the routes on the new server and adjust your other settings, so that it serves the sites directly instead of redirecting.



            Before removing the routes the websites should have been moved to the new location obviously. This has the advantage that you don't have to rely on other DNS servers to update their records in time you can just "wait it out". To shorten that period you can reduce the TTL but be aware that some DNS caches out there ignore the TTL settings, that's why I don't rely on TTLs any more.






            share|improve this answer






















            • Care to explain a bit more about the routes you mentioned? What type/form do they have?
              – bikey77
              17 mins ago










            • I had to explain it a bit broader since you didn't mention which type of server you're using to serve your sites. E.g. in iptables (Linux) you could use Prerouting and masquerading to redirect traffic to a new location, see here: debuntu.org/… The problem with a DNS only approach is that you can't rely on when the DNS caches of your site's visitors update. With the routing approach you determine the time of the switch, minimizing potential downtimes.
              – Broco
              12 mins ago













            up vote
            0
            down vote










            up vote
            0
            down vote









            If I get this right the old server has a single IP address and the new one has only one, too.



            So what you could do is to set up the new server and on it just route all relevant http/https/ftp/whatever traffic to the old IP and then update the DNS records to show the new IP.



            If you only have one IP you can use a simple find/replace to change all IPs in the DNS (don't forget to update the serial number) at once and wait for your current TTL to run out. Once the TTL has run out you can just remove the routes on the new server and adjust your other settings, so that it serves the sites directly instead of redirecting.



            Before removing the routes the websites should have been moved to the new location obviously. This has the advantage that you don't have to rely on other DNS servers to update their records in time you can just "wait it out". To shorten that period you can reduce the TTL but be aware that some DNS caches out there ignore the TTL settings, that's why I don't rely on TTLs any more.






            share|improve this answer














            If I get this right the old server has a single IP address and the new one has only one, too.



            So what you could do is to set up the new server and on it just route all relevant http/https/ftp/whatever traffic to the old IP and then update the DNS records to show the new IP.



            If you only have one IP you can use a simple find/replace to change all IPs in the DNS (don't forget to update the serial number) at once and wait for your current TTL to run out. Once the TTL has run out you can just remove the routes on the new server and adjust your other settings, so that it serves the sites directly instead of redirecting.



            Before removing the routes the websites should have been moved to the new location obviously. This has the advantage that you don't have to rely on other DNS servers to update their records in time you can just "wait it out". To shorten that period you can reduce the TTL but be aware that some DNS caches out there ignore the TTL settings, that's why I don't rely on TTLs any more.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 20 mins ago

























            answered 26 mins ago









            Broco

            1,075617




            1,075617











            • Care to explain a bit more about the routes you mentioned? What type/form do they have?
              – bikey77
              17 mins ago










            • I had to explain it a bit broader since you didn't mention which type of server you're using to serve your sites. E.g. in iptables (Linux) you could use Prerouting and masquerading to redirect traffic to a new location, see here: debuntu.org/… The problem with a DNS only approach is that you can't rely on when the DNS caches of your site's visitors update. With the routing approach you determine the time of the switch, minimizing potential downtimes.
              – Broco
              12 mins ago

















            • Care to explain a bit more about the routes you mentioned? What type/form do they have?
              – bikey77
              17 mins ago










            • I had to explain it a bit broader since you didn't mention which type of server you're using to serve your sites. E.g. in iptables (Linux) you could use Prerouting and masquerading to redirect traffic to a new location, see here: debuntu.org/… The problem with a DNS only approach is that you can't rely on when the DNS caches of your site's visitors update. With the routing approach you determine the time of the switch, minimizing potential downtimes.
              – Broco
              12 mins ago
















            Care to explain a bit more about the routes you mentioned? What type/form do they have?
            – bikey77
            17 mins ago




            Care to explain a bit more about the routes you mentioned? What type/form do they have?
            – bikey77
            17 mins ago












            I had to explain it a bit broader since you didn't mention which type of server you're using to serve your sites. E.g. in iptables (Linux) you could use Prerouting and masquerading to redirect traffic to a new location, see here: debuntu.org/… The problem with a DNS only approach is that you can't rely on when the DNS caches of your site's visitors update. With the routing approach you determine the time of the switch, minimizing potential downtimes.
            – Broco
            12 mins ago





            I had to explain it a bit broader since you didn't mention which type of server you're using to serve your sites. E.g. in iptables (Linux) you could use Prerouting and masquerading to redirect traffic to a new location, see here: debuntu.org/… The problem with a DNS only approach is that you can't rely on when the DNS caches of your site's visitors update. With the routing approach you determine the time of the switch, minimizing potential downtimes.
            – Broco
            12 mins ago











            bikey77 is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            bikey77 is a new contributor. Be nice, and check out our Code of Conduct.












            bikey77 is a new contributor. Be nice, and check out our Code of Conduct.











            bikey77 is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f932945%2fmoving-many-sites-to-new-server-whats-the-quickest-way-to-update-their-dns-rec%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery