dig常用命令

Dig是域信息搜索器的简称(Domain Information Groper),使用dig命令可以执行查询域名相关的任务。

###1. 理解dig的输出结果

$ dig chenrongrong.info

1 ; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> chenrongrong.info
2 ;; global options: +cmd
3 ;; Got answer:
4 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22752
5 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1

7 ;; OPT PSEUDOSECTION:
8 ; EDNS: version: 0, flags:; udp: 4096
9 ;; QUESTION SECTION:
10 ;chenrongrong.info.      IN  A

11 ;; ANSWER SECTION:
12 chenrongrong.info.   600 IN  A   103.245.222.133

13 ;; AUTHORITY SECTION:
14 chenrongrong.info.   600 IN  NS  f1g1ns2.dnspod.net.
15 chenrongrong.info.   600 IN  NS  f1g1ns1.dnspod.net.

16 ;; Query time: 183 msec
17 ;; SERVER: 127.0.1.1#53(127.0.1.1)
18 ;; WHEN: Thu Dec 25 16:04:51 CST 2014
19 ;; MSG SIZE  rcvd: 116

1~8: 显示了dig的基本设置信息,e.g. java -version

9-10: 显示了查询内容,这里查询的是域名chenrongrong.info的A记录

11-12: 显示了查询结果,域名chenrongrong.info的A记录是103.245.222.133(A (Address) 记录是用来指定主机名(或域名)对应的IP地址记)

13-15: 授权信息,域名chenrongrong.info的NS(nameserver)是dnspod的域名服务器

16-19: 统计信息

上述选项都可以通过对应选项选择是否输出,+[no]question,+[no]answer,+[no]authority,+[no]stat,当然+short更加简洁

###2. 显示特定的输出结果

+[no]comments – Turn off the comment lines
+[no]authority – Turn off the authority section
+[no]additional – Turn off the additional section
+[no]stats – Turn off the stats section
+[no]answer – Turn off the answer section (Of course, you wouldn’t want to turn off the answer section)

###3. 查询MX记录 MX(Mail Exchanger)记录查询:

$ dig redhat.com MX +noall +answer
or
$ dig -t MX redhat.com +noall +answer 后者-t代表查询类型,可以是A,MX,NS等,+noall 代表清除所有显示的选项
###4. 查询域名服务器

$ dig -t NS chenrongrong.info +noall +answer

###5. 查询所有DNS记录

$ dig -t ANY chenrongrong.info +answer

; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> -t ANY chenrongrong.info            +noall +answer
;; global options: +cmd
chenrongrong.info.  568 IN  A   103.245.222.133
chenrongrong.info.  568 IN  NS  f1g1ns2.dnspod.net.
chenrongrong.info.  568 IN  NS  f1g1ns1.dnspod.net.
chenrongrong.info.  568 IN  SOA f1g1ns1.dnspod.net.freednsadmin.dnspod.com. 1417233166 3600 180 1209600 180

###6. 简洁显示+short

+short参数只显示nameserver $ dig -t NS chenrongrong.info +short

f1g1ns2.dnspod.net.
f1g1ns1.dnspod.net.

###7. DNS反向解析dig -x

我们一般所说的DNS域名解析指的是正向解析即从域名解析到相应的IP,反之从IP解析到对应的DNS服务器就是反向解析,8.8.8.8是google的一个公共DNS服务器,我们可以通过dig -x查找该ip对应的DNS服务器

$ dig -x 8.8.8.8 +short

google-public-dns-a.google.com.

8.显示域名的CNAME记录

CNAME记录,即:别名记录。这种记录允许您将多个名字映射到同一台计算机.

dig cname www.baidu.com +short

www.a.shifen.com.

dig可以使我们更好的理解DNS解析的过程,dig -h列出了更多详细的命令参数可供我们使用,这也是学习命令有效方式:

Windows Thin PC下载安装笔记

之前在rMBP上一直用VMware Fasion 安装 Windows server 2012 R2虚拟机来运行一些没法替代的Win软件,用了一段时间,发现13寸的MBP实在是跑不动,隔一段时间虚拟机就会卡的不行.不想回去用XP,在网上搜了下,发现了Windows Thin PC,Windows Thin PC是Windows 7的轻量精简版本,跑在虚拟机上是在合适不过了.

继续阅读→

阿里云debian镜像

记录一下
debian 6.x (squeeze)

编辑/etc/apt/sources.list文件, 在文件最前面添加以下条目(操作前请做好相应备份)

deb http://mirrors.aliyun.com/debian/ squeeze main non-free contrib
deb http://mirrors.aliyun.com/debian/ squeeze-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ squeeze main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ squeeze-proposed-updates main non-free contrib
        

debian 7.x (wheezy)

编辑/etc/apt/sources.list文件, 在文件最前面添加以下条目(操作前请做好相应备份)

deb http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib
        

debian 8.x (jessie)

编辑/etc/apt/sources.list文件, 在文件最前面添加以下条目(操作前请做好相应备份)

deb http://mirrors.aliyun.com/debian/ jessie main non-free contrib
deb http://mirrors.aliyun.com/debian/ jessie-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ jessie main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ jessie-proposed-updates main non-free contrib

记一下

rm -rf /etc/apt/sources.list.d
rm -rf /etc/apt/sources.list
cat >>/etc/apt/sources.list<<EOF
deb http://mirrors.cloud.aliyuncs.com/debian/ jessie main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie main contrib non-free
deb http://mirrors.cloud.aliyuncs.com/debian/ jessie-proposed-updates main non-free contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie-proposed-updates main non-free contrib
deb http://mirrors.cloud.aliyuncs.com/debian/ jessie-updates main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie-updates main contrib non-free
EOF