Home > php教程 > PHP开发 > nali is a small tool that displays IP sources under Linux

nali is a small tool that displays IP sources under Linux

高洛峰
Release: 2016-12-15 14:45:21
Original
1595 people have browsed it

nali, the name is taken from the Chinese pinyin of "where".
nali contains a set of command line programs. Its main function is to append the IP strings output by some http://www.aliyun.com/zixun/aggregation/10849.html"> network tools with geographical location information ( Using pure database).
For example, 218.65.137.1 will become 218.65.137.1 [Guangxi Nanning Telecom].
The query is performed locally and will not be performed online, so there will be no impact on efficiency.
It currently includes the following. Several commands:

nalinali-dignali-nslookupnali-traceroutenali-tracepathnali-ping

The prerequisite for using these commands is that their corresponding commands must exist. For example, if you want to use nali-dig, you must ensure that their dig exists. The usage is the same as the original command. For example, nali-dig is used the same as dig.
You may have noticed that the nali command can append geographic information to the standard output IP string. The nali-* series of tools are based on this. To achieve.

Download

wget http://qqwry.googlecode.com/files/nali-0.1.tar.gz

Install

./configure --prefix=/usr && make && make install

Use

1 to count apache’s access records

(you can count which IP has the most visits and see where it comes from):
Command:

cat /data/log/log_all | awk '{print $1}' | sort | uniq -c | nali | sort -rnk1 | more

Output results:

2303 203.208.60.43[Beijing Google (China) Company] 1442 61.135.249.210[Beijing Unicom ADSL] 827 124.207.205.1[Beijing Municipal Telecom] 607 121.14.53.65 [Jiangmen Telecom, Guangdong Province] 493 117.63.249.59 [Changzhou Telecom, Jiangsu Province] 289 203.208.60.5 [Beijing Google (China) Company] 272 203.208.60.47 [Beijing Google (China) Company] 252 173.66.232.6[North America] 240 61.185.198.110[Shaanxi Province Xi’an Telecom ADSL] 217 123.127.8.36[Beijing China Unicom ADSL] 217 113.233.255.7[Liaoning Province China Unicom] 206 222.76.18.1 81[Fuzhou City, Fujian Province Telecom ADSL] 196 72.30.81.190 [US yahoo spider]

2. Use traceroute

command:

nali-traceroute www.google.com

Output result:

traceroute to www.google.com (72.14.203.147 [Google Inc., Mountain View, California, USA]), 30 hops max, 40 byte packets
1 61.189.23.129[China Unicom Liaoning Province] (61.189.23.129[China Unicom Liaoning Province]) 16.628 ms 16.796 ms 16.891 ms
2 218.25.16. 153 [China Unicom of Tiexi District/Huanggu District, Shenyang City, Liaoning Province] (218.25.16.153 [Unicom of Tiexi District/Huanggu District, Shenyang City, Liaoning Province]) 0.658 ms 0.691 ms 0.685 ms
3 218.61.253.201[Huludao City, Liaoning Province] China Unicom] (218.61.253.201 [China Unicom, Huludao City, Liaoning Province]) 7.976 ms 8.008 ms 8.001 ms
4 218.61.255.185 [China Unicom Liaoning Province Backbone Network] (218.61.255.185 [China Unicom Liaoning Province Backbone Network]) 20.614 ms 20.643 ms 20.636 ms
5 219.158.9.57[Beijing China Unicom ADSL] (219.158.9.57[Beijing China Unicom ADSL]) 29.274 ms 29.272 ms 29.264 ms
6 219.158.3.194[Beijing China Unicom ADSL] (219.158.3.194 [Beijing China Unicom ADSL] ) 44.582 ms 44.464 ms 44.489 ms
7 219.158.27.118[Beijing China Unicom ADSL] (219.158.27.118[Beijing China Unicom ADSL]) 82.249 ms 82.690 ms 82.648 ms
8 20 9.85.249.195 [Google Inc., Mountain View, California, USA] 66.336 ms .249.195[Google Inc., Mountain View, CA, U.S.A.] (209.85.249.195[Google Inc., Mountain View, CA, U.S.A.]) 68.010 ms
9 209.85.250.90[Google Inc., Mountain View, CA, U.S.A.] (209.85.250.90[U.S.A. Google Inc., Mountain View, California]) 97.320 ms
209.85.250.86 [Google Inc., Mountain View, California, United States] (209.85.250.86 [Google Inc., Mountain View, California, United States]) 112.428 ms
209.85.250.90 [Google Inc., Mountain View, California, United States] Google, Mountain View, California] (209.85.250.90 [Google, Mountain View, California, United States]) 99.948 ms
10 209.85.243.21 [Google, Mountain View, California, United States] (209.85.243.21 [Google, Mountain View, California, United States] Company]) 96.939 ms
209.85.250.103[Google Inc., Mountain View, California, United States] (209.85.250.103[Google Inc., Mountain View, California, United States]) 97.206 ms
209.85.243.21[Google Inc. Mountain View, California, United States] (209.85.243.21 [Google Inc., Mountain View, CA, USA]) 96.935 ms
11 209.85.241.158 [Google Inc., Mountain View, CA, USA] (209.85.241.158 [Google Inc., Mountain View, CA, USA]) 120.577 ms 120.588 ms 120.543 ms
12 tx-in-f147.google.com (72.14.203.147[Google Inc., Mountain View, California, USA]) 117.533 ms 117.623 ms 117.651 ms

In other words, the nali command can append geographic information to the standard output IP address. In the same way, if you don't like to use nali-dig, you can also use commands like dig ip|nali.
If you find it troublesome to enter nali-xxx, you can do some alias, for example:

alias traceroute='nali-traceroute'alias dig='nali-dig'


More nali shows IP under linux For source related articles about gadgets, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template