Golang DNS解析不起作用

huangapple go评论96阅读模式
英文:

Golang DNS resolution not working

问题

我一直在阅读,但就是找不到解决办法。

我在Google Cloud上打开了一个VPS,在Ubuntu上启动了一个实例,并运行了一个我用Go编写的Web服务器,监听在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上进行了测试,检查了以下错误:

- 由您的域名服务器报告的缺少名称服务器。您应该已经知道您的域名服务器上的NS记录缺失,所以这里再次提醒您:
ns2.crosslogic.com.ar.
ns1.crosslogic.com.ar.

- 没有有效的SOA记录返回!

- 错误:我无法获取www.crosslogic.com.ar的任何A记录!
(我只进行缓存请求,如果您最近添加了WWW A记录,可能不会显示在这里。)

这是代码:

package main

import (
	"net/http"
)

func main() {
	// 生成一个包含计算详情的HTML。


	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端口?

英文:

I'be been reading a lot but I just can't find a solution.

I opened a VPS in Google Cloud, started an instance with Ubuntu and runned a web server i've written in Go listening in port 80. I also registered a domain in my country www.crosslogic.com.ar which delegated like this:

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

(Two were required but I only had one IP)

When I type the IP in the browser everything everything works fine, but when I try to reach the server using www.crosslogic.com.ar, or crosslogic.com.ar, or n1.crosslogic.com.ar I get ERR_NAME_RESOLUTION_FAILED.

I did this test intodns.com/crosslogic.com.ar to check the folowing errors:

-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.) 

This is the code:

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)
	}
}

Am I missing any configuration in Linux? Those NS Records, A records and SOA is something I need to configure in my server? Shoudln't http/net be handling this stuff? Why request don't reach my port 80?

答案1

得分: 1

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

$ nslookup n1.crosslogic.com.ar

DNS请求超时。
    超时时间为2秒。
DNS请求超时。
    超时时间为2秒。
DNS请求超时。
    超时时间为2秒。
DNS请求超时。
    超时时间为2秒。

$ nslookup n2.crosslogic.com.ar

DNS请求超时。
    超时时间为2秒。
DNS请求超时。
    超时时间为2秒。
DNS请求超时。
    超时时间为2秒。
DNS请求超时。
    超时时间为2秒。
英文:

The problem has nothing to do with your code. Your DNS is not registered properly. When running nslookup I get the following:

$ 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.

huangapple
  • 本文由 发表于 2017年3月18日 10:05:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/42869683.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定