We are using Ubuntu machienes as our servers, such we got 14 servers.
The command ifconfig works on all terminals it gives specific IP address.
When I ran the following java program through a script, on one of the 14 servers I get the host ip as standard 127.0.0.1 (I uploaded this file and script on only 2 machines as of now)
package com;
import java.net.Inet4Address;
public class IpAddressTest {
public static void main(String args[]) throws Exception {
String ipaddress = Inet4Address.getLocalHost().getHostAddress();
String hostname = Inet4Address.getLocalHost().getHostName();
System.out.println("THE IP ADDRESS IS" + ipaddress);
System.out.println("THE HOST NAME IS" + hostname);
}
}
To test this program as which server will give me IP as 127.0.0.1, I need to upload this java class file and related script to execute that on all of the 14 servers.
Is there any other alternate way of finding that? I want to check if i can get the IP THROUGH java , but for this i need to upload these java file and script file to all 14 servers .so asking is there any alternate way