-3

Is there any way to resolve hostnames without added to hosts file?

In order to access internal site in my company I have to add the host-name and IP in the .../etc/hosts file. Is there any way to add this in DNS server or active directory instead of manually add this to 100 computer.

Magellan
  • 4,451
  • 3
  • 30
  • 53
Mekko
  • 1
  • 2
  • 3
    Any reason why you Can't just add it to your DNS? – uSlackr Apr 03 '12 at 17:09
  • I thought this was automatic for windows computers that join to the Windows domain. They get added to DNS. You normally never need hosts files. – hookenz Apr 03 '12 at 17:20
  • Say more about "I have to add the hostname and IP in ...etc/hosts". Do you need to add the host/IP of the internal site to hosts file or the host/IP of the clients? – uSlackr Apr 03 '12 at 17:24
  • The host and IP is already in DNS manager !!! – Mekko Apr 03 '12 at 17:51
  • 1
    You should never have to touch your hosts file in a properly configured DNS environment. It sounds like something is incorrectly configured, but based on the scant amount of details given, it's impossible to say whether or not the problem is with your workstation, the DNS server, or the DHCP server. – MDMarra Apr 03 '12 at 18:38

3 Answers3

5

First, all PCs in the organization need to be looking to a DNS server that you control. Use DHCP to populate client PC's network information with the proper DNS server to look to for resolution.

Next, simply add an A record for each DNS name / IP address combination that you want to add.

Further reading that should interest you:

Wesley
  • 32,690
  • 9
  • 82
  • 117
  • We are using windows 2008r2 and I already added New host (A or AAAA) to DNS manager and all PCs are looking to a DNS server. So, if I uncomment the IP and hostname from hosts file I am unable to access the site. – Mekko Apr 03 '12 at 17:50
  • Flush the DNS cache on the client PC after you remove the entry in the hosts file. `ipconfig /flushdns` After that, try to resolve a DNS name that you've added to the server. Use nslookup on the client (make sure that it's pointing to the right DNS server) and see what the response is when you try to resolve that DNS name. – Wesley Apr 03 '12 at 17:53
  • The nslookup is giving me the right IP that I am adding to etc/hosts file after I flushed the DNS but still when I try to browse the site I get this webpage is not available. – Mekko Apr 03 '12 at 18:04
  • @Mekko: You're saying that your host/FQDN is in your DNS server. If you don't have the hostname in your host file, and do an nslookup on the client, the correct IP appears. But if you try to web browse to that host, you're getting an error. – Bart Silverstrim Apr 03 '12 at 18:14
  • If you add that host to your host file, then try web browsing to that host, the website comes up fine. – Bart Silverstrim Apr 03 '12 at 18:14
  • ...in that case, with the host name removed from the hosts file, are you getting the "Correct" IP when you ping the hostname? – Bart Silverstrim Apr 03 '12 at 18:15
  • @ Bart Silverstrim: Yes whenever I added to hosts file, I can browse the internal website ... – Mekko Apr 03 '12 at 18:24
  • @mekko but pinging it (not in the host file) will bring up the proper IP, yes? – Bart Silverstrim Apr 03 '12 at 18:25
  • No, I am getting "Ping request could not find host apim.*plat.net. Please check the name and try again." – Mekko Apr 03 '12 at 18:26
  • And you double checked your DNS setting on the client to make sure it's pointing to your network's DNS server? – Bart Silverstrim Apr 03 '12 at 18:27
  • ipconfig /all - should tell you your DNS server settings. – Bart Silverstrim Apr 03 '12 at 18:28
  • How can I check this? – Mekko Apr 03 '12 at 18:30
  • The DNS is pointing to our internal DNS server not to production DNS. – Mekko Apr 03 '12 at 18:32
  • Well, I will check the Internal DNS ... Humm let me see the internal one. – Mekko Apr 03 '12 at 18:34
  • I will check the internal DNS tomorrow. – Mekko Apr 03 '12 at 18:48
  • Thank you all for the help ... You are amaziiiiiiiiiiiiiiiiing ;) – Mekko Apr 03 '12 at 18:48
3

Yes, there most certainly is, it is even well-documented, over at TechNet: Add a host (A) resource record to a zone

Mathias R. Jessen
  • 25,161
  • 4
  • 63
  • 95
1

Judging by your comments, your internal (AD) and external domain namespaces overlap, meaning that your internal AD domain name is company.com and your external site is also company.com.

This is bad. You should strongly consider doing an AD domain rename and changing it to something like internal.company.com or ad.company.com. If you don't, you're going to have to manage two sets of DNS records, one for each side of the infrastructure as well as having to do some IIS/DC voodoo on your DCs to make company.com reachable from the inside.

MDMarra
  • 100,734
  • 32
  • 197
  • 329