Skip to content

Instantly share code, notes, and snippets.

@satmandu
Created January 17, 2023 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satmandu/a4e3b4bb5ce411b644bb59aecfe4dccc to your computer and use it in GitHub Desktop.
Save satmandu/a4e3b4bb5ce411b644bb59aecfe4dccc to your computer and use it in GitHub Desktop.
Bounce IPv6 connection if router is up but IPv6 connectivity is down, and check the connection every 30 seconds.
#!/bin/bash
# Put this script into your crontab e.g.
# @reboot ~/bin/bounce_ipv6.sh
# Bounce IPv6 connection if router is up but IPv6 connectivity is down,
# and check the connection every 30 seconds.
router_address="192.168.0.1"
ipvsixaddress="2600::"
while true;
do
if ping -c1 $router_address &>/dev/null; then
if ping -c1 $ipvsixaddress &>/dev/null; then
:
else
echo "Resetting ipv6 connection..."
primary_connection=$(nmcli -t -f UUID con | head -n 1)
sudo nmcli connection modify "$primary_connection" ipv6.method "disabled"
sudo nmcli connection up "$primary_connection"
sudo nmcli connection modify "$primary_connection" ipv6.method "auto"
sudo nmcli connection up "$primary_connection"
fi
fi
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment