diff --git a/consul/util.go b/consul/util.go index 87a6dc6d4..cd0f86dc2 100644 --- a/consul/util.go +++ b/consul/util.go @@ -178,6 +178,7 @@ func isPrivateIP(ip_str string) bool { // Returns addresses from interfaces that is up func activeInterfaceAddresses() ([]net.Addr, error) { var upAddrs []net.Addr + var loAddrs []net.Addr interfaces, err := net.Interfaces() if err != nil { @@ -195,9 +196,18 @@ func activeInterfaceAddresses() ([]net.Addr, error) { return nil, fmt.Errorf("Failed to get interface addresses: %v", err) } + if iface.Flags&net.FlagLoopback != 0 { + loAddrs = append(loAddrs, addresses...) + continue + } + upAddrs = append(upAddrs, addresses...) } + if len(upAddrs) == 0 { + return loAddrs, nil + } + return upAddrs, nil }