Compare the IP address reserved for the cable modem against the DNS entry registered for the same. If there is a mis-match alert the sysadmin to update the DNS record.
https://github.com/stevegroom/ispcheck
https://github.com/stevegroom/ispcheck.git
git@github.com:stevegroom/ispcheck.git
@startuml
start
floating note right: ~/development/ispcheck/isMyDnsOk.sh
fork
:process lookup current IP address;
:process parse address with jq;
fork again
:process lookup reverse DNS address;
:process parse address with jq;
end fork
if (addresses match?) then (yes)
:process message = success;
else (no)
:process message = failure;
endif
:process Send message;
stop
@endumlhttps://dns.google.com/resolve?name=groom.ch&type=A
returns
{
"Status": 0,
"TC": false,
"RD": true,
"RA": true,
"AD": false,
"CD": false,
"Question":[ {"name": "groom.ch.","type": 1}],
"Answer":[ {"name": "groom.ch.","type": 1,"TTL": 299,"data": "178.198.102.49"}],
"Comment": "Response from 216.40.47.26."}Filter the results with the jq command:
curl -s https://dns.google.com/resolve?name=groom.ch | tee | jq -r .Answer[0].data
178.198.102.49https://api.ipify.org?format=json
returns
{"ip":"178.198.102.49"}curl -s https://api.ipify.org?format=json | tee | jq -r .ip
178.198.102.49if [ `curl -s https://api.ipify.org?format=json | tee | jq -r .ip` == `curl -s https://dns.google.com/resolve?name=groom.ch | tee | jq -r .Answer[0].data` ] ;then echo "OK" ; fiisMyDnsOk.sh
#!/bin/bash
# Mac OS version
# Checks the dns entry for the cable modem against the current IP address
# and sends an pop-up notification.
# Steve Groom
# 06.04.2019
dnsRec=`curl -s https://dns.google.com/resolve?name=groom.ch | tee | jq -r .Answer[0].data`
ipAddr=`curl -s https://api.ipify.org?format=json | tee | jq -r .ip`
if
[ $ipAddr == $dnsRec ]
then
message="DNS record is correct: $dnsRec"
else
message="DNS record needs updating to: $ipAddr"
fi
osascript -e "display notification \"$message\" with title \"DNS Checker\" "Add this line:
0 20 * * * /Users/steve/development/docker/ispcheck/isMyDnsOk.shto your crontab:
$ crontab -e
crontab: no crontab for steve - using an empty one
crontab: installing new crontabCreate version that can be called from Jenkins (or Jenkins in a docker container).
Steve Groom
2019-04-06
