I am trying to develop a system where there are different nodes that are run on different system or on different ports on the same system.
Now all the nodes create
Usually when i try to find my public IP Address like cmyip.com or www.iplocation.net, i use this way:
public static String myPublicIp() {
/*nslookup myip.opendns.com resolver1.opendns.com*/
String ipAdressDns = "";
try {
String command = "nslookup myip.opendns.com resolver1.opendns.com";
Process proc = Runtime.getRuntime().exec(command);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String s;
while ((s = stdInput.readLine()) != null) {
ipAdressDns += s + "\n";
}
} catch (IOException e) {
e.printStackTrace();
}
return ipAdressDns ;
}