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