Skip to content

Commit

Permalink
Use spec.ip as default listen address for bosh-dns-windows
Browse files Browse the repository at this point in the history
In 1.18 the default listen address was changed to 127.0.0.1 so the dns
server would only be available locally on each VM, to match the default
behaviour on linux. When two non-loopback non-tunnel network interfaces
are present bosh-dns-windows failed to start due to how the
implementation of `windows_manager.go` tries to identify the "primary"
adapter by matching the IP address.

[#171637356](https://www.pivotaltracker.com/story/show/171637356)
  • Loading branch information
cjnosal committed Mar 5, 2020
1 parent ef542b0 commit a7fb83e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions jobs/acceptance-tests-windows/templates/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go.exe install bosh-dns/vendor/github.com/onsi/ginkgo/ginkgo

Push-Location "${env:GOPATH}\src\bosh-dns\acceptance_tests\windows"

$env:LOCAL_IP_ADDRESS = "<%= spec.ip %>"
ginkgo -randomizeAllSpecs -randomizeSuites -race <%= p('suites') %>

Pop-Location
Expand Down
2 changes: 1 addition & 1 deletion jobs/bosh-dns-windows/monit
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if p('override_nameserver')
name: "bosh-dns-nameserverconfig-windows",
executable: "/var/vcap/packages/bosh-dns-windows/bin/bosh-dns-nameserverconfig.exe",

args: ["--bindAddress", p('address') == "0.0.0.0" ? "127.0.0.1" : p('address')]
args: ["--bindAddress", p('address', spec.ip) == "0.0.0.0" ? "127.0.0.1" : p('address', spec.ip)]
}
end

Expand Down
2 changes: 0 additions & 2 deletions jobs/bosh-dns-windows/spec
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ packages:
properties:
address:
description: "Address in which the DNS server will bind"
default: 127.0.0.1
aliased_address:
description: "Address that will be added by default"
default: 127.0.0.1
addresses_files_glob:
description: "Glob for any files to look for extra addresses to listen on"
default: C:\var\vcap\jobs\*\dns\addresses.json
Expand Down
2 changes: 1 addition & 1 deletion jobs/bosh-dns-windows/templates/config.json.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%=
{
address: p('address'),
address: p('address', spec.ip),
port: p('port'),
log_level: p('log_level'),
recursors: p('recursors'),
Expand Down
15 changes: 12 additions & 3 deletions src/bosh-dns/acceptance_tests/windows/windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package windows_test

import (
"fmt"
"os"
"os/exec"
"time"

Expand All @@ -14,6 +15,14 @@ import (
)

var _ = Describe("windows tests", func() {
var localIP string

BeforeEach(func() {
var present bool
localIP, present = os.LookupEnv("LOCAL_IP_ADDRESS")
Expect(present).To(BeTrue(), "LOCAL_IP_ADDRESS environment variable not set")
Expect(localIP).NotTo(BeEmpty(), "LOCAL_IP_ADDRESS environment variable not set")
})

It("should bind to tcp and udp", func() {
cmd := exec.Command("powershell.exe", "-Command", "netstat -na | findstr :53")
Expand All @@ -22,12 +31,12 @@ var _ = Describe("windows tests", func() {
Expect(err).NotTo(HaveOccurred())

Eventually(session, 10*time.Second).Should(gexec.Exit(0))
Expect(session.Out.Contents()).To(ContainSubstring(fmt.Sprintf("TCP 127.0.0.1:53")))
Expect(session.Out.Contents()).To(ContainSubstring(fmt.Sprintf("UDP 127.0.0.1:53")))
Expect(session.Out.Contents()).To(ContainSubstring(fmt.Sprintf("TCP %s:53", localIP)))
Expect(session.Out.Contents()).To(ContainSubstring(fmt.Sprintf("UDP %s:53", localIP)))
})

It("should respond to dns queries", func() {
cmd := exec.Command("powershell.exe", "-Command", fmt.Sprintf("Resolve-DnsName -DnsOnly -Name upcheck.bosh-dns. -Server 127.0.0.1 | Format-list"))
cmd := exec.Command("powershell.exe", "-Command", fmt.Sprintf("Resolve-DnsName -DnsOnly -Name upcheck.bosh-dns. -Server %s | Format-list", localIP))
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())

Expand Down

0 comments on commit a7fb83e

Please sign in to comment.