青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

小默

【轉(zhuǎn)】DiG HOWTO

DiG HOWTO

Paul Heinlein 

Initial publication: August 31, 2004
Most recent revision: May 11, 2006

How to use dig to query DNS name servers.


Introduction

dig is a command-line tool for querying DNS name servers for information about host addresses, mail exchanges, name servers, and related information. The dig(1) man page is somewhat lacking when it comes to examples, a shortcoming this article tries to remedy.

The source code for dig is part of the larger ISC BIND distribution. Compiling and installing BIND are topics outside the scope of this document, but on Linux systems digis usually part of a common package: bind-tools (Gentoo), bind-utils (Red Hat, Fedora), or dnsutils (Debian).

If you’re looking for information on configuring the BIND name server, you might find my article BIND for the Small LAN more to your taste.

Understanding the default output

The most typical, simplest query is for a single host. By default, however, dig is pretty verbose. You probably don’t need all the information in the default output, but it’s probably worth knowing what it is. Below is an annotated query.

$ dig www.isc.org

That’s the command-line invocation of dig I used.

; <<>> DiG 9.2.3 <<>> www.isc.org
;; global options:  printcmd

The opening section of dig’s output tells us a little about itself (version 9.2.3) and the global options that are set (in this case, printcmd). This part of the output can be quelled by using the +nocmd option, but only if it’s the very first argument on the command line (even preceeding the host you’re querying).

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43071
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3

Here, dig tells us some technical details about the answer received from the DNS server. This section of the output can be toggled using the +[no]comments option—but beware that disabling the comments also turns off many section headers.

;; QUESTION SECTION:
;www.isc.org.                   IN      A

In the question section, dig reminds us of our query. The default query is for an Internet address (A). You can turn this output on or off using the +[no]question option.

;; ANSWER SECTION:
www.isc.org.            600     IN      A       204.152.184.88

Finally, we get our answer: the address of www.isc.org is 204.152.184.88. I don’t know why you’d ever want to turn off the answer, but you can toggle this section of the output using the +[no]answer option.

;; AUTHORITY SECTION:
isc.org.                2351    IN      NS      ns-int.isc.org.
isc.org.                2351    IN      NS      ns1.gnac.com.
isc.org.                2351    IN      NS      ns-ext.isc.org.

The authority section tells us what DNS servers can provide an authoritative answer to our query. In this example, isc.org has three name servers. You can toggle this section of the output using the +[no]authority option.

;; ADDITIONAL SECTION:
ns1.gnac.com.           171551  IN      A       209.182.216.75
ns-int.isc.org.         2351    IN      A       204.152.184.65
ns-int.isc.org.         2351    IN      AAAA    2001:4f8:0:2::15

The additional section typically includes the IP addresses of the DNS servers listed in the authority section. This section of the output can be toggled with the +[no]additionaloption.

;; Query time: 2046 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Aug 27 08:22:26 2004
;; MSG SIZE  rcvd: 173

The final section of the default output contains statistics about the query; it can be toggled with the +[no]stats option.

What can I discover?

dig will let you perform any valid DNS query, the most common of which are A (the IP address), TXT (text annotations), MX (mail exchanges), NS name servers, or the omnibusANY.

# get the address(es) for yahoo.com
dig yahoo.com A +noall +answer

# get a list of yahoo's mail servers
dig yahoo.com MX +noall +answer

# get a list of DNS servers authoritative for yahoo.com
dig yahoo.com NS +noall +answer

# get all of the above
dig yahoo.com ANY +noall +answer

More obscurely, for the present anyway, you can also poll for a host’s IPv6 address using the AAAA option.

dig www.isc.org AAAA +short

If the domain you want to query allows DNS transfers, you can get those, too. The reality of life on the Internet, however, is that very few domains allow unrestricted transfers these days.

dig yourdomain.com AXFR

How do I …

Get a short answer?

When all you want is a quick answer, the +short option is your friend:

$ dig www.isc.org +short
204.152.184.88

Get a not-quite-so-short answer?

Note that a short answer is different from only an answer. The way to get a detailed answer, but without any auxiliary information, is to turn off all the results (+noall) and then turn on only those sections you want.

Here’s a short answer followed by only an answer; the latter includes all the configuration information, including time-to-live (TTL) data, displayed in a format compatible with BIND configuration files.

$ dig fsf.org mx +short
20 mx20.gnu.org.
30 mx30.gnu.org.
10 mx10.gnu.org.

$ dig +nocmd fsf.org mx +noall +answer
fsf.org.                3583    IN      MX      30 mx30.gnu.org.
fsf.org.                3583    IN      MX      10 mx10.gnu.org.
fsf.org.                3583    IN      MX      20 mx20.gnu.org.

Get a long answer?

