Created
July 9, 2025 15:19
-
-
Save NiceRath/343dddf4c2a0f2fe565de33e4b7ef29f to your computer and use it in GitHub Desktop.
IPv4 vs IPv6 HTTP Speedtest Script (to CSV)
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
set -eo pipefail | |
if [[ -z "$2" ]] | |
then | |
echo 'USAGE:' | |
echo ' 1 > Domain to target (without www)' | |
echo ' 2 > Number of requests' | |
echo '' | |
echo 'OPTIONAL ENV-VARS:' | |
echo ' CURL_INT > Interface to use' | |
exit 1 | |
fi | |
if [[ -n "$CURL_INT" ]] | |
then | |
CURL_INT="--interface ${CURL_INT}" | |
else | |
CURL_INT='' | |
fi | |
set -u | |
DOMAIN="www.$1" | |
COUNT="$2" | |
UA='User-Agent: Speedtest' | |
LOG_FILE_IP4="/tmp/speedtest_ip4.csv" | |
LOG_FILE_IP6="/tmp/speedtest_ip6.csv" | |
COLUMNS='time_connect,time_appconnect,time_total' | |
echo "$COLUMNS" > "$LOG_FILE_IP4" | |
echo "$COLUMNS" > "$LOG_FILE_IP6" | |
if ! curl -H "${UA}" $CURL_INT --ipv6 -o /dev/null https://google.com 2>/dev/null | |
then | |
echo 'ERROR: Curl not found or client has no IPv6 address' | |
exit 1 | |
fi | |
if ! host "$DOMAIN" | grep -q 'IPv6' | |
then | |
echo 'ERROR: Target has no IPv6 Address' | |
exit 1 | |
fi | |
for i in $(seq "$COUNT") | |
do | |
echo "$i" | |
curl -H "${UA}" $CURL_INT --ipv4 -o /dev/null -w '%{time_connect},%{time_appconnect},%{time_total}\n' "https://${DOMAIN}" 2>/dev/null >> "$LOG_FILE_IP4" | |
sleep 1 | |
curl -H "${UA}" $CURL_INT --ipv6 -o /dev/null -w '%{time_connect},%{time_appconnect},%{time_total}\n' "https://${DOMAIN}" 2>/dev/null >> "$LOG_FILE_IP6" | |
sleep 1 | |
done | |
echo "LOG IPv4: $LOG_FILE_IP4" | |
echo "LOG IPv6: $LOG_FILE_IP6" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment