Skip to content

Commit b5ca06f

Browse files
committed
bugfix for headscale
1 parent 179986e commit b5ca06f

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

tailscale/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ARG BUILD_ARCH=amd64
1010
ARG TAILSCALE_VERSION="v1.80.0"
1111
RUN \
1212
apk add --no-cache \
13+
bind-tools=9.18.33-r0 \
1314
dnsmasq=2.90-r3 \
1415
ethtool=6.11-r0 \
1516
ipcalc=1.0.3-r0 \

tailscale/rootfs/etc/s6-overlay/s6-rc.d/dnsmasq/run

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,38 @@
77

88
readonly DNSMASQ_ADDRESS=127.52.52.52
99

10+
declare hostname
11+
declare -a addresses=()
12+
declare host_record=
13+
1014
bashio::log.info "Starting dnsmasq..."
1115

12-
# This is a dummy DNS to suppress tailscaled warnings about not configured upstream on each DNS query
13-
# It answers REFUSED for everything
16+
# Resolve login_server
17+
if bashio::config.has_value "login_server"; then
18+
# We have to be able to resolve this address
19+
if ! hostname=$(awk -F[/:] '{print $4}' <<<$(bashio::config "login_server")) || \
20+
! bashio::var.has_value "${hostname}"
21+
then
22+
bashio::log.error "Determining host name from '$(bashio::config "login_server")' has failed"
23+
bashio::exit.nok
24+
fi
25+
if ! readarray -t addresses < <(dig ${hostname} A ${hostname} AAAA +short) || \
26+
(( 0 == ${#addresses[@]} ))
27+
then
28+
bashio::log.error "Resolving '${hostname}' has failed"
29+
bashio::exit.nok
30+
fi
31+
else
32+
# This is a best effort, if we fail, let tailscale use it's derp servers as fallback bootstrap DNS servers
33+
hostname="controlplane.tailscale.com"
34+
readarray -t addresses < <(dig ${hostname} A ${hostname} AAAA +short) || true
35+
fi
36+
if (( 0 < ${#addresses[@]} )); then
37+
host_record="--host-record=${hostname}$(printf ",%s" "${addresses[@]}"),0"
38+
fi
39+
40+
# This is a dummy DNS to provide bootstrap DNS resolution for the login_server option, otherwise answers REFUSED for everything
41+
# It is also required to suppress tailscaled warnings about not configured upstream on each DNS query
1442
# It must run on port 53 to be able to specify it in a resolv.conf
1543
echo "nameserver ${DNSMASQ_ADDRESS}" > /etc/resolv.dnsmasq.conf
16-
exec dnsmasq --no-hosts --no-resolv --keep-in-foreground --log-facility='-' --listen-address=${DNSMASQ_ADDRESS} --port=53 --bind-interfaces
44+
exec dnsmasq --no-hosts --no-resolv --keep-in-foreground --log-facility='-' --listen-address=${DNSMASQ_ADDRESS} --port=53 --bind-interfaces ${host_record}

0 commit comments

Comments
 (0)