From 9b59388a58bd79db6d43e169c0fb7903f6bff0d1 Mon Sep 17 00:00:00 2001 From: Harald Ringvold Date: Sat, 20 Mar 2021 21:09:58 +0100 Subject: [PATCH] Adding check for valid ip address In some cases the return body from ifconfig.co is an HTML error page. This change makes sure the response is a valid IP address. --- dyndns.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dyndns.sh b/dyndns.sh index 724c71d..f17a281 100755 --- a/dyndns.sh +++ b/dyndns.sh @@ -30,7 +30,8 @@ while ( true ); do echo "Trying with $service..." ip="$(curl -s $service)" - test -n "$ip" && break + valid_ip=$(echo $ip | grep '[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}') + test -n "$valid_ip" && break done echo "Found IP address $ip"