Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 115
  • Last Modified:

bash script to resolve all hostnames in a list

Hi Guys,
I have a list of over 100 domains.
I need to get the A record of each one of them through a bash script.
I also need the same bash script to write the resolve next to FQDN itself...
Meaning, before the script:
cat /home/user/domains.list

Open in new window

will return
google.com
amazon.com

and after the script it will return
google.com 216.52.217.78
amazon.com 54.239.25.200
0
David Sankovsky
Asked:
David Sankovsky
  • 5
  • 3
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
I'm curious what you are going to do with them.  I ask because your two examples, google.com and amazon.com have not just one but many IP addresses.
0
 
David SankovskySenior SysAdminAuthor Commented:
You are correct Dave but they are only examples. in my scenario I know for a fact that no one will have more than one resolve, I do however expect some to return nxdomain.

The point is simple I have a plesk server we wish to close that has over 100 FQDNs. We want to close this server, we just need to know which domains still actually point to this server.
0
 
Dave BaldwinFixer of ProblemsCommented:
Interesting.  I would have thought that the Plesk software would tell you that.  Or do you know that some have moved to other servers already?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Dave BaldwinFixer of ProblemsCommented:
I just wrote a PHP script that does the lookup for my own websites.  I can post that if you want.
0
 
David SankovskySenior SysAdminAuthor Commented:
Might even be better I could integrate that into one of my management sites...
0
 
Dave BaldwinFixer of ProblemsCommented:
This just displays the name and IP, one to a row.  Substitute you domain names but make sure and observe the punctuation.   You could collect them into a variable and save it to a file fairly easily.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>gethostbyname</title>
</head>
<body>
<?php
$hostz = array(
	"www.Yoursite.com"
	, "www.Yoursite.org"
	, "www.Yoursite.net"
	, "www.Yoursite.info"
	);

foreach($hostz as $value) {
	echo $value." = ";
	$ip = gethostbyname($value);
	echo $ip."<br>";
	}
?>
</body>
</html>

Open in new window

0
 
David SankovskySenior SysAdminAuthor Commented:
ok, now I just need to make that read from a file.
Thanks a lot :)
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now