Windows assign a hostname

Posted on 2012-08-14
Last Modified: 2012-08-19
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.
Question by:legolasthehansy
    LVL 24

    Expert Comment

    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?
    LVL 31

    Accepted Solution

    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!
    LVL 11

    Author Closing Comment

    Thanks - This was what I was looking for.
    LVL 11

    Author Comment

    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.
    LVL 24

    Expert Comment

    Nice, good solutions, never tried that one before...
    LVL 31

    Expert Comment

    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.

    Featured Post

    Don't lose your head updating email signatures!

    Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users should you!

    Join & Write a Comment

    Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
    Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
    This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now