In this case, I’ll show you how to get IP from domains. We will save the domains in the file, then, after calling the command, we will get a list of IP addresses along with the names of the domains from which we want to get the IP address.
Command that we will use is “host“:
I placed some domains, for example:
1 |
$ for i in `cat host_list.txt`; do echo $i ; host $i | awk '/has address/ { print $4 }'; done |
After calling the command:
It’s worth noting that in some cases there are more IPs – like netflix.com. This is because traffic is spread across different servers.
If you want to get only IP addresses without domain names, remove “echo” from the command:
1 |
for i in `cat host_list.txt`; do host $i | awk '/has address/ { print $4 }'; done |
The result of the command is: