Windows assign a hostname

An easy one for the Windows guys -
How do we add a hostname to a windows server 2008 R2. This is a stand alone server with no DNS configured.
LVL 11
Who is Participating?
If you do not have any network-based name resolution services available (e.g. no local DNS server), then the only way to manually define a hostname is to put it into the "hosts" file in C:\windows\system32\drivers\etc.

You would tack the following line into the bottom of the hosts file:

Where "" is what you want to resolve to.

This only affects the single individual computer who's "hosts" file you modified. E.g. if you modify the "hosts" file on your Windows Server machine, only that machine will resolve correctly.

This is appropriate as a quick solution when you need a hostname defined on just one or two specific computers. If you need something that works network-wide.... install the DNS service on your windows server and start using it!
Then you can't...

Hostnames can't contain '.' in the name

What you have shown there is a hostname of
with a subdomain of b
another subdomain c
and the final domain .com

Without a DNS server and the same zones setup this isn't possible...

What is it you are trying to achieve?
legolasthehansyAuthor Commented:
Thanks - This was what I was looking for.
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

legolasthehansyAuthor Commented:
I guess I gave up too soon on this one -

On right click My Computer -> Under Computer Name, Domain and Workgroup settings, Click change settings -> Click on More -> In Primary DNS suffix of this computer give and click OK and in computer name give a

That should do it.
Nice, good solutions, never tried that one before...
A bit more clarification on legolasthehansy's suggestion - this ultimately uses DNS for name resolution but provides several "shortcuts" useful for reducing the maintenance needed in a changing network environment.

By giving the computer a primary DNS suffix of "", it means that when you attempt to resolve names that are NOT fully qualified domain names, it will tack the suffix onto the end of the name. For example you try to resolve "mycomputer", the system will automatically assume you really meant "", and perform DNS resolution on that name. This lets users just type the beginning part of the computer name instead of having to always type the FQDN, but it is strictly a shortcut.

When you give a computer a name (e.g. in System Properties->Computer Name), you are giving the computer a hostname which it will report to the network in two ways:

       - NetBIOS
       - Automatic registration with the local DNS server

NetBIOS is a flaky cludge of a name resolution service that Windows automatically implements, it works sometimes for network discovery but I generally suggest avoiding it altogether as it usually just confuses things, so I won't talk about that further.

More interesting is the automatic DNS registration - in domain environments with a local DNS server, computers on the network can register themselves automatically. This alleviates the network administrator's headache of having to manually maintain all the "A" records of all the desktops and laptops on the network.

In a windows domain environment, computers can join the domain, and then report their hostnames to the local DNS server. Other computers apply a similarly named DNS suffix. The end result is you can just ping computers by their hostname and everything "magically" resolves and works.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.