source: chapter07/network.xml@ f3317d4

7.5-systemd 7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since f3317d4 was f3317d4, checked in by Krejzi <krejzi@…>, 11 years ago

Move Chapter 7 in place for Systemd.

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

  • Property mode set to 100644
File size: 5.3 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-scripts-network">
9 <?dbhtml filename="network.html"?>
10
11 <title>General Network Configuration</title>
12
13 <indexterm zone="ch-scripts-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 <sect2>
21 <title>Creating Network Interface Configuration Files</title>
22
23 <para>Which interfaces are brought up and down by the network script
24 depends on the files in <filename
25 class="directory">/etc/sysconfig/</filename>. This directory should
26 contain a file for each interface to be configured, such as
27 <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> is
28 meaningful to the administrator such as the device name (e.g. eth0).
29 Inside this file are attributes to this interface, such as its IP
30 address(es), subnet masks, and so forth. It is necessary that
31 the stem of the filename be <emphasis>ifconfig</emphasis>.</para>
32
33 <para>The following command creates a sample file for the
34 <emphasis>eth0</emphasis> device with a static IP address:</para>
35
36<screen><userinput>cd /etc/sysconfig/
37cat &gt; ifconfig.eth0 &lt;&lt; "EOF"
38<literal>ONBOOT=yes
39IFACE=eth0
40SERVICE=ipv4-static
41IP=192.168.1.1
42GATEWAY=192.168.1.2
43PREFIX=24
44BROADCAST=192.168.1.255</literal>
45EOF</userinput></screen>
46
47 <para>The values of these variables must be changed in every file to match
48 the proper setup.</para>
49
50 <para>If the <envar>ONBOOT</envar> variable is set to <quote>yes</quote> the
51 network script will bring up the Network Interface Card (NIC) during
52 booting of the system. If set to anything but <quote>yes</quote> the NIC
53 will be ignored by the network script and not be automatically brought up.
54 The interface can be manually started or stopped with the
55 <command>ifup</command> and <command>ifdown</command> commands.</para>
56
57 <para>The <envar>IFACE</envar> variable defines the interface name,
58 for example, eth0. It is required for all network device configuration
59 files. </para>
60
61 <para>The <envar>SERVICE</envar> variable defines the method used for
62 obtaining the IP address. The LFS-Bootscripts package has a modular IP
63 assignment format, and creating additional files in the <filename
64 class="directory">/lib/services/</filename> directory allows other IP
65 assignment methods. This is commonly used for Dynamic Host Configuration
66 Protocol (DHCP), which is addressed in the BLFS book.</para>
67
68 <para>The <envar>GATEWAY</envar> variable should contain the default
69 gateway IP address, if one is present. If not, then comment out the
70 variable entirely.</para>
71
72 <para>The <envar>PREFIX</envar> variable contains the number of
73 bits used in the subnet. Each octet in an IP address is 8 bits. If the
74 subnet's netmask is 255.255.255.0, then it is using the first three octets
75 (24 bits) to specify the network number. If the netmask is 255.255.255.240,
76 it would be using the first 28 bits. Prefixes longer than 24 bits are
77 commonly used by DSL and cable-based Internet Service Providers (ISPs).
78 In this example (PREFIX=24), the netmask is 255.255.255.0. Adjust the
79 <envar>PREFIX</envar> variable according to your specific subnet.i
80 If omitted, the PREFIX defaults to 24.</para>
81
82 <para>For more information see the <command>ifup</command> man page.</para>
83
84 </sect2>
85
86 <sect2 id="resolv.conf">
87 <title>Creating the /etc/resolv.conf File</title>
88
89 <indexterm zone="resolv.conf">
90 <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
91 </indexterm>
92
93 <para>If the system is going to be connected to the Internet, it will
94 need some means of Domain Name Service (DNS) name resolution to
95 resolve Internet domain names to IP addresses, and vice versa. This is
96 best achieved by placing the IP address of the DNS server, available
97 from the ISP or network administrator, into
98 <filename>/etc/resolv.conf</filename>. Create the file by running the
99 following:</para>
100
101<screen><userinput>cat &gt; /etc/resolv.conf &lt;&lt; "EOF"
102<literal># Begin /etc/resolv.conf
103
104domain <replaceable>&lt;Your Domain Name&gt;</replaceable>
105nameserver <replaceable>&lt;IP address of your primary nameserver&gt;</replaceable>
106nameserver <replaceable>&lt;IP address of your secondary nameserver&gt;</replaceable>
107
108# End /etc/resolv.conf</literal>
109EOF</userinput></screen>
110
111 <para>The <varname>domain</varname> statement can be omitted
112 or replaced with a <varname>search</varname> statement. See the man page for
113 resolv.conf for more details.</para>
114
115 <para>Replace <replaceable>&lt;IP address of the nameserver&gt;</replaceable>
116 with the IP address of the DNS most appropriate for the setup. There will
117 often be more than one entry (requirements demand secondary servers for
118 fallback capability). If you only need or want one DNS server, remove the
119 second <emphasis>nameserver</emphasis> line from the file. The IP address
120 may also be a router on the local network.</para>
121
122 <note><para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para></note>
123
124 </sect2>
125
126</sect1>
Note: See TracBrowser for help on using the repository browser.