V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
hanssx
V2EX  ›  Linux

dig 命令异常

  •  
  •   hanssx · 2022-01-20 14:49:27 +08:00 · 1799 次点击
    这是一个创建于 890 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境是 VMware 虚拟机装的 Linux Mint ,在 VMware 软件的 NAT 网络模式里面设置了 DNS: 10.x 的公司内网 DNS 两个公开 DNS 223.5.5.5 8.8.8.8

    为啥要在 VMware 里面设置 DNS 是由于出差在外面用 4G 连公司 VPN 的时候,老是解析不了公司内网的 API 接口,于是把公司内网 DNS 直接设置到了 VMWare 的 NAT 模式下的 DNS 配置中。

    然后我回到公司接入网线,发现 dig 不好使了,nslookup 倒是没有问题。

     nslookup
    > www.baidu.com
    Server:		127.0.0.53
    Address:	127.0.0.53#53
    
    Non-authoritative answer:
    www.baidu.com	canonical name = www.a.shifen.com.
    Name:	www.a.shifen.com
    Address: 220.181.38.150
    Name:	www.a.shifen.com
    Address: 220.181.38.149
    
    

    dig 的话,指定 dns 服务器均提示 connection timed out

    # mint @ mint-virtual-machine in ~ [14:30:23] C:9
    $ ping 114.114.114.114
    PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
    64 bytes from 114.114.114.114: icmp_seq=1 ttl=128 time=20.8 ms
    64 bytes from 114.114.114.114: icmp_seq=2 ttl=128 time=21.7 ms
    ^C
    --- 114.114.114.114 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1001ms
    rtt min/avg/max/mdev = 20.898/21.313/21.728/0.415 ms
    (base) 
    # mint @ mint-virtual-machine in ~ [14:41:22] 
    $ dig @114.114.114.114 www.baidu.com 
    
    
    ; <<>> DiG 9.11.3-1ubuntu1.15-Ubuntu <<>> @114.114.114.114 www.baidu.com
    ; (1 server found)
    ;; global options: +cmd
    ;; connection timed out; no servers could be reached
    (base) 
    # mint @ mint-virtual-machine in ~ [14:41:48] C:9
    $ dig @114.114.114.114 +notrace www.baidu.com
    
    
    ; <<>> DiG 9.11.3-1ubuntu1.15-Ubuntu <<>> @114.114.114.114 +notrace www.baidu.com
    ; (1 server found)
    ;; global options: +cmd
    ;; connection timed out; no servers could be reached
    

    不指定的话显示是从 127.0.0.53 获取的解析记录,但是不指定的情况下+trace 参数失效。

    (base) 
    # mint @ mint-virtual-machine in ~ [14:42:38] C:9
    $ dig  www.baidu.com 
    
    
    ; <<>> DiG 9.11.3-1ubuntu1.15-Ubuntu <<>> www.baidu.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6883
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 65494
    ;; QUESTION SECTION:
    ;www.baidu.com.			IN	A
    
    ;; ANSWER SECTION:
    www.baidu.com.		5	IN	CNAME	www.a.shifen.com.
    www.a.shifen.com.	4	IN	A	220.181.38.150
    www.a.shifen.com.	4	IN	A	220.181.38.149
    
    ;; Query time: 331 msec
    ;; SERVER: 127.0.0.53#53(127.0.0.53)
    ;; WHEN: Thu Jan 20 14:42:53 CST 2022
    ;; MSG SIZE  rcvd: 101
    
    (base) 
    # mint @ mint-virtual-machine in ~ [14:42:53] 
    $ dig +trace www.baidu.com
    
    
    ; <<>> DiG 9.11.3-1ubuntu1.15-Ubuntu <<>> +trace www.baidu.com
    ;; global options: +cmd
    ;; Received 51 bytes from 127.0.0.53#53(127.0.0.53) in 0 ms
    
    
    
    1 条回复    2022-01-20 19:08:41 +08:00
    liuxu
        1
    liuxu  
       2022-01-20 19:08:41 +08:00
    内部和外部用 tcpdump 抓个 53 的包看看
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   919 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:10 · PVG 05:10 · LAX 14:10 · JFK 17:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.