Skip to content

Instantly share code, notes, and snippets.

@awsvpc
Forked from satmandu/bounce_ipv6.sh
Created May 3, 2025 04:16
Show Gist options
  • Save awsvpc/df4f6aa10c8f4dbc297622f77d348153 to your computer and use it in GitHub Desktop.
Save awsvpc/df4f6aa10c8f4dbc297622f77d348153 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