导出Windows反向DNSlogging到绑定文件?

有没有办法将DNS反向查找条目从运行dnsmgmt的Windows Server 2003框导入反向区域文件,Unix文件可以被运行绑定的Unix服务器使用?

如果没有,是否有办法自动将反向DNS信息导出到文本文件中,这样我就可以在Perl中破解一些东西了?

您可以使用Windows支持工具中的DNSCMD实用程序使用/ ZoneExport参数导出区域。 导出有点古怪,因为它导出到托pipe区域的服务器上的%windir%\ system32 \ dns目录。

我不确定格式是完全BIND格式,但它是接近的。 你可以很容易地用脚本来完成这个任务。

为什么不在* nix框上设置辅助DNS区域,将2003服务器上的区域传输授权到该nix框,然后放松一下呢?

这里是我写的一个Perl脚本,用于将Windows的反向DNS区域文件转换为Unix上绑定可以使用的东西。 它为每个Windows dns文件和一个named.conf.windows文件(在Unix上放入你的named.conf文件)和一个named.slave.inc.windows文件(放入named.slave中)创build一个新的Unix区域文件。 inc或Unix上的named.slave.conf文件)。

#!/usr/bin/perl -w # Author: John Scipione @ Netsville (http://www.netsville.com) # This script converts reverse zone files found in # %SystemRoot%\System32\dns on a Windows server to ones that can # be used by Bind on a Unix server. use strict; my $primarydns = ''; # Hostname of your primary DNS server (w/o trailing .) my $primarydnsip = ''; # IP of your primary DNS server my $rootname = ''; # Domain Contact Root Name my $secondarydns = ''; # Hostname of your secondary DNS server (w/o trailing .) my $refresh = '3600'; my $retry = '600'; my $expire = '604800'; my $ttl = '3600'; # Minimum TTL my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); $year += 1900; # Perl uses years since 1900 by default $mon = sprintf("%02d", $mon + 1); # Perl uses month [0..11] by default $mday = sprintf("%02d", $mday); open(MASTER, '>', 'named.conf.windows'); # blank file out close(MASTER); open(SLAVE, '>', 'named.slave.inc.windows'); # blank file out close(SLAVE); my @files = <*>; foreach my $file (@files) { if (substr($file, -3) ne 'dns') { next; # skip if file does not end in .dns } my $outfilename = substr($file, 0, -3) . 'zone'; my @pieces = split(/\./, $file); my $third_octet = $pieces[0]; my $classB = $pieces[1] . '.' . $pieces[2]; my $classC = $pieces[0] . '.' . $pieces[1] . '.' . $pieces[2]; open(INFH, '<', $file); open(OUTFH, '>', $outfilename); print OUTFH "\$TTL $ttl\n"; print OUTFH "\$ORIGIN $classB.in-addr.arpa.\n"; print OUTFH "$third_octet\tIN\tSOA $primarydns. $rootname. (\n"; print OUTFH "\t\t\t\t\t\t" . $year . $mon . $mday . "00\t; serial number\n"; print OUTFH "\t\t\t\t\t\t$refresh\t\t; refresh\n"; print OUTFH "\t\t\t\t\t\t$retry\t\t\t; retry\n"; print OUTFH "\t\t\t\t\t\t$expire\t\t; expire\n"; print OUTFH "\t\t\t\t\t\t$ttl )\t\t; default ttl\n\n"; print OUTFH "\tIN\tNS\t$primarydns.\n"; print OUTFH "\tIN\tNS\t$secondarydns.\n\n"; print OUTFH "\$ORIGIN $classC.in-addr.arpa.\n"; while (<INFH>) { if (substr($_, 0, 1) eq ';') { next; # skip comment lines } $_ =~ s/\r//g; # trim off \r if ($_ =~ /(\d+)\s+PTR\s+(\S+\.\S+\.\S+\.)/) { print OUTFH "$1\tIN\tPTR\t$2\n"; } elsif ($_ =~ /\s+PTR\s+(\S+\.\S+\.\S+\.)/) { print OUTFH "\tIN\tPTR\t$1\n"; } } close(INFH); close(OUTFH); open(MASTER, '>>', "named.conf.windows"); print MASTER "zone \"$classC.in-addr.arpa\" {\n"; print MASTER " type master;\n"; print MASTER " file \"$classC.in-addr.arpa.zone\";\n"; print MASTER "};\n"; close(MASTER); open(SLAVE, '>>', "named.slave.inc.windows"); print SLAVE "zone \"$classC.in-addr.arpa\" {\n"; print SLAVE " type slave;\n"; print SLAVE " file \"$classC.in-addr.arpa.bak\";\n"; print SLAVE " masters { $primarydnsip; };\n"; print SLAVE "};\n"; close(SLAVE); }