Skip to content

Instantly share code, notes, and snippets.

@benoitjpnet
Last active August 29, 2015 14:02
Show Gist options
  • Save benoitjpnet/14cb46e4d97ca9071c27 to your computer and use it in GitHub Desktop.
Save benoitjpnet/14cb46e4d97ca9071c27 to your computer and use it in GitHub Desktop.
online IPv6 sucks :(
#!/bin/bash
# Relaunch dhclient when it crash...
mailaddr="[email protected]"
IPv6=true
pgrep -f dhclient6 > /dev/null
status=$?
if [[ $status != 0 ]]; then
IPv6=false
fi
ping6 -q -c1 free.fr > /dev/null
status=$?
if [[ $status != 0 ]]; then
IPv6=false
fi
if [[ $IPv6 == false ]]; then
echo "IPv6 not functional, relaunched dhclient6!" \
| mail -s "Dhclient for IPv6 relaunched on $(hostname -f)" $mailaddr
/sbin/ifdown eth0
pkill -9 -f dhclient6 > /dev/null
/sbin/ifup eth0
ping6 -q -c1 free.fr > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment