Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

ISP Check

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.

Screenshot

Public repo on gitHub

https://github.com/stevegroom/ispcheck

https://github.com/stevegroom/ispcheck.git
git@github.com:stevegroom/ispcheck.git

Flow

@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

@enduml

DNS Check

https://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.49

Internet address check

https://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.49

Compare the two

if [ `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" ; fi

The macos script

isMyDnsOk.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\" "

Scheduling

Add this line:

0 20 * * * /Users/steve/development/docker/ispcheck/isMyDnsOk.sh

to your crontab:

$ crontab -e
crontab: no crontab for steve - using an empty one
crontab: installing new crontab

Next steps

Create version that can be called from Jenkins (or Jenkins in a docker container).

Steve Groom
2019-04-06

About

Alert if my ISP assigned address has changed

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages