source: chapter07/network.xml@ c34291a

7.5-systemd 7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since c34291a 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
RevLine 
[673b0d8]1<?xml version="1.0" encoding="ISO-8859-1"?>
[b06ca36]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[673b0d8]4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
[d781ffb]7
[3be4d97]8<sect1 id="ch-scripts-network">
[d781ffb]9 <?dbhtml filename="network.html"?>
10
[0cda898]11 <title>General Network Configuration</title>
[d781ffb]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
[0cda898]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
[a2e555d]27 <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> is
[0cda898]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
[ce5ebe1]30 address(es), subnet masks, and so forth. It is necessary that
[0cda898]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"
[d72e04a]38<literal>ONBOOT=yes
[0cda898]39IFACE=eth0
[a088964]40SERVICE=ipv4-static
[00a2bd12]41IP=192.168.1.1
[ba85054d]42GATEWAY=192.168.1.2
[c0155c7]43PREFIX=24
[d72e04a]44BROADCAST=192.168.1.255</literal>
[f67f5cf]45EOF</userinput></screen>
[00a2bd12]46
[d781ffb]47 <para>The values of these variables must be changed in every file to match
[0cda898]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,
[ce5ebe1]58 for example, eth0. It is required for all network device configuration
[0cda898]59 files. </para>
[d781ffb]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
[f874424]64 class="directory">/lib/services/</filename> directory allows other IP
[0cda898]65 assignment methods. This is commonly used for Dynamic Host Configuration
66 Protocol (DHCP), which is addressed in the BLFS book.</para>
[d781ffb]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
[19e4f62]72 <para>The <envar>PREFIX</envar> variable contains the number of
[d781ffb]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
[970a126]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>
[d781ffb]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>
[45340ae]100
[f67f5cf]101<screen><userinput>cat &gt; /etc/resolv.conf &lt;&lt; "EOF"
[d72e04a]102<literal># Begin /etc/resolv.conf
[45340ae]103
[4b51ca76]104domain <replaceable>&lt;Your Domain Name&gt;</replaceable>
[0090db5]105nameserver <replaceable>&lt;IP address of your primary nameserver&gt;</replaceable>
106nameserver <replaceable>&lt;IP address of your secondary nameserver&gt;</replaceable>
[45340ae]107
[d72e04a]108# End /etc/resolv.conf</literal>
[f67f5cf]109EOF</userinput></screen>
[45340ae]110
[0cda898]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
[0090db5]115 <para>Replace <replaceable>&lt;IP address of the nameserver&gt;</replaceable>
[d781ffb]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>
[45340ae]121
[0cda898]122 <note><para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para></note>
123
[d781ffb]124 </sect2>
[81fd230]125
[d781ffb]126</sect1>
Note: See TracBrowser for help on using the repository browser.