dongxing2263 2017-03-18 02:05
浏览 195

Golang DNS解析不起作用

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条回答 默认 最新

  • doufei2007 2017-03-18 02:19
    关注

    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.
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料