According to its man page, the +multiline option will give you an answer with the SOA records in a verbose multi-line format with human-readable comments. In general, the answers retrieved using the +multiline option will appear more like BIND config files than they will without it.

$ dig +nocmd ogi.edu any +multiline +noall +answer
ogi.edu.   14267 IN A 129.95.59.31
ogi.edu.   14267 IN MX 5 cse.ogi.edu.
ogi.edu.   14267 IN MX 15 hermes.admin.ogi.edu.
ogi.edu.   14267 IN SOA zeal.admin.ogi.edu. hostmaster.admin.ogi.edu. (
                   200408230  ; serial
                   14400      ; refresh (4 hours)
                   900        ; retry (15 minutes)
                   3600000    ; expire (5 weeks 6 days 16 hours)
                   14400      ; minimum (4 hours)
                   )
ogi.edu.   14267 IN NS zeal.admin.ogi.edu.
ogi.edu.   14267 IN NS cse.ogi.edu.
ogi.edu.   14267 IN NS fork.admin.ogi.edu.

Do a reverse lookup?

Use the -x option to lookup the main hostname associated with an IP address.

$ dig -x 204.152.184.167 +short
mx-1.isc.org.

In a loop, this is a slick way to map the names in a given subnet:

#!/bin/bash
NET=18.7.22
for n in $(seq 1 254); do
  ADDR=${NET}.${n}
  echo -e "${ADDR}\t$(dig -x ${ADDR} +short)"
done

Query a different nameserver?

Just specify it on the command line:

dig @ns1.google.com www.google.com

Use the search list in /etc/resolv.conf?

The host utility will automatically use the search list in your /etc/resolv.conf file.

$ host www
www.madboa.com has address 65.102.49.170

By default, however, dig doesn’t—which may produce some unexpected results. If you want to use local hostnames instead of fully qualified domain names, use the +searchoption.

dig www +search

Do bulk lookups?

If you want to look up a large number of hostnames, you can put them in a file (one name per line) and use the -f option to query each one in turn.

# do full lookups for a number of hostnames
dig -f /path/to/host-list.txt

# the same, with more focused output
dig -f /path/to/host-list.txt +noall +answer

As far as I can tell, dig versions up to and including 9.2.3 are unable to do reverse lookups using the -f option.

Verifying DNS mappings

An improperly configured DNS setup can be really annoying. You want to make sure that your mappings work both ways:

  1. Each hostname should resolve to an address, and that address ought to resolve back to the proper hostname.

  2. If an address on your subnet(s) has been assigned a reverse pointer to a hostname, that hostname ought to point back to the original address.

There are exceptions to those two rules, of course. A CNAME will resolve to another hostname first, and only then to an address. Sometimes multiple hostnames will point to the same address, but that address will have only one reverse pointer.

Still, it’s good to know that your basic mappings work as expected.

You can script such a test if you build a file containing your known hostnames. The example script below is pretty simple; it will break if fed a CNAME, and it’ll report a failure somewhere if multiple hostnames point to the same address. Let’s assume the file containing your hostnames is named named-hosts.

#!/bin/bash
#
# test DNS forward- and reverse-mapping
#

# edit this variable to reflect local class C subnet(s)
NETS="192.168.1 192.168.2"

# Test name to address to name validity
echo
echo -e "\tname -> address -> name"
echo '----------------------------------'
while read H; do
  ADDR=$(dig $H +short)
  if test -n "$ADDR"; then
    HOST=$(dig -x $ADDR +short)
    if test "$H" = "$HOST"; then
      echo -e "ok\t$H -> $ADDR -> $HOST"
    elif test -n "$HOST"; then
      echo -e "fail\t$H -> $ADDR -> $HOST"
    else
      echo -e "fail\t$H -> $ADDR -> [unassigned]"
    fi
  else
    echo -e "fail\t$H -> [unassigned]"
  fi
done < named-hosts

# Test address to name to address validity
echo
echo -e "\taddress -> name -> address"
echo '-------------------------------------'
for NET in $NETS; do
  for n in $(seq 1 254); do
    A=${NET}.${n}
    HOST=$(dig -x $A +short)
    if test -n "$HOST"; then
      ADDR=$(dig $HOST +short)
      if test "$A" = "$ADDR"; then
        echo -e "ok\t$A -> $HOST -> $ADDR"
      elif test -n "$ADDR"; then
        echo -e "fail\t$A -> $HOST -> $ADDR"
      else
        echo -e "fail\t$A -> $HOST -> [unassigned]"
      fi
    fi
  done
done

dig fun

Roll your own named.root file

Any DNS server connected to the Internet is likely to have a copy of the InterNIC’snamed.root file that lists the root name servers for the entire Internet. You can always download that file in the boring way from the InterNIC’s ftp server. Or, in a true build-it-yourself fashion, you can build it with dig.

