Can I change the zone file from command line?

Mark Andrews marka at isc.org
Tue Jul 23 06:16:41 UTC 2013


In message <CAN3um4yrT+t7Cp2EZYWq-rM5eWx3-ygOK9VKxVUG4qbxcbpzcA at mail.gmail.com>
, Mike Hale writes:
> This seems pretty straight forward.
> 
> Use your standard bash tools to modify the file when necessary, then
> you should simply be able to call rndc reload ZONENAME in the script.

Though why one would want to do this rather than just updating the
zone using DDNS is beyond me.   It's not like DDNS can't be made
secure by using TSIG.

Normalize the zone file using named-checkzone.
Use awk or similar to change the relevent entries and update the SOA serial.
Use named-checkzone to confirm that the resulting file is still valid then
if it is rename it and reload the zone.

named-checkzone -D -q zone file |
awk '$1 == "server" && $4 == "A" { print $1, $2, $3, $4, NEWIP}
$4 == "SOA" { $7 = $7 + 1; print }' > temp
named-checkzone -q zone temp && mv temp file && rndc reload zone

Mark
 
> On Mon, Jul 22, 2013 at 10:28 PM, Mihamina Rakotomandimby
> <mihamina at rktmb.org> wrote:
> > Hello,
> >
> > I did not catch what you're trying to achieve.
> > Please give more details.
> >
> >
> > On 2013-07-23 08:25, Manish Rane wrote:
> >
> > Hi Folks,
> >
> > Wondering if I can edit/change the static zone file as a result of certain
> > bash script. Well, I am trying to write a script which will monitor the
> > server on certain ports and it if fails to connect to the server it will
> > delete or add the entry from zone file so that traffic will be routed to
> > another server, possible?
> >
> > OR does any one aware of such solution available in open source?
> >
> >
> >
> > _______________________________________________
> > Please visit https://lists.isc.org/mailman/listinfo/bind-users to
> > unsubscribe from this list
> >
> > bind-users mailing list
> > bind-users at lists.isc.org
> > https://lists.isc.org/mailman/listinfo/bind-users
> >
> >
> >
> > --
> > RMA.
> >
> >
> > _______________________________________________
> > Please visit https://lists.isc.org/mailman/listinfo/bind-users to
> > unsubscribe from this list
> >
> > bind-users mailing list
> > bind-users at lists.isc.org
> > https://lists.isc.org/mailman/listinfo/bind-users
> 
> 
> 
> -- 
> 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
> _______________________________________________
> Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe
>  from this list
> 
> bind-users mailing list
> bind-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users
-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: marka at isc.org


More information about the bind-users mailing list