Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed

Check HTTP status code for a page on all DNS records

Published: 09-04-2017 | Author: Remy van Elst | Text only version of this article


❗ This post is over six years old. It may no longer be up to date. Opinions may have changed.

This is a small snippet using curl to check the status code of a given URL on all DNS records for a given domain. This site has a few A records in round robin mode, and sometimes the automatic deployment fails. Using this query I can check which server is the culprit and fix it manually.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.

The normal HEAD request output also shows all the headers the server sends and that is a pain to scroll through. This just shows me the HTTP status code, which is all I want.

dig +short A raymii.org | awk '{print "echo "$1"; curl -s -k -o /dev/null -I -w \"%{http_code}\" https://"$1"/s/blog/Burn_in_testing_for_Hypervisor_and_Storage_servers.html; echo; echo"}' | bash

Example output:

163.172.129.56
200

185.54.115.97
404

213.187.244.250
000

81.4.120.226
200

The first and last server are correct. The middle one with status code 000 is offline and the 404 code is also not up to date.

For IPv6 and AAAA records, we add brackets:

dig +short AAAA raymii.org | awk '{print "echo "$1"; curl -6 -s -k -o /dev/null -I -w \"%{http_code}\" https://["$1"]/s/blog/Burn_in_testing_for_Hypervisor_and_Storage_servers.html; echo; echo"}' | bash

Example output:

2a00:d880:5:783::2
200

2a04:92c7:e:4d1::5436
200
Tags: bash , curl , dns , snippets