-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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