The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anyone know how tochange all the dns to point to a new server at once.

Discussion in 'Bind / DNS / Nameserver Issues' started by DWHS.net, Sep 12, 2003.

  1. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Manually editing 100's of dns zones does not sound fun.

    Is there a clever way that will do all of them at once.

    Thanks,

    cPanel.net Support Ticket Number:
     
  2. matthewdavis

    matthewdavis Well-Known Member

    Joined:
    Jun 26, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    NC, USA
    Well, if its a set text that you are changing. You can easily do a a mass search & replace with a perl expression.

    # perl -pi -e 's,OLDTEXT,NEWTEXT,' *

    That will search thru all files in teh current directory (*) and replace OLDTEXT with NEWTEXT. Maybe that'll help.

    cPanel.net Support Ticket Number:
     
  3. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Thanks but I do not know ho to set up perl files.

    Can you show me what the whole perl file would be, what to name it and how does the file know where the named.conf is?

    :)

    cPanel.net Support Ticket Number:
     
  4. matthewdavis

    matthewdavis Well-Known Member

    Joined:
    Jun 26, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    NC, USA
    That is a command you can run from a shell. If you cannot login to your account using SSH (or putty), then you cannot use this command.

    But if you goto the directory of the file you want to modify, and just type that command

    # perl -pi -e 's,OLD,NEW,' named.conf

    That command will search named.conf for everything 'OLD' and change it to 'NEW'.

    cPanel.net Support Ticket Number:
     
  5. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Thanks, I have never ran a perl command from the command line yet.

    :D

    cPanel.net Support Ticket Number:
     
  6. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    DWHS,

    If that works, could you let me know? I have to do that next week...:)

    It would actually be run from /var/named , right?
    # perl -pi -e 's,OLDIP,NEWIP,' *

    cPanel.net Support Ticket Number:
     
    #6 casey, Sep 13, 2003
    Last edited: Sep 14, 2003
  7. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    O.K. I am going to try it tonight.

    cPanel.net Support Ticket Number:
     
  8. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    Did everything go smoothly?

    And is this what you ran from /var/named ?
    # perl -pi -e 's,OLDIP,NEWIP,' *

    cPanel.net Support Ticket Number:
     
  9. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Actually I have a linguring account that needs more time before I can do it.

    Talk to soon about it.

    cPanel.net Support Ticket Number:
     
  10. rsaylor

    rsaylor Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    160
    Likes Received:
    1
    Trophy Points:
    18
    Hi, the perl -pi command will work but not sure about the *

    I did that not too long ago but did it in stages. IE: replaced the * with the zone name.

    Then after you run the perl -pi command restart named and you will be all good.

    cPanel.net Support Ticket Number:
     
  11. matthewdavis

    matthewdavis Well-Known Member

    Joined:
    Jun 26, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    NC, USA
    The * just means it'll search all files in the current directory.

    cPanel.net Support Ticket Number:
     
  12. Stefaans

    Stefaans Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    451
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Vancouver, Canada
    Nearly there . . .

    Nice solution to search and replace text. But shouldn't one increment each zone serial number as well?

    cPanel.net Support Ticket Number:
     
  13. matthewdavis

    matthewdavis Well-Known Member

    Joined:
    Jun 26, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    NC, USA
    I'm no BIND/dns guru, so I'm not sure, sorry.

    cPanel.net Support Ticket Number:
     
  14. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    Well, the time came for mine to be changed, so I did it, and without a hitch. 6 hours before the move, I updated the ttl by doing
    cd /var/named
    perl -pi -e 's,86400,3600,' *

    Then, 6 hours later I moved all the accounts, then ran
    chmod 755 /home/*/public_html
    because the permissions were wrong.

    Then I changed the IPs by doing
    perl -pi -e 's,OLDIP,NEWIP,' *

    Unfortunately, due to my lack of programming abilities, I had to go through the zones one by one after that and increment the serial number by one.

    Worked nicely. Changes were instantaneous if I had not visited the site recently. If I had, it took about 30 minutes for the change to take effect.

    cPanel.net Support Ticket Number:
     
  15. matthewdavis

    matthewdavis Well-Known Member

    Joined:
    Jun 26, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    NC, USA
    Good to hear! And I'm sure there's some script or perl expression you could have run to increment that number. I'm no perl guru either. But perl gurus swear you can do anything with perl. Probably could write the next space shuttle with 3 lines of perl code. 1 for lift off, 1 for travel, and 1 for the return trip.

    cPanel.net Support Ticket Number:
     
  16. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    :)

    cPanel.net Support Ticket Number:
     
  17. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Good news,

    I ended up changing each manualy in the WHM, the serial thing made me a little weary.

    Hopefully there will be a solid methid that will update all domains to a new i.p. and the dns zones.

    Thanks for the update Casy...

    cPanel.net Support Ticket Number:
     
  18. silversurfer

    silversurfer Well-Known Member

    Joined:
    Dec 29, 2002
    Messages:
    274
    Likes Received:
    0
    Trophy Points:
    18
    Hi Casey/ DWHS

    So would you have to change the SOA after the move? i.e. after the move, and after changing the ips in the dns zones to point at the new server, do you have to update the SOA?

    So in effect, having to update the SOA twice. Once after changing the TTL and once after changing the IP. Thanks.
     
  19. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    Well, I actually left mine after the move, because the ttl was already correct on the new server. Won't hurt anything, though. There is a script on these forums now to update the serial number by 1.
     
  20. silversurfer

    silversurfer Well-Known Member

    Joined:
    Dec 29, 2002
    Messages:
    274
    Likes Received:
    0
    Trophy Points:
    18
    Hi

    Do you have the script? Thanks.
     
Loading...

Share This Page