source: chapter09/network.xml@ a3d0817

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 ml-11.0 multilib trunk xry111/git-transition xry111/glibc-2.34 xry111/tester-nohack xry111/usr-move
Last change on this file since a3d0817 was a3d0817, checked in by Bruce Dubbs <bdubbs@…>, 18 months ago

Text updated for cross2 chapter 9

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/cross2@11928 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 10.1 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-config-network" revision="sysv">
9 <?dbhtml filename="network.html"?>
10
11 <title>General Network Configuration</title>
12
13 <indexterm zone="ch-config-network">
14 <primary sortas="d-network">network</primary>
15 <secondary>configuring</secondary></indexterm>
16
17 <sect2>
18 <title>Creating Network Interface Configuration Files</title>
19
20 <para>Which interfaces are brought up and down by the network script
21 usually depends on the files in <filename
22 class="directory">/etc/sysconfig/</filename>. This directory should
23 contain a file for each interface to be configured, such as
24 <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> should describe
25 the network card. The interface name (e.g. eth0) is usually appropriate.
26 Inside this file are attributes to this interface, such as its IP
27 address(es), subnet masks, and so forth. It is necessary that the stem of
28 the filename be <emphasis>ifconfig</emphasis>.</para>
29
30 <note><para>If the procedure in the previous section was not used, udev
31 will assign network card interface names based on system physical
32 characteristics such as enp2s1. If you are not sure what your interface
33 name is, you can always run <command>ip link</command> or <command>ls
34 /sys/class/net</command> after you have booted your system.
35 </para></note>
36
37 <para>The following command creates a sample file for the
38 <emphasis>eth0</emphasis> device with a static IP address:</para>
39<!-- jhalfs relies on the values for IFACE, IP, etc. If you want to change
40 them, please inform the jhalfs maintainer(s). -->
41<screen><userinput>cd /etc/sysconfig/
42cat &gt; ifconfig.<replaceable>eth0</replaceable> &lt;&lt; "EOF"
43<literal>ONBOOT=<replaceable>yes</replaceable>
44IFACE=<replaceable>eth0</replaceable>
45SERVICE=<replaceable>ipv4-static</replaceable>
46IP=<replaceable>192.168.1.2</replaceable>
47GATEWAY=<replaceable>192.168.1.1</replaceable>
48PREFIX=<replaceable>24</replaceable>
49BROADCAST=<replaceable>192.168.1.255</replaceable></literal>
50EOF</userinput></screen>
51
52 <para>The values in italics must be changed in every file to match
53 the proper setup.</para>
54
55 <para>If the <envar>ONBOOT</envar> variable is set to <quote>yes</quote> the
56 System V network script will bring up the Network Interface Card (NIC) during
57 the system boot process. If set to anything but <quote>yes</quote> the NIC
58 will be ignored by the network script and not be automatically brought up.
59 The interface can be manually started or stopped with the
60 <command>ifup</command> and <command>ifdown</command> commands.</para>
61
62 <para>The <envar>IFACE</envar> variable defines the interface name,
63 for example, eth0. It is required for all network device configuration
64 files. The filename extension must match this value.</para>
65
66 <para>The <envar>SERVICE</envar> variable defines the method used for
67 obtaining the IP address. The LFS-Bootscripts package has a modular IP
68 assignment format, and creating additional files in the <filename
69 class="directory">/lib/services/</filename> directory allows other IP
70 assignment methods. This is commonly used for Dynamic Host Configuration
71 Protocol (DHCP), which is addressed in the BLFS book.</para>
72
73 <para>The <envar>GATEWAY</envar> variable should contain the default
74 gateway IP address, if one is present. If not, then comment out the
75 variable entirely.</para>
76
77 <para>The <envar>PREFIX</envar> variable contains the number of
78 bits used in the subnet. Each octet in an IP address is 8 bits. If the
79 subnet's netmask is 255.255.255.0, then it is using the first three octets
80 (24 bits) to specify the network number. If the netmask is 255.255.255.240,
81 it would be using the first 28 bits. Prefixes longer than 24 bits are
82 commonly used by DSL and cable-based Internet Service Providers (ISPs).
83 In this example (PREFIX=24), the netmask is 255.255.255.0. Adjust the
84 <envar>PREFIX</envar> variable according to your specific subnet.
85 If omitted, the PREFIX defaults to 24.</para>
86
87 <para>For more information see the <command>ifup</command> man page.</para>
88
89 </sect2>
90 <sect2 id="resolv.conf">
91 <title>Creating the /etc/resolv.conf File</title>
92
93 <indexterm zone="resolv.conf">
94 <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
95 </indexterm>
96
97 <para>The system will need some means of obtaining Domain Name Service
98 (DNS) name resolution to resolve Internet domain names to IP addresses, and
99 vice versa. This is best achieved by placing the IP address of the DNS
100 server, available from the ISP or network administrator, into
101 <filename>/etc/resolv.conf</filename>. Create the file by running the
102 following:</para>
103
104<screen><userinput>cat &gt; /etc/resolv.conf &lt;&lt; "EOF"
105<literal># Begin /etc/resolv.conf
106
107domain <replaceable>&lt;Your Domain Name&gt;</replaceable>
108nameserver <replaceable>&lt;IP address of your primary nameserver&gt;</replaceable>
109nameserver <replaceable>&lt;IP address of your secondary nameserver&gt;</replaceable>
110
111# End /etc/resolv.conf</literal>
112EOF</userinput></screen>
113
114 <para>The <varname>domain</varname> statement can be omitted
115 or replaced with a <varname>search</varname> statement. See the man page for
116 resolv.conf for more details.</para>
117
118 <para>Replace <replaceable>&lt;IP address of the nameserver&gt;</replaceable>
119 with the IP address of the DNS most appropriate for the setup. There will
120 often be more than one entry (requirements demand secondary servers for
121 fallback capability). If you only need or want one DNS server, remove the
122 second <emphasis>nameserver</emphasis> line from the file. The IP address
123 may also be a router on the local network.</para>
124
125 <note>
126 <para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para>
127 </note>
128
129 </sect2>
130
131 <sect2 id="ch-config-hostname">
132 <title>Configuring the system hostname</title>
133
134 <indexterm zone="ch-config-hostname">
135 <primary sortas="d-hostname">hostname</primary>
136 <secondary>configuring</secondary>
137 </indexterm>
138
139 <para>During the boot process, the file <filename>/etc/hostname</filename>
140 is used for establishing the system's hostname.</para>
141
142 <para>Create the <filename>/etc/hostname</filename> file and enter a
143 hostname by running:</para>
144
145<screen><userinput>echo "<replaceable>&lt;lfs&gt;</replaceable>" &gt; /etc/hostname</userinput></screen>
146
147 <para><replaceable>&lt;lfs&gt;</replaceable> needs to be replaced with the
148 name given to the computer. Do not enter the Fully Qualified Domain Name
149 (FQDN) here. That information is put in the
150 <filename>/etc/hosts</filename> file.</para>
151
152 </sect2>
153
154 <sect2 id="ch-config-hosts">
155 <title>Customizing the /etc/hosts File</title>
156
157 <indexterm zone="ch-config-hosts">
158 <primary sortas="e-/etc/hosts">/etc/hosts</primary>
159 </indexterm>
160
161 <indexterm zone="ch-config-hosts">
162 <primary sortas="d-localnet">localnet</primary>
163 <secondary>/etc/hosts</secondary>
164 </indexterm>
165
166 <indexterm zone="ch-config-hosts">
167 <primary sortas="d-network">network</primary>
168 <secondary>/etc/hosts</secondary>
169 </indexterm>
170
171 <para>Decide on the IP address, fully-qualified domain name (FQDN), and
172 possible aliases for use in the <filename>/etc/hosts</filename> file. The
173 syntax is:</para>
174
175<screen><literal>IP_address myhost.example.org aliases</literal></screen>
176
177 <para>Unless the computer is to be visible to the Internet (i.e., there is
178 a registered domain and a valid block of assigned IP addresses&mdash;most
179 users do not have this), make sure that the IP address is in the private
180 network IP address range. Valid ranges are:</para>
181
182<screen><literal>Private Network Address Range Normal Prefix
18310.0.0.1 - 10.255.255.254 8
184172.x.0.1 - 172.x.255.254 16
185192.168.y.1 - 192.168.y.254 24</literal></screen>
186
187 <para>x can be any number in the range 16-31. y can be any number in the
188 range 0-255.</para>
189
190 <para>A valid private IP address could be 192.168.1.1. A valid FQDN for
191 this IP could be lfs.example.org.</para>
192
193 <para>Even if not using a network card, a valid FQDN is still required.
194 This is necessary for certain programs to operate correctly.</para>
195
196 <para>Create the <filename>/etc/hosts</filename> file by running:</para>
197
198<screen><userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"
199<literal># Begin /etc/hosts
200
201127.0.0.1 localhost.localdomain localhost
202127.0.1.1 <replaceable>&lt;FQDN&gt;</replaceable> <replaceable>&lt;HOSTNAME&gt;</replaceable>
203<replaceable>&lt;192.168.1.1&gt;</replaceable> <replaceable>&lt;FQDN&gt;</replaceable> <replaceable>&lt;HOSTNAME&gt;</replaceable> <replaceable>[alias1] [alias2 ...]</replaceable>
204::1 localhost ip6-localhost ip6-loopback
205ff02::1 ip6-allnodes
206ff02::2 ip6-allrouters
207
208# End /etc/hosts</literal>
209EOF</userinput></screen>
210
211 <para>The <replaceable>&lt;192.168.1.1&gt;</replaceable>,
212 <replaceable>&lt;FQDN&gt;</replaceable>, and
213 <replaceable>&lt;HOSTNAME&gt;</replaceable> values need to be
214 changed for specific uses or requirements (if assigned an IP address by a
215 network/system administrator and the machine will be connected to an
216 existing network). The optional alias name(s) can be omitted.</para>
217
218<!-- This is not very useful
219
220 <para>If a network card is not going to be configured, create the
221 <filename>/etc/hosts</filename> file by running:</para>
222
223<screen role="nodump"><userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"
224<literal># Begin /etc/hosts (no network card version)
225
226127.0.0.1 localhost
227127.0.1.1 <replaceable>&lt;FQDN&gt;</replaceable> <replaceable>&lt;HOSTNAME&gt;</replaceable>
228::1 localhost ip6-localhost ip6-loopback
229ff02::1 ip6-allnodes
230ff02::2 ip6-allrouters
231
232# End /etc/hosts (no network card version)</literal>
233EOF</userinput></screen> -->
234
235 </sect2>
236
237</sect1>
Note: See TracBrowser for help on using the repository browser.