aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mohammad Yosefpor <47300215+m-yosefpor@users.noreply.github.com> 2021-03-18 13:24:57 +0330
committerGravatar GitHub <noreply@github.com> 2021-03-18 10:54:57 +0100
commitdeb09c8905dbb00b47dbe873a296897558506f7c (patch)
treeb631e74ad7ca7eac1d28ed40df90f9ba6fa1c96a
parent1b2f0bef6f3716d798d8e8cfcaa8bc55a103b2aa (diff)
downloadcoredns-deb09c8905dbb00b47dbe873a296897558506f7c.tar.gz
coredns-deb09c8905dbb00b47dbe873a296897558506f7c.tar.zst
coredns-deb09c8905dbb00b47dbe873a296897558506f7c.zip
plugin/bind: Discard link-local addresses on binding by interface name (#4531)
* Discard link-local addresses on binding Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * Update plugin/bind: README.md Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * Except for IPv6 link-local only Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com>
-rw-r--r--plugin/bind/README.md2
-rw-r--r--plugin/bind/setup.go4
2 files changed, 4 insertions, 2 deletions
diff --git a/plugin/bind/README.md b/plugin/bind/README.md
index 6ff3fb888..e3274d3d5 100644
--- a/plugin/bind/README.md
+++ b/plugin/bind/README.md
@@ -13,7 +13,7 @@ If several addresses are provided, a listener will be open on each of the IP pro
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).
-If the given argument is an interface name, and that interface has serveral IP addresses, CoreDNS will listen on all of the interface IP addresses (including IPv4 and IPv6).
+If the given argument is an interface name, and that interface has serveral 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.
## Syntax
diff --git a/plugin/bind/setup.go b/plugin/bind/setup.go
index afca06097..b2a37551c 100644
--- a/plugin/bind/setup.go
+++ b/plugin/bind/setup.go
@@ -37,7 +37,9 @@ func setup(c *caddy.Controller) error {
}
for _, addr := range addrs {
if ipnet, ok := addr.(*net.IPNet); ok {
- all = append(all, ipnet.IP.String())
+ if ipnet.IP.To4() != nil || (!ipnet.IP.IsLinkLocalMulticast() && !ipnet.IP.IsLinkLocalUnicast()) {
+ all = append(all, ipnet.IP.String())
+ }
}
}
}