You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The intent of this block appears to be that for a non-dotted name (which presumably is the local hostname) the fallback should be performed to allow nss-myhostname to attempt resolution of the name as a local hostname.
Unfortunately many installations, including cloud-based hosts, use fully qualified domain names as their hostname. hostname(1) on Linux even says:
/etc/hostname Historically this file was supposed to only contain the hostname and not the full canonical FQDN. Nowadays most software is able to cope with a full FQDN here. This file is read at
boot time by the system initialization scripts to set the hostname.
It doesn't look like anywhere else in the Go resolver has special logic for handling the local hostname, so if your system hostname is an FQDN, go appears to bypass nss-myhostname. If your upstream DNS server cannot resolve the local hostname FQDN, and the hostname is not listed in /etc/hosts, then resolution will fail. But that's precisely what nss-myhostname was created to avoid, yet Go will ignore it.
Not sure what the best option here is, except that if myhostname is in nsswitch.conf, then either the Go resolver should attempt to do the mapping between local hostname and hostname internally, or it should pass the lookup off to netdns=cgo after trying its internal dns+files and getting failure from both of those?
The text was updated successfully, but these errors were encountered:
[fedora@ip-10-0-110-213 ~]$ hostname
ip-10-0-110-213.ec2.internal
[fedora@ip-10-0-110-213 ~]$ go version
go version go1.7.3 linux/amd64
[fedora@ip-10-0-110-213 ~]$ cat dig.go
package main
import "fmt"
import "net"
import "os"
func main() {
a, _ := net.LookupHost(os.Args[1])
fmt.Println(a)
}
[fedora@ip-10-0-110-213 ~]$ go run dig.go ip-10-0-110-213.ec2.internal
[]
[fedora@ip-10-0-110-213 ~]$ GODEBUG=netdns=cgo+1 go run dig.go ip-10-0-110-213.ec2.internal
go package net: using cgo DNS resolver
[fe80::10b8:58ff:feb4:cccc%eth0 10.0.110.213]
quentinmit
changed the title
net/conf.go::hostLookupOrder() should not ignore myhostname for dotted hostnames
net: myhostname nss module doesn't work if hostname contains dots
Nov 18, 2016
222 if src.source == "myhostname" {
223 if hostname == "" || hasDot {
224 continue
225 }
226 return fallbackOrder
227 }
The intent of this block appears to be that for a non-dotted name (which presumably is the local hostname) the fallback should be performed to allow nss-myhostname to attempt resolution of the name as a local hostname.
Unfortunately many installations, including cloud-based hosts, use fully qualified domain names as their hostname. hostname(1) on Linux even says:
It doesn't look like anywhere else in the Go resolver has special logic for handling the local hostname, so if your system hostname is an FQDN, go appears to bypass nss-myhostname. If your upstream DNS server cannot resolve the local hostname FQDN, and the hostname is not listed in /etc/hosts, then resolution will fail. But that's precisely what nss-myhostname was created to avoid, yet Go will ignore it.
Not sure what the best option here is, except that if myhostname is in nsswitch.conf, then either the Go resolver should attempt to do the mapping between local hostname and hostname internally, or it should pass the lookup off to netdns=cgo after trying its internal dns+files and getting failure from both of those?
The text was updated successfully, but these errors were encountered: