From c86aa922fc4823f264775444a2a245e7285d8fa3 Mon Sep 17 00:00:00 2001 From: Till Riedel Date: Wed, 13 Mar 2024 22:59:54 +0100 Subject: [PATCH] allow binding particularly link-local addresses (using a scope/zone) also as a side effect allows using hostnames --- plugin/bind/README.md | 2 +- plugin/bind/setup.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/bind/README.md b/plugin/bind/README.md index 1c0f0c5f9dc7..0d595efecb52 100644 --- a/plugin/bind/README.md +++ b/plugin/bind/README.md @@ -11,7 +11,7 @@ another IP instead. If several addresses are provided, a listener will be open on each of the IP provided. -Each address has to be an IP or name of one of the interfaces of the host. Bind by interface name, binds to the IPs on that interface at the time of startup or reload (reload will happen with a SIGHUP or if the config file changes). +Each address has to be an IP, a host name (not recommended as it resolves to at most one IP) or name of one of the interfaces of the host. Bind by interface name, binds to the IPs on that interface at the time of startup or reload (reload will happen with a SIGHUP or if the config file changes). If the given argument is an interface name, and that interface has several IP addresses, CoreDNS will listen on all of the interface IP addresses (including IPv4 and IPv6), except for IPv6 link-local addresses on that interface. diff --git a/plugin/bind/setup.go b/plugin/bind/setup.go index 1bd39758561a..cddad0db3bb7 100644 --- a/plugin/bind/setup.go +++ b/plugin/bind/setup.go @@ -92,7 +92,8 @@ func listIP(args []string, ifaces []net.Interface) ([]string, error) { } } if !isIface { - if net.ParseIP(a) == nil { + _, err := net.ResolveIPAddr("ip", a) + if err != nil { return nil, fmt.Errorf("not a valid IP address or interface name: %q", a) } all = append(all, a)