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.

mass change on all dns zones.

Discussion in 'Bind / DNS / Nameserver Issues' started by IRCBrasil, Jul 11, 2006.

  1. IRCBrasil

    IRCBrasil Well-Known Member

    Joined:
    Jul 22, 2004
    Messages:
    93
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    I have this situation: I need a mass change on all dns zones. All lines equal this:

    domain.com. 3600 IN TXT "v=spf1 a mx ptr ip4:11.22.33.44 a:ns1.domain.com a:ns2.domain.com -all"

    need be changed to:

    domain.com. 3600 IN TXT "v=spf1 a mx ptr ip4:55.66.77.88 a:ns1.domain.com a:ns2.domain.com -all"

    Some sugestion?

    Since now, tanks for any help.
     
  2. freedog96150

    freedog96150 Well-Known Member

    Joined:
    Mar 25, 2005
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Nevada, USA
    A very quick and crude way to make bulk changes in RH based systems is to use the replace command. You can find help for the replace command by typing
    Code:
    replace -v
    at the prompt. Here is a sample command to change your files in one swoop. Keep in mind that this command is indiscriminate, so it will replace ALL instances of the match with the replacement.
    Code:
    [root@mybox ~]# replace ip4:11.22.33.44 ip4:55.66.77.88 -- /dir/with/files/*
    If your distro does not have replace, then use my personal favorite utility - sed. This is not as hard are most people think and is very powerful (well beyond my simple example below). There is plenty of help on the web at your fingertips with a simple google search. So now to the nitty-gritty:

    Code:
    [root@mybox ~]# sed -e 's/ip4:11.22.33.44/ip4:55.66.77.88/g' /dir/with/files/*
    Simply put this scripts tell sed to '(s)ubstitute/this string/with this string/(g)lobally' in these files

    Hope this helps. Be careful and remember that it is always a good idea to make a copy of the files to a new directory and experiment on the copy first. Once the desired results are achieved, then replace your working copies.
     
  3. IRCBrasil

    IRCBrasil Well-Known Member

    Joined:
    Jul 22, 2004
    Messages:
    93
    Likes Received:
    0
    Trophy Points:
    6
    Its work!!

    Thanks a lot freedog :)
     
  4. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    When updating zone files, the serial number should be updated as well.
     
  5. IRCBrasil

    IRCBrasil Well-Known Member

    Joined:
    Jul 22, 2004
    Messages:
    93
    Likes Received:
    0
    Trophy Points:
    6
  6. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    My servers don't have the 2nd one, but if they both contain zone files, it's probably best to update both.
     
Loading...

Share This Page