Skip to content

Instantly share code, notes, and snippets.

@KyonLi
Created August 12, 2024 13:40
Show Gist options
  • Save KyonLi/43d02ae18e1527a4ec2cc92c26abc644 to your computer and use it in GitHub Desktop.
Save KyonLi/43d02ae18e1527a4ec2cc92c26abc644 to your computer and use it in GitHub Desktop.
log ipv6 disconnection
#!/bin/bash
TEST_URL="http://www.gstatic.com/generate_204"
TRACE_IP="2607:f130:0:ee::1"
STATUS=0
while true; do
result=$(curl -6 -sS -m 2 "$TEST_URL" 2>&1)
if [ $? -ne 0 ]; then
if [ $STATUS -eq 0 ]; then
STATUS=1
#echo "$(date -u): $result" >> curl.log
echo "$(date -u): ipv6 down" >> traceroute.log
traceroute6 -I -n $TRACE_IP 2>&1 >> traceroute.log
fi
else
if [ $STATUS -eq 1 ]; then
STATUS=0
echo "$(date -u): ipv6 restored" >> traceroute.log
echo '' >> traceroute.log
fi
fi
sleep 20s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment