Skip to content

Commit

Permalink
Add DNS resolution checks (fix haugene#1608) (haugene#1617)
Browse files Browse the repository at this point in the history
* Add dns resolution test to healthcheck script

* Add dns resolution test to start script

Co-authored-by: Patrick Kishino <[email protected]>
  • Loading branch information
2 people authored and steveneighbour committed Apr 17, 2021
1 parent d95317b commit f0eb1d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions openvpn/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ if compgen -e | grep -q "OVERRIDE_DNS"; then
done
fi

# Test DNS resolution
if ! nslookup ${HEALTH_CHECK_HOST:-"google.com"} 1>/dev/null 2>&1; then
echo "WARNING: initial DNS resolution test failed"
fi

# If create_tun_device is set, create /dev/net/tun
if [[ "${CREATE_TUN_DEVICE,,}" == "true" ]]; then
echo "Creating TUN device /dev/net/tun"
Expand Down
9 changes: 9 additions & 0 deletions scripts/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ then
HOST="google.com"
fi

# Check DNS resolution works
nslookup $HOST > /dev/null
STATUS=$?
if [[ ${STATUS} -ne 0 ]]
then
echo "DNS resolution failed"
exit 1
fi

ping -c 2 -w 10 $HOST # Get at least 2 responses and timeout after 10 seconds
STATUS=$?
if [[ ${STATUS} -ne 0 ]]
Expand Down

0 comments on commit f0eb1d3

Please sign in to comment.