diff --git a/README.md b/README.md
index edacc8b..4cee9cb 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ There are other environment variables if you want to customize various things in
| Variable | Default | Value | Description |
| -------- | ------- | ----- | ---------- |
| `ADMIN_EMAIL` | unset | email address | Set an administrative contact address for the Block Page |
-| `PIHOLE_DNS_` | `8.8.8.8;8.8.4.4` | IPs delimited by `;` | Upstream DNS server(s) for Pi-hole to forward queries to, seperated by a semicolon
(supports non-standard ports with `#[port number]`) e.g `127.0.0.1#5053;8.8.8.8;8.8.4.4` Note: The existence of this environment variable assumes this as the _sole_ management of upstream DNS. Upstream DNS added via the web interface will be overwritten on container restart/recreation |
+| `PIHOLE_DNS_` | `8.8.8.8;8.8.4.4` | IPs delimited by `;` | Upstream DNS server(s) for Pi-hole to forward queries to, seperated by a semicolon
(supports non-standard ports with `#[port number]`) e.g `127.0.0.1#5053;8.8.8.8;8.8.4.4`
(supports [Docker service names and links](https://docs.docker.com/compose/networking/) instead of IPs) e.g `upstream0;upstream1` where `upstream0` and `upstream1` are the service names of or links to docker services
Note: The existence of this environment variable assumes this as the _sole_ management of upstream DNS. Upstream DNS added via the web interface will be overwritten on container restart/recreation |
| `DNSSEC` | `false` | `<"true"\|"false">` | Enable DNSSEC support |
| `DNS_BOGUS_PRIV` | `true` |`<"true"\|"false">`| Never forward reverse lookups for private ranges |
| `DNS_FQDN_REQUIRED` | `true` | `<"true"\|"false">`| Never forward non-FQDNs |
diff --git a/start.sh b/start.sh
index ef8813c..d0b44c1 100755
--- a/start.sh
+++ b/start.sh
@@ -127,13 +127,29 @@ if [ -n "${PIHOLE_DNS_}" ]; then
change_setting "PIHOLE_DNS_$count" "$i"
((count=count+1))
((valid_entries=valid_entries+1))
- else
- echo "Invalid IP detected in PIHOLE_DNS_: ${i}"
+ continue
fi
+ if [ -n "$(dig +short ${i//#*/})" ]; then
+ # If the "address" is a domain (for example a docker link) then try to resolve it and add
+ # the result as a DNS server in setupVars.conf.
+ resolved_ip="$(dig +short ${i//#*/} | head -n 1)"
+ if [ -n "${i//*#/}" ] && [ "${i//*#/}" != "${i//#*/}" ]; then
+ resolved_ip="${resolved_ip}#${i//*#/}"
+ fi
+ echo "Resolved ${i} from PIHOLE_DNS_ as: ${resolved_ip}"
+ if valid_ip "$resolved_ip" || valid_ip6 "$resolved_ip" ; then
+ change_setting "PIHOLE_DNS_$count" "$resolved_ip"
+ ((count=count+1))
+ ((valid_entries=valid_entries+1))
+ continue
+ fi
+ fi
+ # If the above tests fail then this is an invalid DNS server
+ echo "Invalid entry detected in PIHOLE_DNS_: ${i}"
done
if [ $valid_entries -eq 0 ]; then
- echo "No Valid IPs dectected in PIHOLE_DNS_. Aborting"
+ echo "No Valid entries dectected in PIHOLE_DNS_. Aborting"
exit 1
fi
else