TCP/IP Host Name Utility (hostname)
They say the best place to start is at the beginning. Therefore, in examining TCP/IP administration and troubleshooting utilities, why not begin with the basics? One of the most fundamental of tasks in diagnosing problems with a networked computer is identifying it. Just as the first thing we usually do when we meet someone is exchange names, one of the first actions an administrator takes when accessing a device is to determine its name, if it is not known. This is accomplished using the hostname utility.
You may recall from our discussion of TCP/IP name systems that there are two different ways that hosts can be named. The first way is to manually assign flat names to devices using host tables or equivalent means; this is most often used for devices that not going to be accessed on the public Internet. The second is to give a device a domain name within the Domain Name System (DNS). The hostname utility can be used for both types of named hosts, but it functions in a slightly different way for each.
On most systems, including Windows and many UNIX implementations, the hostname utility is very, very simple. When the command is entered by itself on a line with no arguments, it displays the full name of the host. If it is entered with the -s (short) parameter, then if the host name is a fully qualified DNS domain name, only the local label of the node is shown and not the full domain name; if the host has a flat (non-DNS) name the parameter has no effect. A simple example is shown in Table 283.
The hostname utility is also intended to allow an administrator to set the name of a host. The syntax for this is also simple; you just supply the name of the host as a parameter, as follows:
However, in most implementations, the use of the hostname command for setting a devices name is either disabled or restricted. In Windows systems, a special applet in the Control Panel is used to set the devices name; attempting to set it using hostname will result in an error message. In UNIX, the super-user of the system can use hostname to set the devices name, but it is more common for this to be done by other means, such as editing the configuration file /etc/hosts. Obviously, if a simple flat name is being assigned to this host, the administrator has full control over it, while if DNS is used then the proper procedures for registering the name must be followed.
In most operating systems, the -s parameter is the only one that this command supports. The parameter is not supported on all implementations of the hostname command, however; on some of these, if you use hostname -s, the system may report its host name as being -s. On certain Linux systems, a few additional parameters are included that allow different ways for the host name to be displayed, as well as some miscellaneous functions such as showing the version number of the program.
Home - Table Of Contents - Contact Us
The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005
© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.