[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 |
|
---|
[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 |
|
---|
| 20 | <para>Which interfaces are brought up and down by the network script
|
---|
[bf58c1e] | 21 | usually depends on the files in <filename
|
---|
[0cda898] | 22 | class="directory">/etc/sysconfig/</filename>. This directory should
|
---|
| 23 | contain a file for each interface to be configured, such as
|
---|
[94cea1d] | 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>
|
---|
[cba2d4e] | 29 |
|
---|
[a3d0817] | 30 | <note><para>If the procedure in the previous section was not used, udev
|
---|
[cba2d4e] | 31 | will assign network card interface names based on system physical
|
---|
| 32 | characteristics such as enp2s1. If you are not sure what your interface
|
---|
[94cea1d] | 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>
|
---|
[0cda898] | 36 |
|
---|
| 37 | <para>The following command creates a sample file for the
|
---|
| 38 | <emphasis>eth0</emphasis> device with a static IP address:</para>
|
---|
[8154126] | 39 | <!-- jhalfs relies on the values for IFACE, IP, etc. If you want to change
|
---|
[93058448] | 40 | them, please inform the jhalfs maintainer(s). -->
|
---|
[0cda898] | 41 | <screen><userinput>cd /etc/sysconfig/
|
---|
[cdf7a68] | 42 | cat > ifconfig.<replaceable>eth0</replaceable> << "EOF"
|
---|
| 43 | <literal>ONBOOT=<replaceable>yes</replaceable>
|
---|
| 44 | IFACE=<replaceable>eth0</replaceable>
|
---|
| 45 | SERVICE=<replaceable>ipv4-static</replaceable>
|
---|
| 46 | IP=<replaceable>192.168.1.2</replaceable>
|
---|
| 47 | GATEWAY=<replaceable>192.168.1.1</replaceable>
|
---|
| 48 | PREFIX=<replaceable>24</replaceable>
|
---|
| 49 | BROADCAST=<replaceable>192.168.1.255</replaceable></literal>
|
---|
[f67f5cf] | 50 | EOF</userinput></screen>
|
---|
[00a2bd12] | 51 |
|
---|
[cdf7a68] | 52 | <para>The values in italics must be changed in every file to match
|
---|
[0cda898] | 53 | the proper setup.</para>
|
---|
| 54 |
|
---|
| 55 | <para>If the <envar>ONBOOT</envar> variable is set to <quote>yes</quote> the
|
---|
[cba2d4e] | 56 | System V network script will bring up the Network Interface Card (NIC) during
|
---|
[a3d0817] | 57 | the system boot process. If set to anything but <quote>yes</quote> the NIC
|
---|
[0cda898] | 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,
|
---|
[2ca8941] | 63 | for example, eth0. It is required for all network device configuration
|
---|
[cdf7a68] | 64 | files. The filename extension must match this value.</para>
|
---|
[d781ffb] | 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
|
---|
[f874424] | 69 | class="directory">/lib/services/</filename> directory allows other IP
|
---|
[0cda898] | 70 | assignment methods. This is commonly used for Dynamic Host Configuration
|
---|
| 71 | Protocol (DHCP), which is addressed in the BLFS book.</para>
|
---|
[d781ffb] | 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 |
|
---|
[19e4f62] | 77 | <para>The <envar>PREFIX</envar> variable contains the number of
|
---|
[d781ffb] | 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
|
---|
[7bfe7df] | 84 | <envar>PREFIX</envar> variable according to your specific subnet.
|
---|
[970a126] | 85 | If omitted, the PREFIX defaults to 24.</para>
|
---|
| 86 |
|
---|
| 87 | <para>For more information see the <command>ifup</command> man page.</para>
|
---|
[d781ffb] | 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 |
|
---|
[94cea1d] | 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
|
---|
[d781ffb] | 101 | <filename>/etc/resolv.conf</filename>. Create the file by running the
|
---|
| 102 | following:</para>
|
---|
[45340ae] | 103 |
|
---|
[f67f5cf] | 104 | <screen><userinput>cat > /etc/resolv.conf << "EOF"
|
---|
[d72e04a] | 105 | <literal># Begin /etc/resolv.conf
|
---|
[45340ae] | 106 |
|
---|
[4b51ca76] | 107 | domain <replaceable><Your Domain Name></replaceable>
|
---|
[0090db5] | 108 | nameserver <replaceable><IP address of your primary nameserver></replaceable>
|
---|
| 109 | nameserver <replaceable><IP address of your secondary nameserver></replaceable>
|
---|
[45340ae] | 110 |
|
---|
[d72e04a] | 111 | # End /etc/resolv.conf</literal>
|
---|
[f67f5cf] | 112 | EOF</userinput></screen>
|
---|
[45340ae] | 113 |
|
---|
[0cda898] | 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 |
|
---|
[0090db5] | 118 | <para>Replace <replaceable><IP address of the nameserver></replaceable>
|
---|
[d781ffb] | 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>
|
---|
[45340ae] | 124 |
|
---|
[94cea1d] | 125 | <note>
|
---|
| 126 | <para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para>
|
---|
| 127 | </note>
|
---|
[0cda898] | 128 |
|
---|
[d781ffb] | 129 | </sect2>
|
---|
[c858814a] | 130 |
|
---|
[afcfd74] | 131 | <sect2 id="ch-config-hostname">
|
---|
[bf58c1e] | 132 | <title>Configuring the system hostname</title>
|
---|
| 133 |
|
---|
[afcfd74] | 134 | <indexterm zone="ch-config-hostname">
|
---|
[bf58c1e] | 135 | <primary sortas="d-hostname">hostname</primary>
|
---|
| 136 | <secondary>configuring</secondary>
|
---|
| 137 | </indexterm>
|
---|
| 138 |
|
---|
[b3eb525] | 139 | <para>During the boot process, the file <filename>/etc/hostname</filename>
|
---|
| 140 | is used for establishing the system's hostname.</para>
|
---|
[bf58c1e] | 141 |
|
---|
| 142 | <para>Create the <filename>/etc/hostname</filename> file and enter a
|
---|
| 143 | hostname by running:</para>
|
---|
| 144 |
|
---|
| 145 | <screen><userinput>echo "<replaceable><lfs></replaceable>" > /etc/hostname</userinput></screen>
|
---|
| 146 |
|
---|
| 147 | <para><replaceable><lfs></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 |
|
---|
[afcfd74] | 154 | <sect2 id="ch-config-hosts">
|
---|
[bf58c1e] | 155 | <title>Customizing the /etc/hosts File</title>
|
---|
| 156 |
|
---|
[afcfd74] | 157 | <indexterm zone="ch-config-hosts">
|
---|
[bf58c1e] | 158 | <primary sortas="e-/etc/hosts">/etc/hosts</primary>
|
---|
| 159 | </indexterm>
|
---|
| 160 |
|
---|
[afcfd74] | 161 | <indexterm zone="ch-config-hosts">
|
---|
[bf58c1e] | 162 | <primary sortas="d-localnet">localnet</primary>
|
---|
| 163 | <secondary>/etc/hosts</secondary>
|
---|
| 164 | </indexterm>
|
---|
| 165 |
|
---|
[afcfd74] | 166 | <indexterm zone="ch-config-hosts">
|
---|
[bf58c1e] | 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—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
|
---|
| 183 | 10.0.0.1 - 10.255.255.254 8
|
---|
| 184 | 172.x.0.1 - 172.x.255.254 16
|
---|
| 185 | 192.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 > /etc/hosts << "EOF"
|
---|
[94cea1d] | 199 | <literal># Begin /etc/hosts
|
---|
[bf58c1e] | 200 |
|
---|
[c300794] | 201 | 127.0.0.1 localhost.localdomain localhost
|
---|
[bd4a1d9] | 202 | 127.0.1.1 <replaceable><FQDN></replaceable> <replaceable><HOSTNAME></replaceable>
|
---|
| 203 | <replaceable><192.168.1.1></replaceable> <replaceable><FQDN></replaceable> <replaceable><HOSTNAME></replaceable> <replaceable>[alias1] [alias2 ...]</replaceable>
|
---|
| 204 | ::1 localhost ip6-localhost ip6-loopback
|
---|
| 205 | ff02::1 ip6-allnodes
|
---|
| 206 | ff02::2 ip6-allrouters
|
---|
[bf58c1e] | 207 |
|
---|
[94cea1d] | 208 | # End /etc/hosts</literal>
|
---|
[bf58c1e] | 209 | EOF</userinput></screen>
|
---|
| 210 |
|
---|
[bd4a1d9] | 211 | <para>The <replaceable><192.168.1.1></replaceable>,
|
---|
| 212 | <replaceable><FQDN></replaceable>, and
|
---|
| 213 | <replaceable><HOSTNAME></replaceable> values need to be
|
---|
[bf58c1e] | 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>
|
---|
[94cea1d] | 217 |
|
---|
| 218 | <!-- This is not very useful
|
---|
| 219 |
|
---|
[bf58c1e] | 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 > /etc/hosts << "EOF"
|
---|
| 224 | <literal># Begin /etc/hosts (no network card version)
|
---|
| 225 |
|
---|
[bd4a1d9] | 226 | 127.0.0.1 localhost
|
---|
| 227 | 127.0.1.1 <replaceable><FQDN></replaceable> <replaceable><HOSTNAME></replaceable>
|
---|
| 228 | ::1 localhost ip6-localhost ip6-loopback
|
---|
| 229 | ff02::1 ip6-allnodes
|
---|
| 230 | ff02::2 ip6-allrouters
|
---|
[bf58c1e] | 231 |
|
---|
| 232 | # End /etc/hosts (no network card version)</literal>
|
---|
[94cea1d] | 233 | EOF</userinput></screen> -->
|
---|
[bf58c1e] | 234 |
|
---|
| 235 | </sect2>
|
---|
| 236 |
|
---|
[d781ffb] | 237 | </sect1>
|
---|