Script to delete zone from named.conf
James O'Gorman
james at netinertia.co.uk
Thu Feb 4 20:01:48 UTC 2010
On 4 Feb 2010, at 17:12, bsd wrote:
> Hello,
>
> I am looking for a script to delete a zone from named.conf and maybe also from server (zone file).
>
> My zone file looks like that (but could have some variations). Everything inside brackets should be deleted… and eventually the host file.
Assuming all zone statements are identically formatted (as per your examples), then the following will work:
sed -e '/^zone "bar.com" {$/,/^};$/ d' -i .bak named.conf
That looks for a line that is exactly "zone "..." {" and another that is exactly "};" - and then deletes those lines and everything in between.
If you want to create a script to do this, you could do:
#!/bin/sh
zone=$1
sed -e "/^zone \"$zone\" {/,/^};$/ d" -i .bak named.conf
rm $zone
James
More information about the bind-users
mailing list