I use Cisco IPsec to connect to my workplace VPN. I connect using OS X's native Cisco IPSec client. We have an internal DNS server that holds records for internal sites, such as scotty.infinidat.com
. Using curl to contact an internal site works as expected. Using the following Python code also works:
import requests
resp = requests.get("http://www.google.com")
resp.raise_for_status()
resp = requests.get("http://scotty.infinidat.com")
resp.raise_for_status()
However, trying to implement an equivalent in Go fails:
package main
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))
}
}
Running the program above while connected to the VPN yields the following output:
panic: Error contacting internal site: Get http://scotty.infinidat.com/: dial tcp: lookup scotty.infinidat.com on 10.135.1.1:53: no such host
goroutine 1 [running]:
panic(0x290ca0, 0xc82010a490)
/usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6
main.main()
/Users/roeyd/src/go/src/webtest/main.go:16 +0x2af
Where 10.135.1.1 is my local network's DNS server. To my understanding the pure Go DNS resolver isn't available on OS X. Forcing Go to use the cgo DNS resolver by setting GODEBUG=netdns=cgo
doesn't make any difference.