# compare with ftp://ftp.internic.net/domain/named.root
dig +nocmd . NS +noall +answer +additional

Your TTL values might be a little on the short side, but otherwise, it’s as up-to-date a list as you’ll find!

Tracing dig’s path

Perhaps you’re a devotee of traceroute and like to watch how to get from point A to point B. You can do a similar thing with dig’s +trace option.

dig gentoo.de +trace

You’ll see dig head to the root name servers, then to the servers responsible for all the *.de domains, and finally to the name servers responsible for gentoo.de.

Grabbing SOA information

As a DNS administrator, I sometimes make changes and want to see if any of my name servers are still pushing the old data. The +nssearch provides a clear accounting of your public servers.

# the unvarnished truth
dig cse.ogi.edu +nssearch

# the same, displaying only serial number and hostname
dig cse.ogi.edu +nssearch | cut -d' ' -f4,11

Interpreting TTL numbers

I love Google for many reasons, one of which is that it provides referrer strings in my web logs that make it easy to figure out what sort of queries lead people to pages on this site.

Somewhat unexpectedly, I’ve seen a lot of queries asking for information about TTL (time-to-live) numbers. I would have never guessed that TTL would be a topic of interest, but you learn something new every day. So, by popular demand, here’s a brief intro to TTL.

If you ask your local DNS server for an Internet address, the server figures out where to find an authoritative answer and then asks for it. Once the server receives an answer, it will keep the answer in a local cache so that if you ask for the same address again a short time later, it can give you the answer quickly rather than searching the Internet for it all over again.

When domain administrators configure their DNS records, they decide how long the records should remain in remote caches. This is the TTL number (usually expressed in number of seconds).

Typically, a remote server will only cache those records for the length of time specified by the TTL. After that, the remote server will flush its local cache and ask again for an authoritative answer.

When you use dig to query a DNS server concerning a certain record, the server will tell dig the time (in seconds) that record will remain in cache.

For example, as of this writing, the TTL for the MX records for the gmail.com domain is 300 seconds. The gmail.com admins are asking that remote servers cache their MX records for no more than five minutes. So when you first ask for that record set, dig will report a TTL of 300.

$ dig +nocmd gmail.com MX +noall +answer
gmail.com.        300     IN      MX      20 gsmtp57.google.com.
gmail.com.        300     IN      MX      10 gsmtp171.google.com.

If you ask a few seconds later, you’ll see the TTL number reduced by approximately the number of seconds you waited to ask again.

$ dig +nocmd gmail.com MX +noall +answer
gmail.com.        280     IN      MX      10 gsmtp171.google.com.
gmail.com.        280     IN      MX      20 gsmtp57.google.com.

If your timing is good, you can catch the record at the very end of its life.

$ dig +nocmd gmail.com MX +noall +answer
gmail.com.        1       IN      MX      10 gsmtp171.google.com.
gmail.com.        1       IN      MX      20 gsmtp57.google.com.

After that, the DNS server you’re querying will forget the answer to that question, so the whole cycle will start over again (in this example, at 300 seconds) the next time you perform that query.

posted on 2010-11-23 04:48 小默 閱讀(384) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Network

導(dǎo)航

統(tǒng)計(jì)

留言簿(13)

隨筆分類(287)

隨筆檔案(289)

漏洞

搜索

積分與排名

