用于解析区域文件的 UNIX 脚本(这是最好的代码吗?)

发布于 2024-08-31 14:20:22 字数 603 浏览 4 评论 0原文

发现以下内容: http://mike.murraynet.net/2009/08/23/parsing-the-verisign-zone-file-with-os-x/

unix-masters 可以看一下它,看看它是否是在区域文件中收集唯一域名的最佳方法?

对于 .NET 域: grep “^[a-zA-Z0-9-]+ NS .” net.zone|sed “s/NS .//”|uniq >>> netdomains.txt

对于 .COM 域: grep “^[a-zA-Z0-9-]+ NS .” com.zone|sed “s/NS .//”|uniq >>> comdomains.txt

对于 .EDU 域: grep “^[a-zA-Z0-9-]+ NS .” edu.zone|sed “s/NS .//”|uniq >>> edudomains.txt

FOund the following on: http://mike.murraynet.net/2009/08/23/parsing-the-verisign-zone-file-with-os-x/

Can unix-masters have a look at it and see if its the best possible way to gather the unique domainsnames in a zone file?

For .NET domains:
grep “^[a-zA-Z0-9-]+ NS .” net.zone|sed “s/NS .//”|uniq >> netdomains.txt

For .COM domains:
grep “^[a-zA-Z0-9-]+ NS .” com.zone|sed “s/NS .//”|uniq >> comdomains.txt

For .EDU domains:
grep “^[a-zA-Z0-9-]+ NS .” edu.zone|sed “s/NS .//”|uniq >> edudomains.txt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冬天旳寂寞 2024-09-07 14:20:22

就我个人而言,我会在进一步处理之前使用 named-checkzone 规范化区域文件的格式:

% named-checkzone -i none -s full -D com. com.zone | \
  perl -ane 'print $F[0]."\n" if $F[3] eq "NS"' | \
  uniq

无可否认,命令行更长,但它避免了对潜在脆弱的正则表达式匹配的需要。 named-checkconf 输出保证在第四个字段中包含资源记录类型 (NS),并在第一个字段中包含整个域名。

FWIW,named-checkzone 还会对区域文件输出进行排序,从而确保 uniq 正常工作。

Personally, I'd use named-checkzone to canonicalise the format of the zone file before further processing:

% named-checkzone -i none -s full -D com. com.zone | \
  perl -ane 'print $F[0]."\n" if $F[3] eq "NS"' | \
  uniq

The command line is admittedly longer, but it avoids the need for a potentially fragile regular expression match. The named-checkconf output is guaranteed to have the resource record type (NS) in the fourth field, and the whole domain name in the first field.

FWIW, named-checkzone also sorts the zone file output, which ensures that uniq works properly.

知足的幸福 2024-09-07 14:20:22

这是一个较旧的例子。我和我的对比了一下,格式还是一样的。

http://www.adspeed.org/2006/ 04/parsing-verisign-comnet-zone-files.html

;File start: 95720  
; The use of the Data contained in Verisign Inc.' aggregated  
; .com, and .net top-level domain zone files (including the checksum  
; files) is subject to the restrictions described in the access Agreement  
; with Verisign Inc.  

$ORIGIN EDU.  
@ IN    SOA     L3.NSTLD.COM. NSTLD.VERISIGN-GRS.COM. (  
                                  2006040800 ;serial  
                                  1800 ;refresh every 30 min  
                                  900 ;retry every 15 min      
                                  604800 ;expire after a week
                                  86400 ;minimum of a day
                                  )
$TTL 518400
 NS L3.NSTLD.COM.
 NS D3.NSTLD.COM.
 NS A3.NSTLD.COM.
 NS E3.NSTLD.COM.
 NS C3.NSTLD.COM.
 NS G3.NSTLD.COM.
 NS M3.NSTLD.COM.
 NS H3.NSTLD.COM.
L3.NSTLD.COM. A 192.41.162.32
D3.NSTLD.COM. A 192.31.80.32
A3.NSTLD.COM. A 192.5.6.32
E3.NSTLD.COM. A 192.12.94.32
C3.NSTLD.COM. A 192.26.92.32
G3.NSTLD.COM. A 192.42.93.32
M3.NSTLD.COM. A 192.55.83.32
H3.NSTLD.COM. A 192.54.112.32
$TTL 172800
22CF NS DNS1.NAME-SERVICES.COM.
22CF NS DNS2.NAME-SERVICES.COM.
22CF NS DNS3.NAME-SERVICES.COM.
TEST NS NS1.TEST
......

这是一个 new.zone 文件示例。我添加了底部的一个,这样您就可以看到当名称服务器也是 .net 时情况如何,它省略了它。

Here is an older example. I compared with mine and the format is still the same.

http://www.adspeed.org/2006/04/parsing-verisign-comnet-zone-files.html

;File start: 95720  
; The use of the Data contained in Verisign Inc.' aggregated  
; .com, and .net top-level domain zone files (including the checksum  
; files) is subject to the restrictions described in the access Agreement  
; with Verisign Inc.  

$ORIGIN EDU.  
@ IN    SOA     L3.NSTLD.COM. NSTLD.VERISIGN-GRS.COM. (  
                                  2006040800 ;serial  
                                  1800 ;refresh every 30 min  
                                  900 ;retry every 15 min      
                                  604800 ;expire after a week
                                  86400 ;minimum of a day
                                  )
$TTL 518400
 NS L3.NSTLD.COM.
 NS D3.NSTLD.COM.
 NS A3.NSTLD.COM.
 NS E3.NSTLD.COM.
 NS C3.NSTLD.COM.
 NS G3.NSTLD.COM.
 NS M3.NSTLD.COM.
 NS H3.NSTLD.COM.
L3.NSTLD.COM. A 192.41.162.32
D3.NSTLD.COM. A 192.31.80.32
A3.NSTLD.COM. A 192.5.6.32
E3.NSTLD.COM. A 192.12.94.32
C3.NSTLD.COM. A 192.26.92.32
G3.NSTLD.COM. A 192.42.93.32
M3.NSTLD.COM. A 192.55.83.32
H3.NSTLD.COM. A 192.54.112.32
$TTL 172800
22CF NS DNS1.NAME-SERVICES.COM.
22CF NS DNS2.NAME-SERVICES.COM.
22CF NS DNS3.NAME-SERVICES.COM.
TEST NS NS1.TEST
......

this is a new.zone file example. I added the bottom one so you can see how it is when nameserver is also .net, it leaves it out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文