From f1c3fecfb25224e3a8a700db57fa71b80254fe19 Mon Sep 17 00:00:00 2001 From: rpassmore Date: Sat, 19 Jan 2019 01:41:43 +0000 Subject: [PATCH] Allow configuring IP address the DNS server binds to (#552) Closes #550. --- config.go | 6 ++++-- dns.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index f759ff4a..b159c8d7 100644 --- a/config.go +++ b/config.go @@ -41,7 +41,8 @@ type configuration struct { // field ordering is important -- yaml fields will mirror ordering from here type dnsConfig struct { - Port int `yaml:"port"` + BindHost string `yaml:"bind_host"` + Port int `yaml:"port"` dnsforward.FilteringConfig `yaml:",inline"` @@ -56,7 +57,8 @@ var config = configuration{ BindPort: 3000, BindHost: "127.0.0.1", DNS: dnsConfig{ - Port: 53, + BindHost: "0.0.0.0", + Port: 53, FilteringConfig: dnsforward.FilteringConfig{ ProtectionEnabled: true, // whether or not use any of dnsfilter features FilteringEnabled: true, // whether or not use filter lists diff --git a/dns.go b/dns.go index 6ad93d3c..31d89279 100644 --- a/dns.go +++ b/dns.go @@ -32,8 +32,8 @@ func generateServerConfig() dnsforward.ServerConfig { } newconfig := dnsforward.ServerConfig{ - UDPListenAddr: &net.UDPAddr{Port: config.DNS.Port}, - TCPListenAddr: &net.TCPAddr{Port: config.DNS.Port}, + UDPListenAddr: &net.UDPAddr{IP: net.ParseIP(config.DNS.BindHost), Port: config.DNS.Port}, + TCPListenAddr: &net.TCPAddr{IP: net.ParseIP(config.DNS.BindHost), Port: config.DNS.Port}, FilteringConfig: config.DNS.FilteringConfig, Filters: filters, }