Golang DNS解析无法正常工作

时间:2017-03-18 02:05:09

标签: networking go dns network-programming

我已经阅读了很多,但我无法找到解决方案。

我在Google Cloud中打开了一个VPS,用Ubuntu启动了一个实例并运行了一个我在Go端口用80写的网络服务器。我还在我的国家注册了一个域名www.crosslogic.com.ar委托这样:

n1.crosslogic.com.ar    130.211.196.55
n2.crosslogic.com.ar    130.211.196.55

(两个是必需的,但我只有一个IP)

当我在浏览器中输入IP时,一切正常,但当我尝试使用www.crosslogic.com.ar,或crosslogic.com.ar或n1.crosslogic.com.ar到达服务器时,我得到了ERR_NAME_RESOLUTION_FAILED。

我做了这个测试intodns.com/crosslogic.com.ar来检查以下错误:

-Missing nameservers reported by your nameservers. You should already know that your NS records at your nameservers are missing, so here it is again:
ns2.crosslogic.com.ar.
ns1.crosslogic.com.ar.

-No valid SOA record came back!

-ERROR: I could not get any A records for www.crosslogic.com.ar!
(I only do a cache request, if you recently added a WWW A record, it might not show up here.) 

这是代码:

package main

import (
    "net/http"
)

func main() {
    // Genero un html con los detalles del calculo.


    http.HandleFunc("/", indexHandler)
    err := http.ListenAndServe(":80", nil)
    if err != nil {
        fmt.Println(err.Error())
    }

}

func indexHandler(w http.ResponseWriter, r *http.Request) {

    temp, err := template.ParseFiles("index.html")
    if err != nil {
        panic(err)
    }

    err = temp.Execute(w, nil)
    if err != nil {
        panic(err)
    }
}

我错过了Linux中的任何配置吗?那些NS记录,A记录和SOA是我需要在我的服务器中配置的东西吗? Shoudln的http / net处理这些东西?为什么请求不能到达我的80端口?

1 个答案:

答案 0 :(得分:1)

问题与您的代码无关。您的DNS未正确注册。运行nslookup时,我得到以下信息:

$ nslookup n1.crosslogic.com.ar

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.

$ nslookup n2.crosslogic.com.ar

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.