小言_互联网的博客

每天学一个 Linux 命令(69):nslookup

304人阅读  评论(0)

点击下方“民工哥技术之路”,选择“设为星标”

回复“1024”获取独家整理的学习资料!

推荐阅读:每天学一个 Linux 命令(68):lsof

命令简介

nslookup(name server lookup)命令用于查询域名 DNS 信息的工具。nslookup 有两种工作模式,即“交互模式”和“非交互模式”。


   
  1. [root@CentOS7 -1 ~]# nslookup
  2. -bash: nslookup: command not found
  3. [root@CentOS7 -1 ~]# yum install -y bind-utils

语法格式

nslookup [-option] [name | -] [server]

选项说明


   
  1. -query=TYPE      #设置查询类型
  2. -timeout=NUMBER  #设置等待响应的超时时间,单位秒
  3. -sil             #不显示任何警告信息。

还有一些交互的命令,有兴趣的读者可以查看帮助信息阅读。

应用举例

实例


   
  1. 非交互式模式
  2. [root@CentOS7 -1 ~]# nslookup www.baidu.com
  3. Server:   223.5 .5 .5
  4. Address:  223.5 .5 .5# 53
  5. Non-authoritative answer:
  6. www.baidu.com canonical name = www.a.shifen.com.
  7. Name: www.a.shifen.com
  8. Address:  36.152 .44 .96
  9. Name: www.a.shifen.com
  10. Address:  36.152 .44 .95
  11. #交互式模式
  12. [root@CentOS7 -1 ~]# nslookup
  13. > baidu.com
  14. Server:   223.5 .5 .5
  15. Address:  223.5 .5 .5# 53
  16. Non-authoritative answer:
  17. Name: baidu.com
  18. Address:  39.156 .69 .79
  19. Name: baidu.com
  20. Address:  220.181 .38 .148
  21. 163.com
  22. Server:   223.5 .5 .5
  23. Address:  223.5 .5 .5# 53
  24. Non-authoritative answer:
  25. Name:  163.com
  26. Address:  123.58 .180 .7
  27. Name:  163.com
  28. Address:  123.58 .180 .8

google.com 相关的信息


   
  1. #在您的 DNS 中查询与域名 google.com 相关的所有可用信息。
  2. [root@CentOS7 -1 ~]# nslookup - type=any google.com
  3. Server:   223.5 .5 .5
  4. Address:  223.5 .5 .5# 53
  5. Non-authoritative answer:
  6. Name: google.com
  7. Address:  93.46 .8 .90
  8. google.com nameserver = ns1.google.com.
  9. google.com nameserver = ns2.google.com.
  10. google.com nameserver = ns4.google.com.
  11. google.com nameserver = ns3.google.com.
  12. Authoritative answers can be found from:
  13. #在您的 DNS 中查询与域名 google.com 相关邮件交换服务器的信息
  14. [root@CentOS7 -1 ~]# nslookup - type=mx google.com
  15. Server:   223.5 .5 .5
  16. Address:  223.5 .5 .5# 53
  17. Non-authoritative answer:
  18. google.com mail exchanger =  10 aspmx.l.google.com.
  19. google.com mail exchanger =  50 alt4.aspmx.l.google.com.
  20. google.com mail exchanger =  20 alt1.aspmx.l.google.com.
  21. google.com mail exchanger =  30 alt2.aspmx.l.google.com.
  22. google.com mail exchanger =  40 alt3.aspmx.l.google.com.
  23. Authoritative answers can be found from:

反向查找一个地址(文中地址作了处理哈)


   
  1. [root@CentOS7 -1 ~]# nslookup  200.208 .150 .3
  2.  
  3. Server:          103.240 .22 .111
  4. Address:         103.240 .22 .111# 53
  5.  
  6. Non-authoritative answer:
  7. 3.150 .208 .200.in-addr.arpa      name =  200.208 .150 .3.xmission.com.
  8.  
  9. Authoritative answers can be found from:
  10. 150.208 .200.in-addr.arpa        nameserver = ns1.xmission.com.
  11. 150.208 .200.in-addr.arpa        nameserver = ns2.xmission.com.
  12. 150.208 .200.in-addr.arpa        nameserver = ns.xmission.com.

每天学一个 Linux 命令(66):ss

每天学一个 Linux 命令(67):nmap

推荐阅读 点击标题可跳转

Docker部署Prometheus+Grafana监控系统

牛逼!用 GitLab 做 CI/CD 是什么感觉,太强了

彻夜怒肝!Docker 疑难杂症解决方案已撸完,快要裂开了

蚂蚁金服 CEO 突然辞职!去向很意外

再见 FTP/SFTP!下一代文件传输利器 Croc 来了!

MongoDB 日常运维实践总结

这 5 种常用运维监控工具都不会?你算啥运维人

超详细讲解!10 种常见的软件架构模式

搞懂这 9 步,DNS 访问原理就明明白白了


转载:https://blog.csdn.net/mingongge/article/details/115037782
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场