On Wed, Apr 1, 2015 at 8:09 PM, Barry Margolin <bar...@alum.mit.edu> wrote: > In article <mailman.1867.1427927445.26362.bind-us...@lists.isc.org>, > Jeff Sadowski <jeff.sadow...@gmail.com> wrote: > >> I have a number of slave domains that I would like a naming scheme and >> not have to go to each and change the filename. >> >> I have the following zones >> >> zone "1.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "2.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "3.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "4.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "5.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "6.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "7.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "8.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "9.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> zone "10.168.192.in-addr.arpa" { >> include "named.slave"; >> }; >> >> named.slave looks as follows >> >> type slave; >> masters {192.168.1.2;}; >> file "data/db.@.slave"; >> >> It appears to work on my queries. >> >> nslookup 192.168.1.2 >> >> 2.1.168.192.in-addr.arpa name = pdc.<domain> >> >> nslookup 192.168.1.1 >> >> 1.1.168.192.in-addr.arpa name = gw1.<domain> >> >> nslookup 192.168.2.1 >> >> 1.2.168.192.in-addr.arpa name = gw2.<domain> >> >> the only file created in my data directory seems to be db.@.slave >> with the at sign. > > Why would you expect anything different? @ only has special meaning > inside zone files, it's not special in named.conf. > >> >> Do I really need to have each zone with its own file? > > Yes, you do. What's happening is that every time one of the reverse > zones is transferred, it's overwriting that file. But the files are only > used when initializing the zones when named starts up; you get the > correct answers because the in-memory versions of the zones are > distinct. But try restarting named and then see what happens when you do > those nslookups. You'll see that 192.168.1.1 and 192.168.2.1 both return > the same name. > >> >> Is there a special syntax to get what I expect? >> expected files: >> data/db.1.168.192.in-addr.arpa.slave >> data/db.2.168.192.in-addr.arpa.slave >> data/db.3.168.192.in-addr.arpa.slave >> ... >> data/db.10.168.192.in-addr.arpa.slave >> >> if not I can have Make do it and build some scripts to do what I want >> but if there is syntax to do what I want it would be nice. > > No, there's no built-in syntax to create the filename based on the zone > name. > I wrote a php script to build my file for me
<?php $myslave=array('type'=>'slave' ,'masters'=>array('192.168.1.2') ,'autofile'=>'data/db.@.slave'); $arpa192='.168.192.in-addr.arpa'; $domain='<domain>'; $zone['_msdcs.'.$domain]=$myslave; $zone[$domain]=$myslave; $slavedsubnets=range('1','10'); build_subnets($slavedsubnets ,$arpa192 ,$myslave); build_zones(); function build_subnets($subnets ,$net ,$info) {global $zone; foreach($subnets as $subnet) {$zone[$subnet.$net]=$info; }} function build_zones() {global $zone,$argv; $pounds=str_repeat('#',30); $warning=$pounds.' WARNING '.$pounds."\n"; echo $warning. '# Do not edit this file. '. 'It was generated using "php '. $argv[0]."\"\n".$warning; foreach($zone as $z=>$infos) {echo 'zone "'.$z.'" {'."\n"; foreach($infos as $item=>$value) {echo "\t".$item.' '; if(is_array($value)) {echo '{'; foreach($value as $v){echo $v.';';} echo '}'; } else {switch($item) {case 'file': echo '"'.$value.'"'; break; case 'autofile': echo '"'. str_replace('@',$z,$value).'"'; break; default: echo $value; break; }} echo ";\n"; } echo "};\n"; }} ?> > -- > Barry Margolin > Arlington, MA > _______________________________________________ > Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe > from this list > > bind-users mailing list > bind-users@lists.isc.org > https://lists.isc.org/mailman/listinfo/bind-users _______________________________________________ Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list bind-users mailing list bind-users@lists.isc.org https://lists.isc.org/mailman/listinfo/bind-users