Install and use dig under ubuntu/debian

There is no dig command under ubuntu10.10, but there is this command under debian6

I want to install apt-get under ubuntu, but I don’t find the dig package

After searching, I found that the correct installation is to install dnsutils

apt-get install dnsutils

PS: Redhat series are installed like this

yum install bind-utils

See how the dig command can replace nslookup most of the time

root@www:~# dig sina.com

;<<>> DiG 9.7.1-P2 <<>> sina.com
;; global options:+cmd
;; Got answer:;;->>HEADER<<- opcode: QUERY, status: NOERROR, id:58809;; flags: qr rd ra; QUERY:1, ANSWER:1, AUTHORITY:5, ADDITIONAL:2;; QUESTION SECTION:;sina.com.                      IN      A

;; ANSWER SECTION:
sina.com.60      IN      A       12.130.132.30;; AUTHORITY SECTION:
sina.com.600     IN      NS      ns3.sina.com.cn.
sina.com.600     IN      NS      ns1.sina.com.
sina.com.600     IN      NS      ns2.sina.com.cn.
sina.com.600     IN      NS      ns2.sina.com.
sina.com.600     IN      NS      ns1.sina.com.cn.;; ADDITIONAL SECTION:
ns1.sina.com.60      IN      A       114.134.80.144
ns2.sina.com.60      IN      A       114.134.80.145;; Query time:255 msec
;; SERVER:208.87.241.170#53(208.87.241.170);; WHEN: Thu Nov  322:18:192011;; MSG SIZE  rcvd:175

Concise use, only output A record (it is easy to get the ip address when writing the script)

dig jpuyy.com +short

Only output mx records, easy to use

dig mx jpuyy.com +short

Only output NS records

dig ns jpuyy.com

Query SOA (Start of Autority) and return to the main DNS server

dig soa jpuyy.com

Specify dns, for example query jpuyy.com records in 8.8.8.8

dig +short @8.8.8.8 jpuyy.com

Most of the time, the bottom of dig shows the query time and DNS server, time, and data size. The DNS timeout time is 30 seconds, and the query time is very useful for troubleshooting DNS problems.

;; Query time:48 msec
;; SERVER:10.202.72.118#53(10.202.72.118);; WHEN: Sun Oct 1221:41:472014;; MSG SIZE  rcvd:225

DNS resolution is recursive resolution, then you can use dig to add the +trace parameter, it will display a complete, non-cached, recursive query, and display a complete trace record.
It can be found that the local DNS (10.202.72.118) returned a list of root servers, a root server (199.7.91.13) found the record of com., and one of the com. found jpuyy.com and returned the NS record. A record was found in NS.

dig jpuyy.com +trace

;<<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1<<>> jpuyy.com +trace
;; global options:+cmd
.493573 	IN	NS	i.root-servers.net..493573	IN	NS	e.root-servers.net..493573	IN	NS	k.root-servers.net..493573	IN	NS	c.root-servers.net..493573	IN	NS	f.root-servers.net..493573	IN	NS	d.root-servers.net..493573	IN	NS	m.root-servers.net..493573	IN	NS	j.root-servers.net..493573	IN	NS	g.root-servers.net..493573	IN	NS	b.root-servers.net..493573	IN	NS	h.root-servers.net..493573	IN	NS	a.root-servers.net..493573	IN	NS	l.root-servers.net.;; Received 496 bytes from10.202.72.118#53(10.202.72.118)in1 ms

com.172800	IN	NS	b.gtld-servers.net.
com.172800	IN	NS	i.gtld-servers.net.
com.172800	IN	NS	f.gtld-servers.net.
com.172800	IN	NS	m.gtld-servers.net.
com.172800	IN	NS	l.gtld-servers.net.
com.172800	IN	NS	e.gtld-servers.net.
com.172800	IN	NS	k.gtld-servers.net.
com.172800	IN	NS	g.gtld-servers.net.
com.172800	IN	NS	a.gtld-servers.net.
com.172800	IN	NS	j.gtld-servers.net.
com.172800	IN	NS	d.gtld-servers.net.
com.172800	IN	NS	h.gtld-servers.net.
com.172800	IN	NS	c.gtld-servers.net.;; Received 487 bytes from199.7.91.13#53(199.7.91.13)in162 ms

jpuyy.com.172800	IN	NS	f1g1ns1.dnspod.net.
jpuyy.com.172800	IN	NS	f1g1ns2.dnspod.net.;; Received 209 bytes from192.5.6.30#53(192.5.6.30)in298 ms

jpuyy.com.600	IN	A	114.215.158.48;; Received 43 bytes from112.90.143.29#53(112.90.143.29)in38 ms

The server is often two-wire or three-wire. If there is smart resolution, you need to test to request dns from a certain ip, and add the -b parameter

Recommended Posts

Install and use dig under ubuntu/debian
Install and use docker under CentOS 6.8
Cpp web (1) Install and use Crow service under Ubuntu
Install and configure keepalived under CentOS 5.9
Talk about | Install and use Linux system Ubuntu under Win10
Compile and install LAMP under Centos 5.2
Use Nginx and u under CentOS
CentOS7.3 install iptables and detailed use
Install and deploy Gerrit under Ubuntu
Install nodejs and npm under Ubuntu 16.04
Install Python3 and ansible under CentOS8
CentOS7 install and use SQL Server
Install Python3 and Py under CentOS7
Compile and install QEMU under Ubuntu
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Compile and install libmodbus library under CentOS7
Installation and use of Mysql under CentOS
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
KVM installation and preliminary use under CentOS 7.2
How to install and use Docker on CentOS 7
Install and use Git and GitHub on Ubuntu Linux
How to install and use Docker on Ubuntu 20.04
How to install and use Curl on Ubuntu 18.04
How to install and use Composer on Ubuntu 18.04
How to install and use Wine on Ubuntu 18.04
How to install and use Composer on CentOS 8
How to install and use Composer on Ubuntu 20.04
How to install and use BaasBox on Ubuntu 14.04
Install svn and configuration through yum under CentOS
How to install and use PostgreSQL on Ubuntu 16.04
How to install and use Curl on CentOS 8
How to install and use Docker on Ubuntu 16.04
Install centos7 and connect
Install apache+PHP under Ubuntu
Install node.js under Ubuntu
Install python3.6 under Ubuntu 16.04
Install mysql5.7 under CentOS7
Install win7 and archlinux on hard disk under ubuntu
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install ActiveMQ under Centos7
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Installation and use of GDAL in Python under Ubuntu
How to install and use MySQL Workbench on Ubuntu 18.04
[python] python2 and python3 under ubuntu
Use iptables under ubuntu
2018-09-11 Install arduino under Ubuntu
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
How to install and use Cockpit on CentOS 8/RHEL 8
Install mysql under Centos 7
Install Jenkins under Centos 7
Install ROS under ROS Ubuntu 18.04[2]
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Install MySQL under Ubuntu
Install Yarm-PM2 under Ubuntu
Compile and install Lnmp shell script under Linux centos
Install Huginn on Ubuntu/Debian