networking - Golang DNS 解析不起作用

标签 networking go dns network-programming

我已经阅读了很多书,但我就是找不到解决方案。

我在谷歌云中打开了一个 VPS,用 Ubuntu 启动了一个实例,并运行了一个我用 Go 编写的网络服务器,在端口 80 监听。我还在我的国家注册了一个域名 www.crosslogic.com.ar ,委托(delegate)如下这个:

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。

我在 dns.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 是我需要在我的服务器中配置的东西吗? http/net 不应该处理这些东西吗?为什么请求没有到达我的 80 端口?

最佳答案

问题与您的代码无关。您的 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.

关于networking - Golang DNS 解析不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42869683/

相关文章:

c# - 自动获取服务器IP给客户端

reflection - 如何通过 reflect.Value 获取 slice 底层值

http - 如果 ".com"之后有一个点,它是一个有效的 URL 吗?

encryption - 创建 CLI : What should I do with the password in the config file (and how)?

azure - 我可以为我不拥有的域添加主机名到我的网站吗?

dns - 如何使用相同的 TXT 和 CNAME 为 Mailgun 配置 DNS?

mysql - 如何从远程计算机(不是本地主机)访问MySQL?

android - 如何使用 NetworkRequest.Builder().setNetworkSpecifier(string) 指定 wifi 网络

c++ - 如何使用C++标准库网络TS在服务器和客户端之间发送消息

Go: map 相关错误