How to find the IP address in CMD using hostname?

In networking, each system has its own identity denoted by a few numerical digits known as IP address, however, remembering them can be a difficult task, especially when there are a large number of systems. For example, each website running on the Internet has an IP address, so that other systems can call them whenever needed but do you think it is feasible to remember the long series of numbers for each website we visit?

The answer is “No”, hence corresponding to each IP address we can set a human-readable label. That’s the reason why when we need to visit Google we use its domain name instead of its IP address. Similarly, in our local networks, we have hostnames for each PC alongside IP addresses. This hostname allows us to connect PC if we don’t know the IP address.

However, if you don’t know the IP address corresponding to some hostname and want to find that, here in this tutorial we learn how to use the Command prompt or PowerShell to translate a hostname or Domain name to its corresponding IP address.

Step 1: Open Command Prompt

Well, as the title of this tutorial suggests we are going to use the command line on Windows to find the IP address associated with a hostname. Therefore, open the command prompt or PowerShell, click on the Windows Start button search for “CMD” as it appears click to run the same.

Alternatively, we can use the Windows key + R to open the Run dialog, typing “cmd,” and pressing Enter to access the Command prompt.

Rus as administrator command prompt

Also, learn – how to find a Wi-Fi password using the command prompt in Windows 11.

Step 2: Ping and NSLookUp

There are two common commands that we can use to find the IP address associated with a hostname, one is PING, and the other is NsLookUP, let’s see how to use them.

Ping Command to find the hostname IP

On your command prompt, and those are use PowerShell, run the “ping” command along with the hostname of the PC or device that IP address you want to identify. For example, our local hostname is “h2smedia” then the command to find its IP address:


ping hostname or domain

ping h2smedia

If you want to get IPv4 then add the ‘-4‘ parameter in the above command, it will be like this:

ping h2smedia -4

Similarly, we can use any domain name to find its corresponding IP:


Using NSLookUp

Like ping, we can use the NSLookUp which is a specialized command line tool for querying Domain Name System to obtain the mapping between domain name and IP address:


nslookup hostname or domain


nslookup h2smedia

Step 3: View the IP Address

Well, the ping command as you run it, the system will start pinging the remote system or device to send packets to the mentioned hostname and in return will display the IP address along with information on whether the remote or local system is in reach or not. To identify the IP address just look for the line that starts with “Reply from” followed by the IP address.

Similarly, in the NSlokup command, you will directly have the Ip-address value as output, instead of confirming whether the host is reachable or not.

command prompt to find hostname ip address

Step 4: Note the IP Address

Once you have the IP address on the command prompt display, you can start using it to either connect the device available in your network or perform any troubleshooting task with the help of any third-party software such as Wireshark.

Other Articles: