source: chapter09/network.xml@ fcc02767

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 fcc02767 was fcc02767, checked in by Bruce Dubbs <bdubbs@…>, 18 months ago

Initial commit of alternative cross LFS

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

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