-1

I have a multi NIC system where NIC_1(public network), NIC_2(private network) are associated with IP_1, IP_2 respectively. Using the system's hostname I tried to get the system IP using InetAddress.getByName(hostname) and I found that the InetAddress.getByName(hostname) returns the private IP IP_2 when I was expecting it to return the public IP IP_1. DNS is not configured and since I am running this code locally on the system, how does InetAddress.getByName(hostname) decide which IP to pick in a multi NIC system? I checked the Java API docs for InetAddress but I could not find any information on multi NIC scenario for that method. How did the method call pick private IP address and not the public IP address? With DNS NOT configured, how does the InetAddress.getByName(hostname) decide which system IP to return?

Arun kumar R
  • 135
  • 7

1 Answers1

0

you will get back the first matching entry from your /etc/hosts file

Gábor
  • 304
  • 2
  • 6