DNS查詢 and trouble-shooting case

fiona8953發表於2016-09-23
ping和host,dig,nslookup是兩種不同型別的處理DNS的方式

ping,首先會查詢本地的/etc/hosts檔案,然後才會查詢DNS伺服器,這樣做有啥好處?效率高。

host,dig,nslookup三個命令是一樣的,不會查詢本地的/etc/hosts檔案,如果查詢DNS伺服器沒有結果,那麼直接返回無結果,此時,即使本地有配置/etc/hosts檔案也是沒有用的。

dig 顯示域名的高階資料(功能強大,操作簡潔) 
#dig 163.com 
#dig 163.com -t MX(查詢163的郵件伺服器) 
host 查詢主機使用的域名(簡單易用,輸出簡潔) 
#host 163.com 
#host -t MX 163.com 
nslookup 查詢域名與地址的對應(LINUX/UNIX平臺可用dig命令代替) 
#nslookup 
>set type=mx 
>163.com 
>exit


Trouble-shooting case
while true; do curl -s -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} Size: %{size_download} \n" -H 'Host: ' <'> ;done

dns: %{time_namelookup}
while true; do curl -s -o /dev/null -w "Connect: %{time_connect} DNS: %{time_namelookup} TTFB: %{time_starttransfer} Total time: %{time_total} Size: %{size_download} \n" -H 'Host: ' <'> ;done

Long respond time from CUBE API to Epay
fzou@cnpradm01:~$ while true; do curl -s -o /dev/null -w "Connect: %{time_connect} DNS: %{time_namelookup} TTFB: %{time_starttransfer} Total time: %{time_total} Size: %{size_download} \n" -H 'Host: ';done                            Connect: 0.008 DNS: 0.006 TTFB: 0.011 Total time: 0.011 Size: 426
Connect: 0.002 DNS: 0.002 TTFB: 0.004 Total time: 0.004 Size: 426
Connect: 0.003 DNS: 0.002 TTFB: 0.008 Total time: 0.008 Size: 426
Connect: 5.005 DNS: 5.005 TTFB: 5.010 Total time: 5.010 Size: 426
Connect: 0.003 DNS: 0.002 TTFB: 0.006 Total time: 0.006 Size: 426
Connect: 0.002 DNS: 0.002 TTFB: 0.004 Total time: 0.004 Size: 426
Connect: 0.003 DNS: 0.002 TTFB: 0.008 Total time: 0.008 Size: 426
Connect: 5.005 DNS: 5.005 TTFB: 5.010 Total time: 5.010 Size: 426
Connect: 0.003 DNS: 0.002 TTFB: 0.006 Total time: 0.006 Size: 426
Connect: 0.002 DNS: 0.002 TTFB: 0.004 Total time: 0.004 Size: 426
Connect: 0.003 DNS: 0.002 TTFB: 0.008 Total time: 0.008 Size: 426
Connect: 5.005 DNS: 5.005 TTFB: 5.009 Total time: 5.009 Size: 426
Connect: 0.004 DNS: 0.002 TTFB: 0.006 Total time: 0.006 Size: 426
Connect: 0.002 DNS: 0.002 TTFB: 0.004 Total time: 0.004 Size: 426
Connect: 0.003 DNS: 0.002 TTFB: 0.008 Total time: 0.008 Size: 426
Connect: 5.005 DNS: 5.005 TTFB: 5.009 Total time: 5.009 Size: 426
Connect: 0.004 DNS: 0.002 TTFB: 0.007 Total time: 0.007 Size: 426
Connect: 0.002 DNS: 0.002 TTFB: 0.004 Total time: 0.004 Size: 426
Connect: 0.003 DNS: 0.002 TTFB: 0.008 Total time: 0.008 Size: 426

\n
             timelookup:  %{time_namelookup}\n
               time_connect:  %{time_connect}\n
            time_appconnect:  %{time_appconnect}\n
           time_pretransfer:  %{time_pretransfer}\n
              time_redirect:  %{time_redirect}\n
         time_starttransfer:  %{time_starttransfer}\n
                            ----------\n
                 time_total:  %{time_total}\n
\n

curl "" -H "Pragma: no-cache" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4" -H "Upgrade-Insecure-Requests: 1" -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "Cache-Control: no-cache" -H "Cookie: JSESSIONID=89ED8D62D30A1CEA8BCEED04E8B074AF.frt004" -H "Connection: keep-alive" --compressed -IL -w "@curl_display.txt"

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26477398/viewspace-2125409/,如需轉載,請註明出處,否則將追究法律責任。

相關文章