最新評(píng)論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲一区亚洲| 欧美精品一二三| 欧美国产免费| 男女精品网站| 欧美在线地址| 久久激情视频久久| 久久综合五月天婷婷伊人| 老司机亚洲精品| 亚洲国产天堂久久综合网| 亚洲丰满少妇videoshd| 亚洲毛片在线观看| 亚洲一区三区视频在线观看 | 亚洲福利视频一区二区| 免费亚洲电影在线| 亚洲欧洲视频| 亚洲一区二区三区在线看| 久久精品夜色噜噜亚洲a∨| 玖玖玖国产精品| 欧美日韩综合在线| 伊人成人在线| 中文精品一区二区三区| 欧美专区日韩视频| 亚洲国产成人不卡| 亚洲小说欧美另类婷婷| 久久久欧美精品| 欧美日本一道本| 国产亚洲视频在线| 妖精成人www高清在线观看| 欧美一区二区三区的| 欧美成人r级一区二区三区| 亚洲私人影院| 女女同性精品视频| 国产精品人成在线观看免费| 精品1区2区3区4区| 亚洲欧美激情诱惑| 亚洲韩国青草视频| 久久国产乱子精品免费女| 欧美日韩不卡在线| 亚洲国产高清aⅴ视频| 性久久久久久久久| 一本久道久久综合狠狠爱| 欧美一级免费视频| 国产精品久99| 亚洲午夜日本在线观看| 亚洲第一精品福利| 久久先锋影音| 韩国精品久久久999| 亚洲欧美日韩精品综合在线观看| 亚洲高清久久久| 久久资源在线| 一区二区在线视频播放| 久久九九免费视频| 香蕉成人久久| 国产亚洲一二三区| 久久精品国产综合| 亚洲欧美日本国产有色| 欧美视频中文字幕在线| 一区二区三区欧美在线观看| 亚洲日本一区二区三区| 久久精品视频在线免费观看| 亚洲欧美国产77777| 日韩一区二区精品视频| 欧美粗暴jizz性欧美20| 亚洲欧洲一区二区天堂久久| 欧美国产欧美亚洲国产日韩mv天天看完整 | 国模 一区 二区 三区| 久久成人精品一区二区三区| 亚洲欧美成人一区二区三区| 国产日韩精品在线播放| 久久精品色图| 久久精品水蜜桃av综合天堂| 在线观看日韩一区| 亚洲黄色av一区| 欧美色大人视频| 午夜精品久久久久久久99黑人| 日韩图片一区| 国产女主播一区二区| 久久天天躁狠狠躁夜夜av| 免费成人av在线看| 亚洲手机视频| 香蕉尹人综合在线观看| 亚洲电影有码| 日韩性生活视频| 国产在线拍揄自揄视频不卡99| 你懂的亚洲视频| 欧美日韩国产首页| 午夜宅男欧美| 久久综合久久久| 一区二区不卡在线视频 午夜欧美不卡在 | 亚洲第一精品夜夜躁人人躁| 91久久精品久久国产性色也91| 欧美性色综合| 久久伊人免费视频| 欧美日韩蜜桃| 久久久久久欧美| 欧美韩日一区二区三区| 欧美影院一区| 欧美巨乳波霸| 久久亚洲精品视频| 欧美日韩大陆在线| 久久综合色天天久久综合图片| 欧美三日本三级少妇三99| 免费在线日韩av| 国产精品视频yy9299一区| 欧美电影资源| 日韩一级裸体免费视频| 亚洲女优在线| 狠狠久久婷婷| 一区二区欧美日韩视频| 中文国产成人精品| 欧美色区777第一页| 亚洲激情精品| 99视频精品在线| 国产精品多人| 亚洲高清自拍| 亚洲精品国产精品国自产在线| 久久久久国产精品一区| 一本久道久久综合婷婷鲸鱼| 欧美日韩四区| 亚洲综合丁香| 亚洲视频精选在线| 国产伦精品一区二区三| 欧美成人中文字幕| 亚洲精品在线视频| 欧美影院精品一区| 国产性做久久久久久| 久久综合久久久| 一本久道久久久| 欧美国产成人精品| 午夜国产精品视频| 亚洲精品视频免费观看| 欧美深夜影院| 欧美三日本三级少妇三2023 | 在线成人欧美| 欧美日韩精品| 欧美性猛交一区二区三区精品| 老**午夜毛片一区二区三区| 亚洲电影免费观看高清完整版| 欧美一级欧美一级在线播放| 亚洲少妇诱惑| 亚洲一区二区在线看| 欧美在线日韩| 亚洲电影激情视频网站| 欧美日韩一区不卡| 欧美日韩国产在线一区| 久久伊人亚洲| 亚洲欧美成人精品| 亚洲人成在线观看一区二区 | 久久九九国产| 久久精品主播| 欧美国产高清| 99在线热播精品免费| 亚洲欧美国产精品桃花| 午夜精品福利电影| 亚洲一区二区黄色| 久久精品综合一区| 免费观看一级特黄欧美大片| 欧美视频在线视频| 日韩视频专区| 亚洲美女精品一区| 香蕉av777xxx色综合一区| 亚洲桃花岛网站| 久久久久一区二区三区| 欧美成黄导航| 亚洲国产网站| 午夜国产一区| 欧美日本高清视频| 在线观看视频亚洲| 国产精品99久久99久久久二8| 久久艳片www.17c.com| 亚洲高清视频一区| 久久精品亚洲国产奇米99| 美腿丝袜亚洲色图| 娇妻被交换粗又大又硬视频欧美| 亚洲女同同性videoxma| 乱中年女人伦av一区二区| 亚洲影视在线| 国产欧美一区二区三区另类精品 | 久久久久久免费| 日韩一级黄色大片| 欧美天天综合网| 一区二区在线观看av| 99这里只有精品| 亚洲三级免费| 欧美日本一区二区三区 | 久久精品首页| 亚洲狼人综合| 国产农村妇女精品一区二区| 亚洲一区二区在线播放| 久久精品二区| 韩国精品一区二区三区| 久久福利毛片| 久久久久se| 这里只有精品丝袜| 亚洲剧情一区二区| 欧美色区777第一页| 欧美不卡激情三级在线观看| 久久久久久成人| 在线观看日韩av电影| 亚洲人久久久|