New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: LookupAddr returns a zero length slice when looking up its own IP address on a Windows DNS server #29600

Open
jftuga opened this Issue Jan 7, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@jftuga
Copy link

jftuga commented Jan 7, 2019

What version of Go are you using (go version)?

go version go1.11.4 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\jftuga\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\jftuga\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\jftuga\AppData\Local\Temp\go-build308914574=/tmp/go-build -gno-record-gcc-switches

What did you do?

// dnstest.go
package main
import "fmt"
import "net"
import "os"

func main() {
    	ip := os.Args[1]
    	fmt.Println("LookupAddr on ", ip)
    	addresses, err := net.LookupAddr(ip)
        if err != nil {
    		fmt.Println("error:", err)
    		return
        }
    	if len(addresses) == 0 {
    		fmt.Printf("error: addresses has a length of zero")
    		return
    	}
    	fmt.Println("results:",addresses)
}
192.168.1.2 is a Active Directory server running DNS
This program is running on 192.168.1.2 and the bug is only seen in this situation.

What did you expect to see?

  • Windows Server 2008 R2 Enterprise

  • Windows Server 2016 Enterprise

  • 192.168.1.2 is a Active Directory server running DNS

    dnstest.exe 192.168.1.2
    LookupAddr on 192.168.1.2
    results: [dns1.example.com.]

What did you see instead?

If I run this program on the DNS server itself, this is the result:

dnstest.exe 192.168.1.2
LookupAddr on  192.168.1.2
error: addresses has a length of zero

This problem only occurs when:

1. Windows OS, this does not occur under Linux
2. This program is running on the DNS server itself
3. It is looking up it's own IP address

In essence, this program does not return any hostnames when looking up it's own IP address when running on a DNS server under Windows. Instead, it returns a zero length slice. In this situation, err is nil.

Can someone else reproduce this?

Also, should err be set when len(addresses) == 0?

@julieqiu julieqiu changed the title net.LookupAddr returns a zero length slice when looking up it's own IP address on a Windows DNS server net: net.LookupAddr returns a zero length slice when looking up it's own IP address on a Windows DNS server Jan 8, 2019

@julieqiu julieqiu changed the title net: net.LookupAddr returns a zero length slice when looking up it's own IP address on a Windows DNS server net: LookupAddr returns a zero length slice when looking up it's own IP address on a Windows DNS server Jan 8, 2019

@julieqiu

This comment has been minimized.

Copy link

julieqiu commented Jan 8, 2019

@bradfitz bradfitz changed the title net: LookupAddr returns a zero length slice when looking up it's own IP address on a Windows DNS server net: LookupAddr returns a zero length slice when looking up its own IP address on a Windows DNS server Jan 8, 2019

@bradfitz bradfitz added the OS-Windows label Jan 8, 2019

@bradfitz bradfitz added this to the Go1.13 milestone Jan 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment