The process of finding the IP address is achieved by searching the DNS (Domain Name Servers) until a match on the domain name is found. This process is also known as DNS lookup, NSLOOKUP or (erroneously) IP lookup.
The process of finding the host name (or domain name) from an IP address involves sending a message to the IP address and requesting the computer located at that IP address to return its name. Usually this will be the same as the domain name. However, many computers host many domains so the host name may be one of the domain names hosted or it could be something totally different.
There are some special IP addresses. 127.0.0.1 is always the IP address of every computer. No matter which computer you use, it will always have an IP address of 127.0.0.1 and a name of 'localhost'. In addition, a computer can have more than one IP address. In order to connect to other computers it will have an IP address that is known to other computers.
Host Name or Domain Name:
There is often confusion about what is a host name and what is a domain name.
A domain name is the name that is purchased from a registrar. It will be something like hcidata.com or hcidata.co.uk. Note that there is no www at the beginning of a domain name. A domain name can be subdivided into sub-domains - for example www.hcidata.com. Once you own a domain, there is no reasonable limit to the number (or names) of the sub-domains you can create. A sub-domain can be allocated to a host machine - for example a PC. In fact many sub-domains can be allocated to the same host machine. The way sub-domains are allocated to a host machine is to create a record in the DNS (Domain Name Servers) that records the sub-domain name and the IP address of the host machine. Any requests for a sub-domain (e.g. www.hcidata.com) are converted to an IP address by DNS and the IP address is used to route the request through the network until it reaches the host machine.
In the early years of the Internet, each sub-domain would have a unique IP address so it was common for a host machine to have only one sub domain name. Nowadays, the common practice is to have many sub-domains with the same IP address. It is also common for the domain name to be converted to the IP address of the host machine that runs the www sub domain.
A host name is the unique name of a machine. When the host operating system is set up it is given a name. This name may reflect the prime use of the machine. For example, a host machine that converts host names to IP addresses using DNS may be called dns.hcidata.com and a host machine that is a web server may be called www.hcidata.com. When we need to find the host name from an IP address we send a request to the host using its IP address. The host will respond with its host name.
IP address to Country:
IP addresses are allocated by regional organisations. Therefore it is relatively easy to work out the country in which an IP is likely to reside. When an IP is allocated to a company they are expected to be used in the country the organisation resides. But, there is nothing to stop a company allocating an IP to a machine in another country. For example. A company is allocated a range of IP addresses X.Y.Z.0 to X.Y.Z.255 for use in England. This company has a private network with a branch office in New York. So, it uses most of the IP address in England but uses some of them in the States. So, we cannot guarantee that the country is 100% correct when converting an IP address, but we would expect it to be correct at least 90% of the time.
You can find or change any host name to its ip address or vice versa here