In the file C: \ WINDOWS \ system32 \ drivers \ etc \ hosts I have only the following line
192.168.0.23 computername.domain.com computername
When i started
InetAddress localhost = InetAddress.getLocalHost(); System.out.println("getLocalHost:" + localhost);
I expect the conclusion to be
getLocalHost:computername/192.168.0.23
but he appears like
getLocalHost:computername/192.168.0.107
Any ideas on why this is happening? Should the configuration be done in another file (too)?
EDIT
InetAddress.getByName('computername')
creates the same IP address as getLocalHost() .
source share