247 lines
4.1 KiB
HTML
247 lines
4.1 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Setting the Hostname</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><LINK
|
|
REL="HOME"
|
|
TITLE="Linux Network Administrators Guide"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Configuring TCP/IP Networking"
|
|
HREF="x-087-2-iface.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Installing the Binaries"
|
|
HREF="x-087-2-iface.binaries.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Assigning IP Addresses"
|
|
HREF="x-087-2-iface.addresses.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Linux Network Administrators Guide</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x-087-2-iface.binaries.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 5. Configuring TCP/IP Networking</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x-087-2-iface.addresses.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="X-087-2-IFACE.HOSTNAME"
|
|
>5.3. Setting the Hostname</A
|
|
></H1
|
|
><P
|
|
>Most, if not all, network applications rely on you to set the local
|
|
host's name to some reasonable value. This setting is usually made
|
|
during the boot procedure by executing the <B
|
|
CLASS="COMMAND"
|
|
>hostname</B
|
|
>
|
|
command. To set the hostname to <TT
|
|
CLASS="REPLACEABLE"
|
|
><I
|
|
>name</I
|
|
></TT
|
|
>, enter:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
># <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>hostname</B
|
|
></TT
|
|
> <TT
|
|
CLASS="REPLACEABLE"
|
|
><I
|
|
>name</I
|
|
></TT
|
|
></PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
><P
|
|
>It is common practice to use the unqualified hostname without
|
|
specifying the domain name. For instance, hosts at the Virtual Brewery
|
|
(described in <A
|
|
HREF="x-087-2-appendix.brewery.html"
|
|
>Appendix A</A
|
|
>) might be
|
|
called <SPAN
|
|
CLASS="SYSTEMITEM"
|
|
>vale.vbrew.com</SPAN
|
|
> or
|
|
<SPAN
|
|
CLASS="SYSTEMITEM"
|
|
>vlager.vbrew.com</SPAN
|
|
>. These are
|
|
their official <I
|
|
CLASS="EMPHASIS"
|
|
>fully qualified domain names</I
|
|
>
|
|
(FQDNs). Their local hostnames would be the first component of the
|
|
name, such as <SPAN
|
|
CLASS="SYSTEMITEM"
|
|
>vale</SPAN
|
|
>. However,
|
|
as the local hostname is frequently used to look up the host's IP
|
|
address, you have to make sure that the resolver library is able to
|
|
look up the host's IP address. This usually means that you have to
|
|
enter the name in <TT
|
|
CLASS="FILENAME"
|
|
>/etc/hosts</TT
|
|
>.</P
|
|
><P
|
|
>
|
|
|
|
Some people suggest using the <B
|
|
CLASS="COMMAND"
|
|
>domainname</B
|
|
> command to
|
|
set the kernel's idea of a domain name to the remaining part of the
|
|
FQDN. This way you could combine the output from
|
|
<B
|
|
CLASS="COMMAND"
|
|
>hostname</B
|
|
> and <B
|
|
CLASS="COMMAND"
|
|
>domainname</B
|
|
> to get
|
|
the FQDN again. However, this is at best only half
|
|
correct. <B
|
|
CLASS="COMMAND"
|
|
>domainname</B
|
|
> is generally used to set the
|
|
host's NIS domain, which may be entirely different from the DNS domain
|
|
to which your host belongs. Instead, to ensure that the short form of
|
|
your hostname is resolvable with all recent versions of the
|
|
<B
|
|
CLASS="COMMAND"
|
|
>hostname</B
|
|
> command, either add it as an entry in your
|
|
local Domain Name Server or place the fully qualified domain name in
|
|
the <TT
|
|
CLASS="FILENAME"
|
|
>/etc/hosts</TT
|
|
> file. You may then use the
|
|
<TT
|
|
CLASS="PARAMETER"
|
|
><I
|
|
>--fqdn</I
|
|
></TT
|
|
> argument to the
|
|
<B
|
|
CLASS="COMMAND"
|
|
>hostname</B
|
|
> command, and it will print the fully
|
|
qualifed domain name.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x-087-2-iface.binaries.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x-087-2-iface.addresses.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Installing the Binaries</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x-087-2-iface.html"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Assigning IP Addresses</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |