Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin/bind: allow binding particularly link-local addresses (using a scope/zone) #6551

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin/bind/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion plugin/bind/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions plugin/bind/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestSetup(t *testing.T) {
{`bind ::1 1.2.3.4 ::5 127.9.9.0 noone`, nil, true},
{`bind 1.2.3.4 lo`, []string{"1.2.3.4", "127.0.0.1", "::1"}, false},
{"bind lo {\nexcept 127.0.0.1\n}\n", []string{"::1"}, false},
{"bind localhost", []string{"127.0.0.1"}, false},
} {
c := caddy.NewTestController("dns", test.config)
err := setup(c)
Expand Down