2004-05-03 11:59:46 +01:00
|
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2005-01-30 18:06:48 +00:00
|
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
2004-05-03 11:59:46 +01:00
|
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
|
|
%general-entities;
|
|
|
|
]>
|
2004-01-27 22:29:49 +00:00
|
|
|
<sect1 id="ch-scripts-hosts">
|
2005-01-30 11:27:57 +00:00
|
|
|
<title>Creating the /etc/hosts File</title>
|
2004-05-03 11:59:46 +01:00
|
|
|
<?dbhtml filename="hosts.html"?>
|
|
|
|
|
2005-02-19 22:16:42 +00:00
|
|
|
<indexterm zone="ch-scripts-hosts"><primary sortas="e-/etc/hosts">/etc/hosts</primary></indexterm>
|
|
|
|
|
|
|
|
<indexterm zone="ch-scripts-hosts">
|
|
|
|
<primary sortas="d-localnet">localnet</primary>
|
|
|
|
<secondary>/etc/hosts</secondary></indexterm>
|
|
|
|
|
|
|
|
<indexterm zone="ch-scripts-hosts">
|
|
|
|
<primary sortas="d-network">network</primary>
|
|
|
|
<secondary>/etc/hosts</secondary></indexterm>
|
|
|
|
|
2005-06-16 21:09:36 +01:00
|
|
|
<para>If a network card is to be configured, decide on the IP address,
|
2005-02-19 22:16:42 +00:00
|
|
|
FQDN, and possible aliases for use in the
|
|
|
|
<filename>/etc/hosts</filename> file. The syntax is:</para>
|
|
|
|
|
|
|
|
<screen><IP address> myhost.example.org aliases</screen>
|
|
|
|
|
2005-06-16 21:09:36 +01:00
|
|
|
<para>Unless the computer is to be visible to the Internet (i.e.,
|
2005-02-19 22:16:42 +00:00
|
|
|
there is a registered domain and a valid block of assigned IP
|
|
|
|
addresses—most users do not have this), make sure that the IP
|
|
|
|
address is in the private network IP address range. Valid ranges
|
|
|
|
are:</para>
|
|
|
|
|
|
|
|
<screen> Class Networks
|
|
|
|
A 10.0.0.0
|
2005-06-16 21:09:36 +01:00
|
|
|
B 172.16.0.0 through 172.31.0.255
|
|
|
|
C 192.168.0.0 through 192.168.255.255</screen>
|
2005-02-19 22:16:42 +00:00
|
|
|
|
|
|
|
<para>A valid IP address could be 192.168.1.1. A valid FQDN for this
|
|
|
|
IP could be www.linuxfromscratch.org (not recommended because this is
|
|
|
|
a valid registered domain address and could cause domain name server
|
|
|
|
issues).</para>
|
|
|
|
|
|
|
|
<para>Even if not using a network card, an FQDN is still required.
|
|
|
|
This is necessary for certain programs to operate correctly.</para>
|
|
|
|
|
|
|
|
<para>Create the <filename>/etc/hosts</filename> file by running:</para>
|
2001-07-22 20:45:10 +01:00
|
|
|
|
2004-06-19 17:54:58 +01:00
|
|
|
<screen><userinput>cat > /etc/hosts << "EOF"
|
2005-01-30 12:51:22 +00:00
|
|
|
<literal># Begin /etc/hosts (network card version)
|
2001-02-15 15:26:52 +00:00
|
|
|
|
2005-01-30 12:51:22 +00:00
|
|
|
127.0.0.1 localhost
|
|
|
|
<replaceable>[192.168.1.1]</replaceable> <replaceable>[<HOSTNAME>.example.org]</replaceable> <replaceable>[HOSTNAME]</replaceable>
|
2001-02-15 15:26:52 +00:00
|
|
|
|
2005-01-30 12:51:22 +00:00
|
|
|
# End /etc/hosts (network card version)</literal>
|
2004-06-19 17:54:58 +01:00
|
|
|
EOF</userinput></screen>
|
2001-07-22 20:45:10 +01:00
|
|
|
|
2005-02-19 22:16:42 +00:00
|
|
|
<para>The <replaceable>[192.168.1.1]</replaceable> and
|
|
|
|
<replaceable>[<HOSTNAME>.example.org]</replaceable>
|
|
|
|
values need to be changed for specific users or requirements (if
|
|
|
|
assigned an IP address by a network/system administrator and the
|
|
|
|
machine will be connected to an existing network).</para>
|
|
|
|
|
2005-01-30 12:51:22 +00:00
|
|
|
<para>If a network card is not going to be configured, create the
|
2002-01-15 21:36:04 +00:00
|
|
|
<filename>/etc/hosts</filename> file by running:</para>
|
2001-07-22 20:45:10 +01:00
|
|
|
|
2005-10-08 20:40:42 +01:00
|
|
|
<screen role="nodump"><userinput>cat > /etc/hosts << "EOF"
|
2005-01-30 12:51:22 +00:00
|
|
|
<literal># Begin /etc/hosts (no network card version)
|
2001-02-15 15:26:52 +00:00
|
|
|
|
2005-01-30 12:51:22 +00:00
|
|
|
127.0.0.1 <replaceable>[<HOSTNAME>.example.org]</replaceable> <replaceable>[HOSTNAME]</replaceable> localhost
|
2001-02-15 15:26:52 +00:00
|
|
|
|
2005-01-30 12:51:22 +00:00
|
|
|
# End /etc/hosts (no network card version)</literal>
|
2004-06-19 17:54:58 +01:00
|
|
|
EOF</userinput></screen>
|
2001-02-15 15:26:52 +00:00
|
|
|
|
|
|
|
</sect1>
|
2005-02-19 22:16:42 +00:00
|
|
|
|