Changeset bf58c1e for chapter07/network.xml
- Timestamp:
- 04/21/2014 09:44:04 PM (10 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- 5af3f9e
- Parents:
- c65dd23e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/network.xml
rc65dd23e rbf58c1e 25 25 installed in <xref linkend="ch-scripts-bootscripts"/>.</para> 26 26 27 <sect2 id='stable-net-names'>28 <title>Creating stable names for network interfaces</title>29 30 <para>If there is only one network interface in the system to be31 configured, this section is optional, although it will never be wrong to do32 it. In many cases (e.g. a laptop with a wireless and a wired interface),33 accomplishing the configuration in this section is necessary.</para>34 35 <para>With Udev and modular network drivers, the network interface numbering36 is not persistent across reboots by default, because the drivers are loaded37 in parallel and, thus, in random order. For example, on a computer having38 two network cards made by Intel and Realtek, the network card manufactured39 by Intel may become <filename class="devicefile">eth0</filename> and the40 Realtek card becomes <filename class="devicefile">eth1</filename>. In some41 cases, after a reboot the cards get renumbered the other way around. To42 avoid this, Udev comes with a script and some rules to assign stable names43 to network cards based on their MAC address.</para>44 45 <para>If using the traditional network interface names such as eth0 is desired,46 generate a custom Udev rule:</para>47 48 <screen><userinput>bash /lib/udev/init-net-rules.sh</userinput></screen>49 50 <para> Now, inspect the51 <filename>/etc/udev/rules.d/70-persistent-net.rules</filename> file, to52 find out which name was assigned to which network device:</para>53 54 <screen role="nodump"><userinput>cat /etc/udev/rules.d/70-persistent-net.rules</userinput></screen>55 56 <note><para>In some cases such as when MAC addresess have been assigned to57 a network card manually or in a virtual environment such as Xen,58 the network rules file may not have been generated because addresses59 are not consistently assigned. In these cases, just continue to60 the next section.</para></note>61 62 <para>The file begins with a comment block followed by two lines for each63 NIC. The first line for each NIC is a commented description showing its64 hardware IDs (e.g. its PCI vendor and device IDs, if it's a PCI card),65 along with its driver in parentheses, if the driver can be found. Neither66 the hardware ID nor the driver is used to determine which name to give an67 interface; this information is only for reference. The second line is the68 Udev rule that matches this NIC and actually assigns it a name.</para>69 70 <para>All Udev rules are made up of several keys, separated by commas and71 optional whitespace. This rule's keys and an explanation of each of them72 are as follows:</para>73 74 <itemizedlist>75 <listitem>76 <para><literal>SUBSYSTEM=="net"</literal> - This tells Udev to ignore77 devices that are not network cards.</para>78 </listitem>79 <listitem>80 <para><literal>ACTION=="add"</literal> - This tells Udev to ignore this81 rule for a uevent that isn't an add ("remove" and "change" uevents also82 happen, but don't need to rename network interfaces).</para>83 </listitem>84 <listitem>85 <para><literal>DRIVERS=="?*"</literal> - This exists so that Udev will86 ignore VLAN or bridge sub-interfaces (because these sub-interfaces do87 not have drivers). These sub-interfaces are skipped because the name88 that would be assigned would collide with their parent devices.</para>89 </listitem>90 <listitem>91 <para><literal>ATTR{address}</literal> - The value of this key is the92 NIC's MAC address.</para>93 </listitem>94 <listitem>95 <para><literal>ATTR{type}=="1"</literal> - This ensures the rule only96 matches the primary interface in the case of certain wireless drivers,97 which create multiple virtual interfaces. The secondary interfaces are98 skipped for the same reason that VLAN and bridge sub-interfaces are99 skipped: there would be a name collision otherwise.</para>100 </listitem>101 <listitem>102 <para><literal>KERNEL=="eth*"</literal> - This key was added to the103 Udev rule generator to handle machines that have multiple network104 interfaces, all with the same MAC address (the PS3 is one such105 machine). If the independent interfaces have different basenames,106 this key will allow Udev to tell them apart. This is generally not107 necessary for most Linux From Scratch users, but does not hurt.</para>108 </listitem>109 <listitem>110 <para><literal>NAME</literal> - The value of this key is the name that111 Udev will assign to this interface.</para>112 </listitem>113 </itemizedlist>114 115 <para>The value of <literal>NAME</literal> is the important part. Make sure116 you know which name has been assigned to each of your network cards before117 proceeding, and be sure to use that <literal>NAME</literal> value when118 creating your configuration files below.</para>119 120 </sect2>121 122 27 <sect2> 123 28 <title>Creating Network Interface Configuration Files</title> 124 29 125 30 <para>Which interfaces are brought up and down by the network script 126 depends on the files in <filename31 usually depends on the files in <filename 127 32 class="directory">/etc/sysconfig/</filename>. This directory should 128 33 contain a file for each interface to be configured, such as … … 217 122 name as described on the beginning of this page.</para> 218 123 124 <note><para>These procedures require the configuartion files as specified 125 in the previous section.</para></note> 126 219 127 <note><para>The network card can also be started or stopped 220 128 with the traditional <command>ifup <device></command> or 221 129 <command>ifdown <device></command> commands.</para></note> 130 131 </sect2> 132 133 <sect2 id="systemd2-net-enable"> 134 <title>Configuring the Network Interface Card for systemd-networkd</title> 135 136 <para>An alternative way to configure a NIC when booting with with 137 systemd is to create a configuration file recognized by the 138 systemd-networkd daemon. To configure the device create a file similar 139 to this:</para> 140 141 <screen role="nodump"><userinput>cat > /etc/systemd/network/10-static-eth0.network << "EOF" 142 [Match] 143 Name=eth0 144 145 [Network] 146 Address=192.168.0.2/24 147 Gateway=192.168.0.1 148 EOF</userinput></screen> 149 150 <para>You can use multiple .network files if desired. You can also specify 151 DHCP=yes instead of the Address and Gateway settings. See the man page for 152 systemd.network for more details,</para> 222 153 223 154 </sect2> … … 263 194 </sect2> 264 195 196 <sect2 id="ch-scripts-hostname"> 197 <title>Configuring the system hostname</title> 198 199 <indexterm zone="ch-scripts-hostname"> 200 <primary sortas="d-hostname">hostname</primary> 201 <secondary>configuring</secondary> 202 </indexterm> 203 204 <para>During the boot process, both Systemd and System V use the same file 205 for establishing the system's hostname. This needs to be configured by 206 creating <filename>/etc/hostname</filename>.</para> 207 208 <para>Create the <filename>/etc/hostname</filename> file and enter a 209 hostname by running:</para> 210 211 <screen><userinput>echo "<replaceable><lfs></replaceable>" > /etc/hostname</userinput></screen> 212 213 <para><replaceable><lfs></replaceable> needs to be replaced with the 214 name given to the computer. Do not enter the Fully Qualified Domain Name 215 (FQDN) here. That information is put in the 216 <filename>/etc/hosts</filename> file.</para> 217 218 </sect2> 219 220 <sect2 id="ch-scripts-hosts"> 221 <title>Customizing the /etc/hosts File</title> 222 223 <indexterm zone="ch-scripts-hosts"> 224 <primary sortas="e-/etc/hosts">/etc/hosts</primary> 225 </indexterm> 226 227 <indexterm zone="ch-scripts-hosts"> 228 <primary sortas="d-localnet">localnet</primary> 229 <secondary>/etc/hosts</secondary> 230 </indexterm> 231 232 <indexterm zone="ch-scripts-hosts"> 233 <primary sortas="d-network">network</primary> 234 <secondary>/etc/hosts</secondary> 235 </indexterm> 236 237 <para>Decide on the IP address, fully-qualified domain name (FQDN), and 238 possible aliases for use in the <filename>/etc/hosts</filename> file. The 239 syntax is:</para> 240 241 <screen><literal>IP_address myhost.example.org aliases</literal></screen> 242 243 <para>Unless the computer is to be visible to the Internet (i.e., there is 244 a registered domain and a valid block of assigned IP addresses—most 245 users do not have this), make sure that the IP address is in the private 246 network IP address range. Valid ranges are:</para> 247 248 <screen><literal>Private Network Address Range Normal Prefix 249 10.0.0.1 - 10.255.255.254 8 250 172.x.0.1 - 172.x.255.254 16 251 192.168.y.1 - 192.168.y.254 24</literal></screen> 252 253 <para>x can be any number in the range 16-31. y can be any number in the 254 range 0-255.</para> 255 256 <para>A valid private IP address could be 192.168.1.1. A valid FQDN for 257 this IP could be lfs.example.org.</para> 258 259 <para>Even if not using a network card, a valid FQDN is still required. 260 This is necessary for certain programs to operate correctly.</para> 261 262 <para>Create the <filename>/etc/hosts</filename> file by running:</para> 263 264 <screen><userinput>cat > /etc/hosts << "EOF" 265 <literal># Begin /etc/hosts (network card version) 266 267 127.0.0.1 localhost 268 <replaceable><192.168.1.1></replaceable> <replaceable><HOSTNAME.example.org></replaceable> <replaceable>[alias1] [alias2 ...]</replaceable> 269 270 # End /etc/hosts (network card version)</literal> 271 EOF</userinput></screen> 272 273 <para>The <replaceable><192.168.1.1></replaceable> and 274 <replaceable><HOSTNAME.example.org></replaceable> values need to be 275 changed for specific uses or requirements (if assigned an IP address by a 276 network/system administrator and the machine will be connected to an 277 existing network). The optional alias name(s) can be omitted.</para> 278 279 <para>If a network card is not going to be configured, create the 280 <filename>/etc/hosts</filename> file by running:</para> 281 282 <screen role="nodump"><userinput>cat > /etc/hosts << "EOF" 283 <literal># Begin /etc/hosts (no network card version) 284 285 127.0.0.1 <replaceable><HOSTNAME.example.org></replaceable> <replaceable><HOSTNAME></replaceable> localhost 286 287 # End /etc/hosts (no network card version)</literal> 288 EOF</userinput></screen> 289 290 </sect2> 291 265 292 </sect1>
Note:
See TracChangeset
for help on using the changeset viewer.