{"id":18947639,"url":"https://github.com/yousafkhamza/dns-lookup-bash-script","last_synced_at":"2025-04-15T23:30:23.931Z","repository":{"id":195965541,"uuid":"384962574","full_name":"yousafkhamza/dns-lookup-bash-script","owner":"yousafkhamza","description":"It's a bash script to show a complete DNS lookup of a domain and it might be useful for Linux system/support engineers who handled client support. I believe it helps for these guys to troubleshoot or easy way to find all the details in a single click.","archived":false,"fork":false,"pushed_at":"2021-11-24T04:14:35.000Z","size":75,"stargazers_count":11,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-09-20T19:52:41.345Z","etag":null,"topics":["bash-script","command-line","dns","dns-lookup","linux","scripting"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yousafkhamza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-07-11T14:01:29.000Z","updated_at":"2023-09-20T19:52:43.168Z","dependencies_parsed_at":"2023-09-20T20:13:36.203Z","dependency_job_id":null,"html_url":"https://github.com/yousafkhamza/dns-lookup-bash-script","commit_stats":null,"previous_names":["yousafkhamza/dns-lookup-bash-script"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdns-lookup-bash-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdns-lookup-bash-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdns-lookup-bash-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousafkhamza%2Fdns-lookup-bash-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yousafkhamza","download_url":"https://codeload.github.com/yousafkhamza/dns-lookup-bash-script/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223688710,"owners_count":17186298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-script","command-line","dns","dns-lookup","linux","scripting"],"created_at":"2024-11-08T13:10:49.114Z","updated_at":"2024-11-08T13:10:50.936Z","avatar_url":"https://github.com/yousafkhamza.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Complete DNS lookup script\n[![Build](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)\n\n---\n## Description\n\nIt's a bash script to show a complete DNS lookup of a domain and it might be useful for Linux system/support engineers who handled client support.  I believe it helps for these guys to troubleshoot or easy way to find all the details in a single click.\n\n----\n## Feature\n- DNS Lookup Script for troubleshooting \n- Including almost DNS Related commands in a single script\n- Including whois details and telnet conncetivity (so need to install both that the packages)\n\n---\n## Pre-Requestes (Packages Installation)\n_For-RedHat-Distributer_\n```sh\nsudo yum update\nsudo yum -y install git \nsudo yum -y install bind-utils\nsudo yum -y install telnet\nsudo yum -y install whois\nsudo yum -y install nc\n```\n_For-Debian-Distributer_\n```sh\nsudo apt update\nsudo apt -y install git \nsudo apt -y install dnsutils\nsudo apt -y install telnet\nsudo apt -y install whois\nsudo apt -y install nc\n```\n\n\u003e Please note that this script is not supporting with macOS.\n \n----\n## How to use this script\n```sh\ngit clone https://github.com/yousafkhamza/dns-lookup-bash-script\ncd dns-lookup-bash-script\nchmod +x dt.sh\n```\n_Alias Assgning for this script_\n```sh\necho \"alias dg='bash $(pwd)/dt.sh'\" \u003e\u003e ~/.bashrc\nsource ~/.bashrc\n```\n\n## Script Running\n```sh\ndg geekflare.com                   #\u003c--------------- Before set alias\nor \nbash dt.sh geekflare.com           #\u003c-------------- On the Sript directory\n```\n\n## Output\n```sh\n# dg geekflare.com\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nDig +trace result of the geekflare.com\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\ngeekflare.com.          30      IN      A       104.27.118.115\ngeekflare.com.          30      IN      A       104.27.119.115\ngeekflare.com.          86400   IN      DS      2371 13 2 CBAA2018F41B29985DAEDE7F127D4F9626ADA609665CEBAB0011903B 7C639254\ngeekflare.com.          172800  IN      NS      olga.ns.cloudflare.com.\ngeekflare.com.          172800  IN      NS      todd.ns.cloudflare.com.\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nMX Record Result of the geekflare.com\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\ngeekflare.com.          300     IN      MX      10 alt3.aspmx.l.google.com.\ngeekflare.com.          300     IN      MX      10 alt4.aspmx.l.google.com.\ngeekflare.com.          300     IN      MX      1 aspmx.l.google.com.\ngeekflare.com.          300     IN      MX      5 alt1.aspmx.l.google.com.\ngeekflare.com.          300     IN      MX      5 alt2.aspmx.l.google.com.\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nTXT Record Resutl of the geekflare.com\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\ngeekflare.com.          300     IN      TXT     \"google-site-verification=MRSwa454qay1S6pwwixzoiZl08kfJfkhiQIslhok3-A\"\ngeekflare.com.          300     IN      TXT     \"ahrefs-site-verification_8eefbd2fe43a8728b6fd14a393e2aff77b671e41615d2c1c6fc365ec33a4d6d0\"\ngeekflare.com.          300     IN      TXT     \"yandex-verification: 42f25bad396e79f5\"\ngeekflare.com.          300     IN      TXT     \"v=spf1 include:_spf.google.com include:mailgun.org ~all\"\ngeekflare.com.          300     IN      TXT     \"google-site-verification=7QXbgb492Y5NVyWzSAgAScfUV3XIAGTKKZfdpCvcaGM\"\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nPTR record result of the 104.27.118.115\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nTelnet trying to connect that IP Result of the alt3.aspmx.l.google.com\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nIP: 172.217.194.27\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nTelnet Result of IP: 104.27.118.115 \u0026\u0026 MX: alt3.aspmx.l.google.com and checking both 25 \u0026 587\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nIP:\n          ------\nMX: 220 mx.google.com ESMTP 26si18015154pgs.402 - gsmtp\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nWHOIS Result of the geekflare.com\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n   Registrar URL: http://www.cloudflare.com\n   Registry Expiry Date: 2025-01-07T14:14:12Z\n   Registrar: CloudFlare, Inc.\n   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited\n   Name Server: OLGA.NS.CLOUDFLARE.COM\n   Name Server: TODD.NS.CLOUDFLARE.COM\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n```\n\n----\n## Behind the code\n```sh\n#!/bin/bash\n\ndomain=$1\nif [ -z \"$domain\" ]\nthen\n        echo \"Please specify a FQDN. eg:('google.com')\"\n        exit 1\nelif [[ \"$domain\" =~ ^http://* ]] || [[ \"$domain\" =~ ^https://* ]]\nthen\n        echo \"Please specify a FQDN without Protocol and Symbols. eg:('google.com')\"\n        exit 1\nelif grep -oP '^((?!-)[A-Za-z0-9-]{1,63}(?\u003c!-)\\.)+[A-Za-z]{2,6}$' \u003c\u003c\u003c \"$domain\" \u003e/dev/null 2\u003e\u00261;\nthen\n#dig +trace domain\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho \"Dig +trace result of the $domain\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\ndig +nocmd $domain a +noall +answer \u003e\u003e ~/digtrace\ndig +nocmd $domain ns +noall +answer \u003e\u003e ~/digtrace\ndig +trace @8.8.8.8 $domain | grep \"$domain.\" | grep -vE 'RRSIG|;' \u003e\u003e ~/digtrace\ncat ~/digtrace | sort | sort -u -k 5 \u0026\u0026 rm -f ~/digtrace\n\n#MX Record\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho  \"MX Record Result of the $domain\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n#dig +nocmd $domain txt +noall +answer\ndig +nocmd $domain mx +noall +answer | sort -k 5\n\n#TXT Record\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho  \"TXT Record Resutl of the $domain\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n#dig txt $domain | grep ^\"$domain\" | grep TXT\ndig +nocmd $domain txt +noall +answer\n\nIP=`dig +nocmd $domain a +noall +answer | grep ^\"$domain\" | grep A | awk {'print $5'} | head -n1`\n#IP=`dig $domain | grep ^\"$domain\" | grep A | awk {'print $5'} | head -n1`\n#host for IP\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho  \"PTR record result of the $IP\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n#host $IP | awk {'print $5'}\ndig -x $IP +noall +answer | grep -vE ^\";|^$\"\n\nMX=`dig +nocmd $domain mx +noall +answer | grep ^\"$domain\" | grep MX | awk {'print $6'} | rev | cut -c2- | rev | head -n1`\n#MX=`dig mx $domain | grep ^\"$domain\" | grep MX | awk {'print $6'} | rev | cut -c2- | rev | head -n1`\n#MX Trying IP Resutl\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho  \"Telnet trying to connect that IP Result of the $MX\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho \"IP: `timeout 1 telnet $MX 587 \u003e ~/Try; timeout 1 telnet $MX 25 \u003e\u003e ~/Try; cat ~/Try | grep -v -e '^$'| grep Trying | head -n1 | awk {'print $2'} | rev | cut -c4- |rev; rm -f ~/Try`\"\n\n#Netcatch Result for MX 25 \u0026 587\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho  \"Telnet Result of IP: $IP \u0026\u0026 MX: $MX and checking both 25 \u0026 587\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho \"IP: `timeout 3 nc $IP 587 \u003e ~/rre; timeout 1 nc $IP 25 \u003e\u003e ~/rre; cat ~/rre | grep -v -e '^$'| head -n1; rm -f ~/rre`\"\necho \"          ------\"\necho \"MX: `timeout 3 nc $MX 587 \u003e ~/rre; timeout 1 nc $MX 25 \u003e\u003e ~/rre; cat ~/rre | grep -v -e '^$'| head -n1; rm -f ~/rre`\"\n\n#WHOIS Result for Domain\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\necho  \"WHOIS Result of the $domain\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\nwhois $domain | grep -E \"Registrar:|Registry Expiry Date:|Registrar URL:|Name Server:|Expiration Date:|Status:|URL:\"\necho \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\nelse\necho \"Please enter a valid FQDN. eg:('google.com')\"\nfi\n```\n\u003e Please note that I didn't use \"dig +short\" because I need to get the complete domain name and result so that's why I used this. If anyone comfertable with that kind of commands please be look and change the same as above file who needs to require that. \n\n---\n### _Commands used (lookup)_\n- _dig_\n- _dig +trace_\n- _telnet_\n- _nc_\n- _whois_\n\n----\n### _DNS Lookup working be like_\n\n![alt text](https://i.ibb.co/Rybf9sQ/dns.png)\n\n----\n## Conclusion\n\nIt's a simple bash script for complete DNS lookup details in a sing click. I hope it's useful for those who handle client support. Please let me know if you are facing any issues while using this script. Also, you guys can reach me out with the below contact details. \n\n### ⚙️ Connect with Me \n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"mailto:yousaf.k.hamza@gmail.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Gmail-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/in/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://www.instagram.com/yousafkhamza\"\u003e\u003cimg src=\"https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge\u0026logo=instagram\u0026logoColor=white\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://wa.me/%2B917736720639?text=This%20message%20from%20GitHub.\"\u003e\u003cimg src=\"https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white\"/\u003e\u003c/a\u003e\u003cbr /\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fdns-lookup-bash-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyousafkhamza%2Fdns-lookup-bash-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousafkhamza%2Fdns-lookup-bash-script/lists"}