M99
M99

Reputation: 1907

Domain Name When querying DNS server

When querying DNS server for the IP address, which one of the following is a valid domain name (or host name)? I want to write a program in Java to Query the DNS Server for the IP address of a given host.

www.google.com
OR 
google.com

Upvotes: 1

Views: 1306

Answers (4)

nos
nos

Reputation: 229058

They might be both valid.

If you want to check whether google.com, www.google.com, wwwwwww.goo.g.le.com are valid, the best thing is to query the DNS server.

Upvotes: 0

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84151

Why not try both? They might have same set of resource records, they might be different, or one might be an alias for the other. In reality they are different:

nickf@gloin:~$ host google.com
google.com has address 72.14.204.99
google.com has address 72.14.204.104
google.com has address 72.14.204.103
google.com has address 72.14.204.147
google.com mail is handled by 100 google.com.s9a1.psmtp.com.
google.com mail is handled by 300 google.com.s9b1.psmtp.com.
google.com mail is handled by 400 google.com.s9b2.psmtp.com.
google.com mail is handled by 200 google.com.s9a2.psmtp.com.

nickf@gloin:~$ host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 72.14.204.147
www.l.google.com has address 72.14.204.103
www.l.google.com has address 72.14.204.99
www.l.google.com has address 72.14.204.104

Upvotes: 2

Nishant
Nishant

Reputation: 55856

google.com == domain --> resolve to server-IP mapped to google.com

www.google.com == subdomain --> resolve to server-IP mapped to www.google.com

If they have configured the same you will get same result, else different. But both are correct.

Upvotes: 1

Jim Lewis
Jim Lewis

Reputation: 45025

Both are valid hostnames as far as DNS is concerned.

Upvotes: 0

Related Questions