2020-12-21 08:50:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-08-14 05:55:01 +00:00
|
|
|
[[ -n "$DEBUG" ]] && set -x
|
2020-12-21 08:50:15 +00:00
|
|
|
|
2021-08-14 05:55:01 +00:00
|
|
|
interface="$(ip link show | awk '/ ppp/ {print substr($2, 1, length($2)-1)}')"
|
|
|
|
addr="$(ip addr show dev "$interface" | awk '/inet / {print $2}')"
|
|
|
|
resolved="$(dig +short "${domain}" A)"
|
|
|
|
|
|
|
|
if [[ -z "$addr" ]] || [[ -z "$resolved" ]]
|
2020-12-21 08:50:15 +00:00
|
|
|
then
|
2021-08-14 05:55:01 +00:00
|
|
|
echo "Address on '$interface' is '$addr' - resolved '$resolved'"
|
2020-12-21 08:50:15 +00:00
|
|
|
exit 3
|
2021-08-14 05:55:01 +00:00
|
|
|
elif [[ "$addr" == "$resolved" ]]
|
|
|
|
then
|
|
|
|
echo "Resolved IP for ${domain} matches current ip on $interface"
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "Resolved $resolved for ${domain}, but got $addr on $interface!"
|
|
|
|
exit 2
|
2020-12-21 08:50:15 +00:00
|
|
|
fi
|