关于网络的总结-命令篇2

/ Network / 没有评论 / 49浏览

nslookup

在线查询

http://tool.chinaz.com/nslookup/

http://tools.bugscaner.com/nslookup/

默认解析对应配置文件是 /etc/resolv.conf

查询记录

直接查询返回的是A记录,我们可以指定参数,查询其他记录,比如AAAA、MX等。

nslookup -qt=type domain [dns-server]

其中,type可以是以下这些类型:

TXT记录

$ nslookup -qt=TXT lijinghua.club
Server:		114.114.114.114
Address:	114.114.114.114#53

Non-authoritative answer:
*** Can't find lijinghua.club: No answer

Authoritative answers can be found from:
lijinghua.club
	origin = dns31.hichina.com
	mail addr = hostmaster.hichina.com
	serial = 2017073015
	refresh = 3600
	retry = 1200
	expire = 3600
	minimum = 360

A记录

$ nslookup -qt=A lijinghua.club
Server:		114.114.114.114
Address:	114.114.114.114#53

Non-authoritative answer:
Name:	lijinghua.club
Address: 59.110.172.131

交互式

type 可以是上面的任意类型

root@ali:~# nslookup
> set type=mx
> lijinghua.club
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
lijinghua.club	mail exchanger = 5 mxn.mxhichina.com.
lijinghua.club	mail exchanger = 10 mxw.mxhichina.com.
lijinghua.club	mail exchanger = 10 mx.ym.163.com.

Authoritative answers can be found from:
> set type=ns
> baidu.com
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
baidu.com	nameserver = dns.baidu.com.
baidu.com	nameserver = ns2.baidu.com.
baidu.com	nameserver = ns7.baidu.com.
baidu.com	nameserver = ns4.baidu.com.
baidu.com	nameserver = ns3.baidu.com.

Authoritative answers can be found from:
>

mtr

Mtr是 Linux中有一个非常棒的网络连通性判断工具,它结合了ping, traceroute,nslookup 的相关特性。

网络诊断工具包括pingtraceroutemtr,它们使用Internet控制消息协议(ICMP)数据包来测试Internet上两点之间的连接和传输。当用户在Internet上ping主机时,会向主机发送一系列ICMP数据包,主机通过发送数据包作为响应。然后,用户的客户端能够计算因特网上两点之间的往返时间。

相反,诸如traceroute和MTR之类的工具发送ICMP数据包的TTL递增,可以查看数据包在源和目的地之间产生的一系列跳。TTL即生存时间,控制着数据包在“死亡”并返回主机之前将进行多少跳。通过发送一系列数据包并使它们在一跳、两跳、三跳之后返回,MTR能够分析英特网上不同主机之间流量的通路。

MTR不是只提供Internet的路由间的简单概述,而是收集有关中间主机的状态,连接和响应性的其他信息。由于这些附加信息,MTR可以提供Internet上两台主机之间连接的完整描述。以下部分概述了如何安装MTR软件以及如何解释此工具提供的结果。

Host:显示的是IP地址和本机域名,这点和traceroute很像
loss:显示每跳的丢包百分比
snt:10 设置每秒发送数据包的数量,默认值是10 可以通过参数 -c来指定。其中-c的说明是:–report-cycles COUNT
Snt:是显示的每个对应IP的丢包率
last:显示的最近一次的返回时延
Avg:是平均值 这个应该是发送ping包的平均时延
Best:是最好或者说时延最短的
Wrst:是最差或者说时延最常的
StDev:是标准偏差

? 超时可能由于各种原因而发生。有些路由器将丢弃ICMP,缺少的回复将在输出中显示为超时(???)。或者,返回路线可能存在问题

dig

Dig是一个在类Unix命令行模式下查询DNS包括NS记录,A记录,MX记录等相关信息的工具。由于一直缺失 Dig man page文档,本文就权当一个dig使用向导吧。 Dig的源码是ISC BIND大包的一部分,但是大多编译和安装Bind的文档都不把它包括在内,但是在linux系 统下,它通常是某个包的一部分

在Gentoo下是bind-tools,在Redhat/Fedora下是 bind-utils,或者在Debian下是 dnsutils。

基础使用

阿里云 ubuntu

阿里云 机器 ubuntu 16.04 使用的阿里云的DNS 127.0.0.5

以上信息在输出中都有

