Make sure ping uses ipv4 when $TESTPROTO equals -4

The ping command on some systems will default to using ipv6 if a
hostname resolves to both ipv4 and ipv6 addresses.
This commit is contained in:
Aidan Harris 2020-11-15 12:32:22 +00:00
parent a6bfe2d4db
commit e36812903b
No known key found for this signature in database
GPG key ID: E18BE27807DA2E96
3 changed files with 21 additions and 6 deletions

View file

@ -114,9 +114,9 @@ start_pings() {
# Start Ping
if [ $TESTPROTO -eq "-4" ]
then
ping $PINGHOST > $PINGFILE &
"${PING4}" $PINGHOST > $PINGFILE &
else
ping6 $PINGHOST > $PINGFILE &
"${PING6}" $PINGHOST > $PINGFILE &
fi
ping_pid=$!
# echo "Ping PID: $ping_pid"
@ -186,6 +186,11 @@ measure_direction() {
# set an initial values for defaults
TESTHOST="netperf.bufferbloat.net"
TESTDUR="60"
PING4=ping
command -v ping4 > /dev/null 2>&1 && PING4=ping4
PING6=ping6
PINGHOST="gstatic.com"
MAXSESSIONS="5"
TESTPROTO="-4"

View file

@ -108,9 +108,9 @@ start_pings() {
# Start Ping
if [ $TESTPROTO -eq "-4" ]
then
ping $PINGHOST > $PINGFILE &
"${PING4}" $PINGHOST > $PINGFILE &
else
ping6 $PINGHOST > $PINGFILE &
"${PING6}" $PINGHOST > $PINGFILE &
fi
ping_pid=$!
# echo "Ping PID: $ping_pid"
@ -127,6 +127,11 @@ start_pings() {
# set an initial values for defaults
TESTDUR="60"
PING4=ping
command -v ping4 > /dev/null 2>&1 && PING4=ping4
PING6=ping6
PINGHOST="gstatic.com"
TESTPROTO="-4"

View file

@ -72,6 +72,11 @@ summarize_pings() {
# set an initial values for defaults
TESTHOST="netperf.bufferbloat.net"
TESTDUR="60"
PING4=ping
command -v ping4 > /dev/null 2>&1 && PING4=ping4
PING6=ping6
PINGHOST="gstatic.com"
MAXSESSIONS=4
TESTPROTO=-4
@ -132,9 +137,9 @@ echo "$DATE Testing $TESTHOST ($PROTO) with $MAXSESSIONS streams down and up whi
# Start Ping
if [ $TESTPROTO -eq "-4" ]
then
ping $PINGHOST > $PINGFILE &
"${PING4}" $PINGHOST > $PINGFILE &
else
ping6 $PINGHOST > $PINGFILE &
"${PING6}" $PINGHOST > $PINGFILE &
fi
ping_pid=$!
# echo "Ping PID: $ping_pid"