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.

How to remove a few DNS records from all zone files?

Discussion in 'Bind / DNS / Nameserver Issues' started by postcd, Apr 27, 2014.

  1. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    624
    Likes Received:
    6
    Trophy Points:
    18
    Hello,

    WHM stupidly without asking me added all Default nameservers into zone files of accounts i transfered to my server.

    The aim is now fix the mess WHM did.

    Removing whole entry lines

    nsx1.hosting.com X X X IP
    nsx2.hosting.com X X X IP

    there is more than 100 zone files to edit. so i ask how i can remove these two whole lines automatically via linux command line from all zone files.
     
  2. cPanelPeter

    cPanelPeter Technical Analyst III
    Staff Member

    Joined:
    Sep 23, 2013
    Messages:
    569
    Likes Received:
    15
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You could use the replace command. First if you haven't already done so, make a backup of the /var/named directory

    Code:
    cp -rfpd /var/named /var/named.bak
    
    Then you would use the replace command something like this:

    Code:
    replace 'nsx1.hosting.com X X X IP' '' -- *
    replace 'nsx2.hosting.com X X X IP' '' -- *
    
    That should do the trick. If anything goes wrong, you still have the backup.
     
Loading...

Share This Page