root@ali:~# dig lijinghua.club

; <<>> DiG 9.11.3-1ubuntu1.8-Ubuntu <<>> lijinghua.club
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2287
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;lijinghua.club.			IN	A

;; ANSWER SECTION:
lijinghua.club.		600	IN	A	59.110.172.131

;; Query time: 30 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Wed Oct 02 18:46:56 CST 2019
;; MSG SIZE  rcvd: 59

虚拟机 centos 7.5

虚拟机器 centos 7.5 解析地址是 8.8.8.8 能看到13个根服务器的ipv4地址和ipv6地址

[root@k8s-master tmp]# dig lijinghua.club

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> lijinghua.club
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23770
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 27

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;lijinghua.club.			IN	A

;; ANSWER SECTION:
lijinghua.club.		497	IN	A	59.110.172.131

;; AUTHORITY SECTION:
.			1405	IN	NS	b.root-servers.net.
.			1405	IN	NS	k.root-servers.net.
.			1405	IN	NS	h.root-servers.net.
.			1405	IN	NS	f.root-servers.net.
.			1405	IN	NS	d.root-servers.net.
.			1405	IN	NS	j.root-servers.net.
.			1405	IN	NS	i.root-servers.net.
.			1405	IN	NS	g.root-servers.net.
.			1405	IN	NS	m.root-servers.net.
.			1405	IN	NS	l.root-servers.net.
.			1405	IN	NS	c.root-servers.net.
.			1405	IN	NS	a.root-servers.net.
.			1405	IN	NS	e.root-servers.net.

;; ADDITIONAL SECTION:
a.ROOT-SERVERS.net.	3714	IN	A	198.41.0.4
b.ROOT-SERVERS.net.	437299	IN	A	199.9.14.201
c.ROOT-SERVERS.net.	78008	IN	A	192.33.4.12
d.ROOT-SERVERS.net.	179971	IN	A	199.7.91.13
e.ROOT-SERVERS.net.	594945	IN	A	192.203.230.10
f.ROOT-SERVERS.net.	218722	IN	A	192.5.5.241
g.ROOT-SERVERS.net.	283815	IN	A	192.112.36.4
h.ROOT-SERVERS.net.	580807	IN	A	198.97.190.53
i.ROOT-SERVERS.net.	159094	IN	A	192.36.148.17
j.ROOT-SERVERS.net.	34691	IN	A	192.58.128.30
k.ROOT-SERVERS.net.	278297	IN	A	193.0.14.129
l.ROOT-SERVERS.net.	451072	IN	A	199.7.83.42
m.ROOT-SERVERS.net.	552766	IN	A	202.12.27.33
a.ROOT-SERVERS.net.	72798	IN	AAAA	2001:503:ba3e::2:30
b.ROOT-SERVERS.net.	164152	IN	AAAA	2001:500:200::b
c.ROOT-SERVERS.net.	140973	IN	AAAA	2001:500:2::c
d.ROOT-SERVERS.net.	144133	IN	AAAA	2001:500:2d::d
e.ROOT-SERVERS.net.	492214	IN	AAAA	2001:500:a8::e
f.ROOT-SERVERS.net.	354	IN	AAAA	2001:500:2f::f
g.ROOT-SERVERS.net.	272724	IN	AAAA	2001:500:12::d0d
h.ROOT-SERVERS.net.	195314	IN	AAAA	2001:500:1::53
i.ROOT-SERVERS.net.	163301	IN	AAAA	2001:7fe::53
j.ROOT-SERVERS.net.	19872	IN	AAAA	2001:503:c27::2:30
k.ROOT-SERVERS.net.	173463	IN	AAAA	2001:7fd::1
l.ROOT-SERVERS.net.	267848	IN	AAAA	2001:500:9f::42
m.ROOT-SERVERS.net.	328847	IN	AAAA	2001:dc3::35

;; Query time: 7 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Wed Oct 02 18:34:45 CST 2019
;; MSG SIZE  rcvd: 881

A记录

