fix(plugin/bind): remove zone for link-local IPv4 (#7295)

This fixes a bug introduced in
https://github.com/coredns/coredns/pull/6547 which resulted in the zone
being added to IPv4 addresses.  This bug results in a failure to start
when binding to an interface with a link-local IPv4 address assigned to
it, with the following error:

    $ ./coredns -conf=/etc/coredns/Corefile
    maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined
    lookup 169.254.1.1%dummy0: no such host

Signed-off-by: Mark Mickan <mark.mickan@openlms.net>
Co-authored-by: Mark Mickan <mark.mickan@openlms.net>
This commit is contained in:
Mark Mickan 2025-05-20 22:37:46 +09:30 committed by GitHub
parent 7045098d6b
commit 1de92ec9dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,7 +85,7 @@ func listIP(args []string, ifaces []net.Interface) ([]string, error) {
if ipnet, ok := addr.(*net.IPNet); ok {
ipa, err := net.ResolveIPAddr("ip", ipnet.IP.String())
if err == nil {
if len(ipnet.IP) == net.IPv6len &&
if ipnet.IP.To4() == nil &&
(ipnet.IP.IsLinkLocalMulticast() || ipnet.IP.IsLinkLocalUnicast()) {
if ipa.Zone == "" {
ipa.Zone = iface.Name