In: Computer Science
The solution for the above problem is given below and if you feel any problem then feel free to ask.
Solution:-
Finding hostname in Windows :
If you want to know the hostname then you have to open the command line and enter the "hostname" command and it will give the host name of the computer you are working on.
And if you want to get the host name from a given IP address then you have to enter the "nslookup <ip>" command and it will give you the hostname that is bound with that IP address. Here the <ip> gets replaced by the IP whose hostname you want to find.
Now, finding hostname in Linux :
If you want to know the hostname on a Linux based system then you can also use "hostname" command in the Terminal and it will give you the present computer's host name on which you have entered the command.
And, if you want to know the hostname from the IP address of the system then you can use either "nslookup <ip>" or "host <ip>" commands and either of them will give you the hostname. In case of nslookup command the hostname is given in front of the "name =" label and in case of host command the hostname is given in the last of the data without any label. And also the <ip> part in both commands get replaced by the IP whose hostname you want to find.
If the internet browser is unable to find the hostname then you have to flush the domain name server by the following command in the terminal so that any problem in the file of DNS will get flushed also:
For flushing DNS the commands are as follows:
In Windows: ipconfig /flushdns
In Linux: sudo /etc/init.d/nscd restart