0

This is probably a Network related question, although i can't really find out what is going on.

InetAddress giriAddress = java.net.InetAddress.getByName("www.google.com");
String address = giriAddress.getHostAddress();
System.out.println(address);
//output
//74.125.24.147 as well as 216.58.210.228

What i expected:

  • 8.8.8.8

What I got:

  • 74.125.24.147

  • 216.58.210.228

Note:

And in fact by visiting both of these addresses I'm viewing google's homepage

My Question:

Why 8.8.8.8 is not returned? Why these two addresses looping on each other?

Phill Alexakis
  • 1,449
  • 1
  • 12
  • 31

1 Answers1

1

8.8.8.8 is the IP address of Google's DNS server.

What you're getting are the resolved IP addresses of webservers hosting www.google.com

From InetAddress#getByName:

Determines the IP address of a host, given the host's name.

So it actually does the DNS resolving for you.

gcasar
  • 729
  • 1
  • 9
  • 22