[root@k8s-master tmp]# dig lijinghua.club  A +noall +answer

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> lijinghua.club A +noall +answer
;; global options: +cmd
lijinghua.club.		600	IN	A	59.110.172.131
[root@k8s-master tmp]# dig yahoo.com A +noall +answer

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> yahoo.com A +noall +answer
;; global options: +cmd
yahoo.com.		600	IN	A	72.30.35.9
yahoo.com.		600	IN	A	72.30.35.10
yahoo.com.		600	IN	A	98.137.246.8
yahoo.com.		600	IN	A	98.138.219.231
yahoo.com.		600	IN	A	98.137.246.7
yahoo.com.		600	IN	A	98.138.219.232
[root@k8s-master tmp]# dig baidu.com A +noall +answer

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> baidu.com A +noall +answer
;; global options: +cmd
baidu.com.		600	IN	A	220.181.38.148
baidu.com.		600	IN	A	39.156.69.79

MX记录

[root@k8s-master tmp]# dig lijinghua.club MX +noall +answer

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> lijinghua.club MX +noall +answer
;; global options: +cmd
lijinghua.club.		600	IN	MX	5 mxn.mxhichina.com.
lijinghua.club.		600	IN	MX	10 mx.ym.163.com.
lijinghua.club.		600	IN	MX	10 mxw.mxhichina.com.

权威NS

我的域名解析在阿里云

[root@k8s-master tmp]# dig lijinghua.club NS +noall +answer

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> lijinghua.club NS +noall +answer
;; global options: +cmd
lijinghua.club.		3140	IN	NS	dns32.hichina.com.
lijinghua.club.		3140	IN	NS	dns31.hichina.com.

查找所有记录

四个A的记录是ipv6的地址

[root@k8s-master tmp]# dig yahoo.com ANY +noall +answer

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> yahoo.com ANY +noall +answer
;; global options: +cmd
yahoo.com.		1654	IN	SOA	ns1.yahoo.com. hostmaster.yahoo-inc.com. 2019100201 3600 300 1814400 600
yahoo.com.		1654	IN	A	98.137.246.7
yahoo.com.		1654	IN	A	98.138.219.231
yahoo.com.		1654	IN	A	72.30.35.9
yahoo.com.		1654	IN	A	98.138.219.232
yahoo.com.		1654	IN	A	72.30.35.10
yahoo.com.		1654	IN	A	98.137.246.8
yahoo.com.		1654	IN	AAAA	2001:4998:44:41d::3
yahoo.com.		1654	IN	AAAA	2001:4998:58:1836::11
yahoo.com.		1654	IN	AAAA	2001:4998:44:41d::4
yahoo.com.		1654	IN	AAAA	2001:4998:c:1023::4
yahoo.com.		1654	IN	AAAA	2001:4998:58:1836::10
yahoo.com.		1654	IN	AAAA	2001:4998:c:1023::5
yahoo.com.		1654	IN	MX	1 mta7.am0.yahoodns.net.
yahoo.com.		1654	IN	MX	1 mta6.am0.yahoodns.net.
yahoo.com.		1654	IN	MX	1 mta5.am0.yahoodns.net.
yahoo.com.		21454	IN	NS	ns4.yahoo.com.
yahoo.com.		21454	IN	NS	ns5.yahoo.com.
yahoo.com.		21454	IN	NS	ns2.yahoo.com.
yahoo.com.		21454	IN	NS	ns3.yahoo.com.
yahoo.com.		21454	IN	NS	ns1.yahoo.com.
yahoo.com.		1654	IN	TXT	"edb3bff2c0d64622a9b2250438277a59"
yahoo.com.		1654	IN	TXT	"facebook-domain-verification=gysqrcd69g0ej34f4jfn0huivkym1p"
yahoo.com.		1654	IN	TXT	"v=spf1 redirect=_spf.mail.yahoo.com"
yahoo.com.		1654	IN	CAA	0 issue "globalsign.com"
yahoo.com.		1654	IN	CAA	0 iodef "mailto:security@oath.com"
yahoo.com.		1654	IN	CAA	0 issue "digicert.com"

AAAA ipv6

root@ali:~# dig www.taobao.com  AAAA +answer

; <<>> DiG 9.11.3-1ubuntu1.8-Ubuntu <<>> www.taobao.com AAAA +answer
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64974
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.taobao.com.			IN	AAAA

;; ANSWER SECTION:
www.taobao.com.		172	IN	CNAME	www.taobao.com.danuoyi.tbcache.com.

;; Query time: 2 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Wed Oct 02 19:18:53 CST 2019
;; MSG SIZE  rcvd: 88