为了账号安全,请及时绑定邮箱和手机立即绑定

通过 Cisco IPSec 连接时,应用程序无法解析内部 DNS 条目

通过 Cisco IPSec 连接时,应用程序无法解析内部 DNS 条目

Go
SMILET 2022-01-10 10:31:23
我使用 Cisco IPsec 连接到我的工作场所 VPN。我使用 OS X 的本机 Cisco IPSec 客户端进行连接。我们有一个内部 DNS 服务器,用于保存内部站点的记录,例如scotty.infinidat.com. 使用 curl 联系内部站点按预期工作。使用以下 Python 代码也可以:import requestsresp = requests.get("http://www.google.com")resp.raise_for_status()resp = requests.get("http://scotty.infinidat.com")resp.raise_for_status()但是,尝试在 Go 中实现等价物失败:包主import (    "fmt"    "net/http")func main() {    _, err := http.Get("http://google.com/") // This works    if err != nil {        panic(fmt.Sprintf("Error contacting Google: %s", err))    }    _, err = http.Get("http://scotty.infinidat.com/") // This doesn't    if err != nil {        panic(fmt.Sprintf("Error contacting an internal site: %s", err))    }}在连接到 VPN 时运行上述程序会产生以下输出:panic: Error contacting internal site: Get http://scotty.infinidat.com/: dial tcp: lookup scotty.infinidat.com on 10.135.1.1:53: no such hostgoroutine 1 [running]:panic(0x290ca0, 0xc82010a490)        /usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6main.main()        /Users/roeyd/src/go/src/webtest/main.go:16 +0x2af其中 10.135.1.1 是我本地网络的 DNS 服务器。据我了解,纯 Go DNS 解析器在 OS X 上不可用。通过设置强制 Go 使用 cgo DNS 解析器GODEBUG=netdns=cgo没有任何区别。
查看完整描述

2 回答

?
森林海

TA贡献2011条经验 获得超2个赞

可能您已经这样做了,但是从我这边执行时dig scotty.infinidat.com我没有记录(与您的结果匹配):


$ dig scotty.infinidat.com


; <<>> DiG 9.8.3-P1 <<>> scotty.infinidat.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 53313

;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0


;; QUESTION SECTION:

;scotty.infinidat.com.          IN      A


;; AUTHORITY SECTION:

infinidat.com.          155     IN      SOA     ns1.dnsimple.com. admin.dnsimple.com. 1438782431 86400 7200 604800 300


;; Query time: 234 msec

;; SERVER: 10.132.0.1#53(10.132.0.1)

;; WHEN: Sun Jul 30 21:37:14 2017

;; MSG SIZE  rcvd: 93

因此,如果 forwww.google.com工作正常,那么更改可能与您的 DNS/ZONE 更相关。


查看完整回答
反对 回复 2022-01-10
?
大话西游666

TA贡献1817条经验 获得超14个赞

或许你可以先用一个完整的DNS库来解析IP:


 package main


 import (

    "log"


    "github.com/miekg/dns"

 )


 func main() {

    c := dns.Client{}

    m := dns.Msg{}

    m.SetQuestion("scotty.infinidat.com.", dns.TypeA)

    r, t, err := c.Exchange(&m, "10.135.1.1:53")

    if err != nil {

        log.Fatal(err)

    }

    log.Printf("Took %v", t)

    for _, ans := range r.Answer {

        Arecord := ans.(*dns.A)

        log.Printf("%s", Arecord.A)

    }

 }


查看完整回答
反对 回复 2022-01-10
  • 2 回答
  • 0 关注
  • 374 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号