Network Host Scan/Discovery
Resolve Hostnames to IPs (Linux example)
You can use tools like nslookup
, dig
, or host
to resolve hostnames into IP addresses.
Automating the Process with a Script:
If you have many hostnames, you can write a simple script to resolve them into IP addresses and output a clean list. It ensures that output is in IPv4 format filtering for valid IPv4 addresses from the nslookup
result, ensuring only IPv4 addresses are written to the output file.
Here’s a bash script to do that:
How to Use the Script:
Save the script as
resolve_ips.sh
:Make it executable:
Run the script with your hostname list file as a parameter:
This script now takes the file
hostnames.txt
(or any other file you provide as a parameter) and resolves the hostnames into IPs.The output will be saved to
resolved_ips.txt.
Last updated