I have a problem understanding how IP resolving works on Linux systems. To demonstrate my problem I'll show an example on Windows and afterwards on Linux.
hosts file is empty. It only contains comments.
Running the following command in a Python shell:
192.168.10.105 which is my current IP in the network I am in. As I expected it to be.
On Linux my
/etc/hosts looks as follows:
127.0.0.1 localhost.localdomain localhost
The same Python command would give me errors that the resource is temporarily unavailable. I am guessing that it has to do with the absence of the my current Hostname from
/etc/hosts. If I add it manually
127.0.0.1 localhost.localdomain localhost MyHostName
the python command returns
127.0.0.1. Which is still not what I expected it to be. I can however add the IP and my hostname to the file
127.0.0.1 localhost.localdomain localhost 192.168.10.115 MyHostName
but this is surely not the correct way to go. If DHCP is used this IP would change.
How can I achieve the same result on Linux as on Windows? Where is my configuration (or my thinking?) wrong?