Skip to content

Instantly share code, notes, and snippets.

@steigr
Last active April 18, 2016 18:47
Show Gist options
  • Save steigr/d58e03a3d0d3b0dfff5e824a3a85e503 to your computer and use it in GitHub Desktop.
Save steigr/d58e03a3d0d3b0dfff5e824a3a85e503 to your computer and use it in GitHub Desktop.
Check if DNS Server is link local and wait up to 60s to become reachable
#!/bin/sh
link_local_dns() {
sed -e '/^[[:space:]]*nameserver/!d' \
-e 's/^[[:space:]]*nameserver[[:space:]]*\(169\.254\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/' \
/etc/resolv.conf
}
dns_reachable() { link_local_dns | xargs -n1 arping -q -f -c 60; }
[[ "$(link_local_dns)" ]] && dns_reachable
RUN curl -sL https://gist.github.com/steigr/d58e03a3d0d3b0dfff5e824a3a85e503/raw/dns-resilience | install -m 0755 -o root -g root /dev/stdin /usr/bin/dns-resilience
RUN wget -qO- https://gist.github.com/steigr/d58e03a3d0d3b0dfff5e824a3a85e503/raw/dns-resilience | install -m 0755 -o root -g root /dev/stdin /usr/bin/dns-resilience
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment