[7152faa] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[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 |
|
---|
[afcfd74] | 8 | <sect1 id="ch-config-network" revision="sysv">
|
---|
[d781ffb] | 9 | <?dbhtml filename="network.html"?>
|
---|
| 10 |
|
---|
[0cda898] | 11 | <title>General Network Configuration</title>
|
---|
[d781ffb] | 12 |
|
---|
[afcfd74] | 13 | <indexterm zone="ch-config-network">
|
---|
[d781ffb] | 14 | <primary sortas="d-network">network</primary>
|
---|
| 15 | <secondary>configuring</secondary></indexterm>
|
---|
| 16 |
|
---|
| 17 | <sect2>
|
---|
| 18 | <title>Creating Network Interface Configuration Files</title>
|
---|
| 19 |
|
---|
[c5c1e86] | 20 | <para>The files in <filename class="directory">/etc/sysconfig/</filename>
|
---|
| 21 | usually determine which interfaces are brought up and down by the network
|
---|
| 22 | script. This directory should
|
---|
[0cda898] | 23 | contain a file for each interface to be configured, such as
|
---|
[c5c1e86] | 24 | <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> describes
|
---|
[94cea1d] | 25 | the network card. The interface name (e.g. eth0) is usually appropriate.
|
---|
[c5c1e86] | 26 | Each file contains the attributes of one interface, such as its IP
|
---|
| 27 | address(es), subnet masks, and so forth. The stem of
|
---|
| 28 | the filename must be <emphasis>ifconfig</emphasis>.</para>
|
---|
[cba2d4e] | 29 |
|
---|
[1966b8d] | 30 | <note>
|
---|
| 31 | <para>If the procedure in the previous section was not used, udev
|
---|
| 32 | will assign network card interface names based on system physical
|
---|
| 33 | characteristics such as enp2s1. If you are not sure what your interface
|
---|
| 34 | name is, you can always run <command>ip link</command> or <command>ls
|
---|
| 35 | /sys/class/net</command> after you have booted your system.
|
---|
| 36 | </para>
|
---|
| 37 |
|
---|
| 38 | <para>The interface names depend on the implementation and
|
---|
| 39 | configuration of the udev daemon running on the system. The udev
|
---|
[a289860] | 40 | daemon for LFS (installed in <xref linkend="ch-system-udev"/>) will
|
---|
[c5c1e86] | 41 | not run until the LFS system is booted. So the interface names
|
---|
| 42 | in the LFS system cannot always be determined by running
|
---|
[1966b8d] | 43 | those commands on the host distro,
|
---|
[c5c1e86] | 44 | <emphasis>even in the chroot environment</emphasis>.</para>
|
---|
[1966b8d] | 45 | </note>
|
---|
[0cda898] | 46 |
|
---|
| 47 | <para>The following command creates a sample file for the
|
---|
| 48 | <emphasis>eth0</emphasis> device with a static IP address:</para>
|
---|
[8154126] | 49 | <!-- jhalfs relies on the values for IFACE, IP, etc. If you want to change
|
---|
[93058448] | 50 | them, please inform the jhalfs maintainer(s). -->
|
---|
[0cda898] | 51 | <screen><userinput>cd /etc/sysconfig/
|
---|
[cdf7a68] | 52 | cat > ifconfig.<replaceable>eth0</replaceable> << "EOF"
|
---|
| 53 | <literal>ONBOOT=<replaceable>yes</replaceable>
|
---|
| 54 | IFACE=<replaceable>eth0</replaceable>
|
---|
| 55 | SERVICE=<replaceable>ipv4-static</replaceable>
|
---|
| 56 | IP=<replaceable>192.168.1.2</replaceable>
|
---|
| 57 | GATEWAY=<replaceable>192.168.1.1</replaceable>
|
---|
| 58 | PREFIX=<replaceable>24</replaceable>
|
---|
| 59 | BROADCAST=<replaceable>192.168.1.255</replaceable></literal>
|
---|
[f67f5cf] | 60 | EOF</userinput></screen>
|
---|
[00a2bd12] | 61 |
|
---|
[c5c1e86] | 62 | <para>The values in italics must be changed in each file, to set
|
---|
| 63 | the interfaces up correctly.</para>
|
---|
[0cda898] | 64 |
|
---|
[360fdfca] | 65 | <para>If the <envar>ONBOOT</envar> variable is set to <literal>yes</literal> the
|
---|
[cba2d4e] | 66 | System V network script will bring up the Network Interface Card (NIC) during
|
---|
[360fdfca] | 67 | the system boot process. If set to anything besides <literal>yes</literal>, the NIC
|
---|
[c5c1e86] | 68 | will be ignored by the network script and will not be started automatically.
|
---|
| 69 | Interfaces can be manually started or stopped with the
|
---|
[0cda898] | 70 | <command>ifup</command> and <command>ifdown</command> commands.</para>
|
---|
| 71 |
|
---|
| 72 | <para>The <envar>IFACE</envar> variable defines the interface name,
|
---|
[2ca8941] | 73 | for example, eth0. It is required for all network device configuration
|
---|
[cdf7a68] | 74 | files. The filename extension must match this value.</para>
|
---|
[d781ffb] | 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
|
---|
[f874424] | 79 | class="directory">/lib/services/</filename> directory allows other IP
|
---|
[0cda898] | 80 | assignment methods. This is commonly used for Dynamic Host Configuration
|
---|
| 81 | Protocol (DHCP), which is addressed in the BLFS book.</para>
|
---|
[d781ffb] | 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 |
|
---|
[c5c1e86] | 87 | <para>The <envar>PREFIX</envar> variable specifies the number of
|
---|
| 88 | bits used in the subnet. Each segment of an IP address is 8 bits. If the
|
---|
| 89 | subnet's netmask is 255.255.255.0, then it is using the first three segments
|
---|
[d781ffb] | 90 | (24 bits) to specify the network number. If the netmask is 255.255.255.240,
|
---|
[c5c1e86] | 91 | the subnet is using the first 28 bits. Prefixes longer than 24 bits are
|
---|
[d781ffb] | 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
|
---|
[7bfe7df] | 94 | <envar>PREFIX</envar> variable according to your specific subnet.
|
---|
[970a126] | 95 | If omitted, the PREFIX defaults to 24.</para>
|
---|
| 96 |
|
---|
| 97 | <para>For more information see the <command>ifup</command> man page.</para>
|
---|
[d781ffb] | 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 |
|
---|
[94cea1d] | 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
|
---|
[d781ffb] | 111 | <filename>/etc/resolv.conf</filename>. Create the file by running the
|
---|
| 112 | following:</para>
|
---|
[45340ae] | 113 |
|
---|
[f67f5cf] | 114 | <screen><userinput>cat > /etc/resolv.conf << "EOF"
|
---|
[d72e04a] | 115 | <literal># Begin /etc/resolv.conf
|
---|
[45340ae] | 116 |
|
---|
[4b51ca76] | 117 | domain <replaceable><Your Domain Name></replaceable>
|
---|
[0090db5] | 118 | nameserver <replaceable><IP address of your primary nameserver></replaceable>
|
---|
| 119 | nameserver <replaceable><IP address of your secondary nameserver></replaceable>
|
---|
[45340ae] | 120 |
|
---|
[d72e04a] | 121 | # End /etc/resolv.conf</literal>
|
---|
[f67f5cf] | 122 | EOF</userinput></screen>
|
---|
[45340ae] | 123 |
|
---|
[0cda898] | 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 |
|
---|
[0090db5] | 128 | <para>Replace <replaceable><IP address of the nameserver></replaceable>
|
---|
[d781ffb] | 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>
|
---|
[45340ae] | 134 |
|
---|
[94cea1d] | 135 | <note>
|
---|
| 136 | <para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para>
|
---|
| 137 | </note>
|
---|
[0cda898] | 138 |
|
---|
[d781ffb] | 139 | </sect2>
|
---|
[c858814a] | 140 |
|
---|
[afcfd74] | 141 | <sect2 id="ch-config-hostname">
|
---|
[c5c1e86] | 142 | <title>Configuring the System Hostname</title>
|
---|
[bf58c1e] | 143 |
|
---|
[afcfd74] | 144 | <indexterm zone="ch-config-hostname">
|
---|
[bf58c1e] | 145 | <primary sortas="d-hostname">hostname</primary>
|
---|
| 146 | <secondary>configuring</secondary>
|
---|
| 147 | </indexterm>
|
---|
| 148 |
|
---|
[b3eb525] | 149 | <para>During the boot process, the file <filename>/etc/hostname</filename>
|
---|
| 150 | is used for establishing the system's hostname.</para>
|
---|
[bf58c1e] | 151 |
|
---|
| 152 | <para>Create the <filename>/etc/hostname</filename> file and enter a
|
---|
| 153 | hostname by running:</para>
|
---|
| 154 |
|
---|
| 155 | <screen><userinput>echo "<replaceable><lfs></replaceable>" > /etc/hostname</userinput></screen>
|
---|
| 156 |
|
---|
| 157 | <para><replaceable><lfs></replaceable> needs to be replaced with the
|
---|
| 158 | name given to the computer. Do not enter the Fully Qualified Domain Name
|
---|
[c5c1e86] | 159 | (FQDN) here. That information goes in the
|
---|
[bf58c1e] | 160 | <filename>/etc/hosts</filename> file.</para>
|
---|
| 161 |
|
---|
| 162 | </sect2>
|
---|
| 163 |
|
---|
[afcfd74] | 164 | <sect2 id="ch-config-hosts">
|
---|
[bf58c1e] | 165 | <title>Customizing the /etc/hosts File</title>
|
---|
| 166 |
|
---|
[afcfd74] | 167 | <indexterm zone="ch-config-hosts">
|
---|
[bf58c1e] | 168 | <primary sortas="e-/etc/hosts">/etc/hosts</primary>
|
---|
| 169 | </indexterm>
|
---|
[c34b4fb] | 170 |
|
---|
[afcfd74] | 171 | <indexterm zone="ch-config-hosts">
|
---|
[bf58c1e] | 172 | <primary sortas="d-localnet">localnet</primary>
|
---|
| 173 | <secondary>/etc/hosts</secondary>
|
---|
| 174 | </indexterm>
|
---|
[c34b4fb] | 175 |
|
---|
[afcfd74] | 176 | <indexterm zone="ch-config-hosts">
|
---|
[bf58c1e] | 177 | <primary sortas="d-network">network</primary>
|
---|
| 178 | <secondary>/etc/hosts</secondary>
|
---|
| 179 | </indexterm>
|
---|
[c34b4fb] | 180 |
|
---|
[ba40e32] | 181 | <para>Decide on a fully-qualified domain name (FQDN), and possible aliases
|
---|
| 182 | for use in the <filename>/etc/hosts</filename> file. If using static IP
|
---|
| 183 | addresses, you'll also need to decide on an IP address. The syntax
|
---|
| 184 | for a hosts file entry is:</para>
|
---|
[c34b4fb] | 185 |
|
---|
[bf58c1e] | 186 | <screen><literal>IP_address myhost.example.org aliases</literal></screen>
|
---|
| 187 |
|
---|
| 188 | <para>Unless the computer is to be visible to the Internet (i.e., there is
|
---|
| 189 | a registered domain and a valid block of assigned IP addresses—most
|
---|
| 190 | users do not have this), make sure that the IP address is in the private
|
---|
| 191 | network IP address range. Valid ranges are:</para>
|
---|
| 192 |
|
---|
| 193 | <screen><literal>Private Network Address Range Normal Prefix
|
---|
| 194 | 10.0.0.1 - 10.255.255.254 8
|
---|
| 195 | 172.x.0.1 - 172.x.255.254 16
|
---|
| 196 | 192.168.y.1 - 192.168.y.254 24</literal></screen>
|
---|
| 197 |
|
---|
| 198 | <para>x can be any number in the range 16-31. y can be any number in the
|
---|
| 199 | range 0-255.</para>
|
---|
[c34b4fb] | 200 |
|
---|
[ba40e32] | 201 | <para>A valid private IP address could be 192.168.1.1.</para>
|
---|
[c34b4fb] | 202 |
|
---|
[ba40e32] | 203 | <para>If the computer is to be visible to the Internet, a valid FQDN
|
---|
| 204 | can be the domain name itself, or a string resulted by concatenating a
|
---|
| 205 | prefix (often the hostname) and the domain name with a <quote>.</quote>
|
---|
| 206 | character. And, you need to contact the domain provider to resolve the
|
---|
| 207 | FQDN to your public IP address.</para>
|
---|
| 208 |
|
---|
| 209 | <para>Even if the computer is not visible to the Internet, a FQDN is
|
---|
| 210 | still needed for certain programs, such as MTAs, to operate properly.
|
---|
| 211 | A special FQDN, <literal>localhost.localdomain</literal>, can be used
|
---|
| 212 | for this purpose.</para>
|
---|
[c34b4fb] | 213 |
|
---|
[bf58c1e] | 214 | <para>Create the <filename>/etc/hosts</filename> file by running:</para>
|
---|
| 215 |
|
---|
| 216 | <screen><userinput>cat > /etc/hosts << "EOF"
|
---|
[94cea1d] | 217 | <literal># Begin /etc/hosts
|
---|
[bf58c1e] | 218 |
|
---|
[c300794] | 219 | 127.0.0.1 localhost.localdomain localhost
|
---|
[bd4a1d9] | 220 | 127.0.1.1 <replaceable><FQDN></replaceable> <replaceable><HOSTNAME></replaceable>
|
---|
| 221 | <replaceable><192.168.1.1></replaceable> <replaceable><FQDN></replaceable> <replaceable><HOSTNAME></replaceable> <replaceable>[alias1] [alias2 ...]</replaceable>
|
---|
| 222 | ::1 localhost ip6-localhost ip6-loopback
|
---|
| 223 | ff02::1 ip6-allnodes
|
---|
| 224 | ff02::2 ip6-allrouters
|
---|
[bf58c1e] | 225 |
|
---|
[94cea1d] | 226 | # End /etc/hosts</literal>
|
---|
[bf58c1e] | 227 | EOF</userinput></screen>
|
---|
| 228 |
|
---|
[bd4a1d9] | 229 | <para>The <replaceable><192.168.1.1></replaceable>,
|
---|
[c34b4fb] | 230 | <replaceable><FQDN></replaceable>, and
|
---|
[bd4a1d9] | 231 | <replaceable><HOSTNAME></replaceable> values need to be
|
---|
[bf58c1e] | 232 | changed for specific uses or requirements (if assigned an IP address by a
|
---|
| 233 | network/system administrator and the machine will be connected to an
|
---|
| 234 | existing network). The optional alias name(s) can be omitted.</para>
|
---|
[94cea1d] | 235 |
|
---|
| 236 | <!-- This is not very useful
|
---|
| 237 |
|
---|
[bf58c1e] | 238 | <para>If a network card is not going to be configured, create the
|
---|
| 239 | <filename>/etc/hosts</filename> file by running:</para>
|
---|
| 240 |
|
---|
| 241 | <screen role="nodump"><userinput>cat > /etc/hosts << "EOF"
|
---|
| 242 | <literal># Begin /etc/hosts (no network card version)
|
---|
| 243 |
|
---|
[bd4a1d9] | 244 | 127.0.0.1 localhost
|
---|
| 245 | 127.0.1.1 <replaceable><FQDN></replaceable> <replaceable><HOSTNAME></replaceable>
|
---|
| 246 | ::1 localhost ip6-localhost ip6-loopback
|
---|
| 247 | ff02::1 ip6-allnodes
|
---|
| 248 | ff02::2 ip6-allrouters
|
---|
[bf58c1e] | 249 |
|
---|
| 250 | # End /etc/hosts (no network card version)</literal>
|
---|
[94cea1d] | 251 | EOF</userinput></screen> -->
|
---|
[bf58c1e] | 252 |
|
---|
| 253 | </sect2>
|
---|
| 254 |
|
---|
[d781ffb] | 255 | </sect1>
|
---|