windows安裝dig

dig是一個Linux下用來查詢DNS信息的工具,全稱是Domain Information Groper,
與nslookup類似,但比nslookup功能更強大。
Windows下只有nslookup,如果也想用到dig命令,需要自己動手安裝。
dig作爲bind的一部分,我們需要去bind9官網的鏡像中下載安裝包,
bind是現在使用最爲廣泛的DNS服務器軟件,最早由伯克利大學的一名學生編寫,
最新的版本是9.9.9(截至今天),目前由ISC(Internet Systems Consortium)編寫和維護。

1. 下載:訪問https://www.bind9.net/download,隨便選擇一個mirrors link下載
  (有些可能打不開,多試幾個,我訪問的是United States的mirror ftp://ftp.isc.org/isc/bind9/)
2. 選擇最新版本9.9.9/版本進入,點擊BIND9.9.9.x64.zip下載
3. 解壓zip文件,點擊vcredist_x64.exe安裝Microsoft Visual C++ 2012 Redistribution
4. 將解壓後的dll文件(9.9.9版本有9個dll文件)複製到C:\Windows\System32目錄下
5. 將解壓後的dig.exe也複製到C:\Windows\System32目錄下
6. 安裝完畢,cmd打開windows終端,測試: dig baidu.com




使用python dig SRV測試,SRV參考(https://en.wikipedia.org/wiki/SRV_record)
def test_dig_in_windows():
    """
    如果不在windows上安裝dig,使用subprocess執行下面命令會報error:
        WindowsError: [Error 2] The system cannot find the file specified
    :return: srv
    """
    import subprocess
    import shlex

    cmd = 'dig @ns1.xxx.net _sips._tcp.xxx.xxx. -t SRV +short'
    process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE)
    out, err = process.communicate()
    print(out)

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章