Java. InetAddress.getLocalHost returns strange IP -


i'm don't understand, why code below prints 0.0.9.229 instead 127.0.0.1. can tell me, hot fix that?

string ha = inetaddress.getlocalhost().gethostaddress(); system.out.println(ha); 

upd: code running on ubuntu

/etc/hosts

127.0.0.1       localhost 127.0.1.1       2533 

inetaddress.getlocalhost() doesn't people think does. returns hostname of machine, , ip address associated hostname. may address used connect outside world. may not. depends on how have system configured.

on windowsbox gets machine name , external ip address. on linux box returns hostname , 127.0.0.1 because have set in /etc/hosts


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -