Skip to content

Instantly share code, notes, and snippets.

@dejavueakay
Created April 23, 2018 22:06
Show Gist options
  • Select an option

  • Save dejavueakay/e1d66c930404a6aafcf6c4bdc633f885 to your computer and use it in GitHub Desktop.

Select an option

Save dejavueakay/e1d66c930404a6aafcf6c4bdc633f885 to your computer and use it in GitHub Desktop.
check for IPv6 connectivity
#!/bin/bash
# Check for IPv6 Connectivity by looking for a IPv6 address
function check_ipv6() {
# Lets see if we got an IPv6, which in return means that we're live
IPv6=`curl -6 -s https://wtfismyip.com/text`
if [ $IPv6 ]
then
# OK IPv6 was found, return code 0 - OK
echo "OK - IPv6 connection ESTABLISHED. IP: $IPv6"
exit 0
else
# Error: IPv6 was not found, return code 2 - critical
echo "CRITICAL - no IPv6 connection ESTABLISHED. Output: $IPv6"
exit 1
fi
}
check_ipv6
eof
[Unit]
Description=IPv6 connectivity check
After=network-online.target
[Service]
ExecStart=/usr/local/bin/ipv6.sh
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment