Perl uses dig and Nali to determine if DNS resolution address attribution is consistent script sharing _perl

Source: Internet
Author: User
Tags svn

Here first introduces the next Nali this open source applet, project address:

Here's a description of the website from the project's owner:

Copy Code code as follows:


nali-0.2.tar.gz–2011-09-11 Release (download link one, download link II)
NALI-0.1.TAR.GZ–2009-08-16 Release


Nali, the name is taken from the Chinese "where" pinyin. Nali contains a set of command-line programs whose primary function is to attach the IP strings of the output of some network tools to the location information (using the Pure database QQWry.Dat). For example, will become[Guangxi Nanning Telecom]. The query is local and does not make network queries, so the efficiency aspect does not affect the original command.

The following commands are currently included:

The premise of using these commands is that their corresponding commands must exist. For example, if you want to use Nali-dig, you must ensure that dig exists. Their usage is the same as the original command. For example Nali-dig, the usage is the same as dig. (Nali-dig equivalent to dig |nali)

You may have noticed the Nali command, which allows you to attach geographic information to the IP string of the standard output. The nali-* series of tools are implemented based on this.

If you think the input nali-xxx trouble, then you can do some alias, for example
surfchen@mac:~$ alias traceroute= ' Nali-traceroute '
surfchen@mac:~$ alias dig= ' Nali-dig '

If you are using a network tool that is not included in the Nali package, you can do this:
surfchen@mac:~$ My_network_tool|nali
Server[China Telecom CDMA]
In other words, Nali This command, you can attach geographic information to the standard output IP. Similarly, if you don't like to use Nali-dig, you can also use dig Ip|nali such commands.

Of course, you can also query IP address information directly with Nali:
surfchen@mac:~$ Nali[Guangxi Nanning Telecom]


[sudo] make install

Update IP Database

Use the nali-update command to update the IP database


SVN Co Http://
Note that SVN does not contain QQWry.Dat, and if you need to compile from SVN version, download the QQWry.Dat yourself and put it in the share directory of your project.
Bug Submission:


Here are 3 examples.
chenze@osx:~$ Nali-traceroute
Traceroute to ([Taiwan large broadband), hops max, byte packets
1[LAN each other and you in the same intranet] ([LAN each other and you in the same intranet]) 0.747 Ms 0.353 ms 0.278 ms
2[China Telecom CDMA] ([China Telecom CDMA]) 435.595 Ms 65.757 ms 48.906 ms
3[China Telecom CDMA] ([China Telecom CDMA]) 70.990 Ms 66.751 ms 46.936 ms
4[China Telecom CDMA] ([China Telecom CDMA]) 192.944 Ms 72.679 ms 46.958 ms
5[Guangxi Nanning Telecom] ([Guangxi Nanning Telecom) 66.963 Ms 54.412 ms 54.943 ms
6[Guangxi Nanning Telecom] ([Guangxi Nanning Telecom) 102.969 Ms 73.220 ms 47.016 ms
7[Guangxi Telecom Backbone Network] ([Guangxi Telecom Backbone)) 432.915 Ms 161.390 ms 165.018 ms
8 *[China Telecom Backbone Network] ([China Telecom Backbone)) 185.598 Ms 161.236 ms
9[Shanghai Telecom Backbone Network International export] ([Shanghai Telecom Backbone Network International export)) 79.857 Ms 66.537 ms

工欲善其事, its prerequisite, the sharp weapon has, below say our demand. There are a number of domain names, 31 DNS addresses, now to round these domain names in the 31 DNS resolution results are not the same, the same input to another file; Here is the script:

Copy Code code as follows:

Use strict;

Open DNS, "dns_ip.txt" or Die "I can ' t filnd the file1!\n";;
Open URL, "url_jiangsu.txt" or Die "I can ' t filnd the file!\n";;
Open NUM, ">>numbers.txt";
Open URLS, ">>url_in_jiangsu.txt";
while (my $url =<url>) {
Chomp $url;
My $num _1=0;
my $all = 0;
$num _1= '/usr/bin/dig \@ $url +tries=1 +time=3 +short|grep-v ' [a-z].* ' |head-1|nali|grep-q ' Jiangsu. * mobile ' && Amp echo 1| | echo 0′; #注意这里第一和最后一个单引号是其实是tab键上面那个
while (my $dns =<dns>) {
Chomp $dns;
My $num = '/usr/bin/dig \@ $dns $url +tries=1 +time=3 +short|grep-v ' [a-z].* ' |head-1|nali|grep-q ' move ' && echo 1| | echo 0′; #注意这里第一和最后一个单引号是其实是tab键上面那个
$all + + $num;
if ($all = = $num _1==1) {
Print URLS $url. " \ n ";
Print NUM $url. " ". $all." \ n ";
Seek (DNS, 1, 0);

Close DNS;
Close URL;
Close URLS;
Close NUM;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.