[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
|
---|
[94f4fb86] | 25 | class="directory">/etc/sysconfig/</filename>. This directory should
|
---|
[0cda898] | 26 | contain a file for each interface to be configured, such as
|
---|
[a2e555d] | 27 | <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> is
|
---|
[94f4fb86] | 28 | required to be a Network Card Interface name (e.g. eth0).
|
---|
[0cda898] | 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 |
|
---|
[94f4fb86] | 33 | <note><para>Udev may assign random Network Card Interface names
|
---|
| 34 | for some network cards such as enp2s1. If you are not sure what
|
---|
| 35 | your Network Card Interface name is, you can always run
|
---|
| 36 | <command>ip l</command> after you have booted your system. Again,
|
---|
| 37 | it is important that <filename>ifconfig.xyz</filename> is named
|
---|
| 38 | after correct Network Card Interface name (e.g.
|
---|
| 39 | <filename>ifconfig.enp2s1</filename> or
|
---|
| 40 | <filename>ifconfig.eth0</filename>) or Systemd will fail to bring
|
---|
| 41 | up your network interface.</para></note>
|
---|
| 42 |
|
---|
[0cda898] | 43 | <para>The following command creates a sample file for the
|
---|
| 44 | <emphasis>eth0</emphasis> device with a static IP address:</para>
|
---|
| 45 |
|
---|
| 46 | <screen><userinput>cd /etc/sysconfig/
|
---|
| 47 | cat > ifconfig.eth0 << "EOF"
|
---|
[94f4fb86] | 48 | <literal>IFACE=eth0
|
---|
[a088964] | 49 | SERVICE=ipv4-static
|
---|
[00a2bd12] | 50 | IP=192.168.1.1
|
---|
[ba85054d] | 51 | GATEWAY=192.168.1.2
|
---|
[c0155c7] | 52 | PREFIX=24
|
---|
[d72e04a] | 53 | BROADCAST=192.168.1.255</literal>
|
---|
[f67f5cf] | 54 | EOF</userinput></screen>
|
---|
[00a2bd12] | 55 |
|
---|
[d781ffb] | 56 | <para>The values of these variables must be changed in every file to match
|
---|
[0cda898] | 57 | the proper setup.</para>
|
---|
| 58 |
|
---|
| 59 | <para>The <envar>IFACE</envar> variable defines the interface name,
|
---|
[94f4fb86] | 60 | for example, eth0. It is required for all network device configuration
|
---|
| 61 | files.</para>
|
---|
[d781ffb] | 62 |
|
---|
| 63 | <para>The <envar>SERVICE</envar> variable defines the method used for
|
---|
[94f4fb86] | 64 | obtaining the IP address. The LFS-Network-Scripts package has a modular
|
---|
| 65 | IP assignment format, and creating additional files in the <filename
|
---|
[f874424] | 66 | class="directory">/lib/services/</filename> directory allows other IP
|
---|
[0cda898] | 67 | assignment methods. This is commonly used for Dynamic Host Configuration
|
---|
| 68 | Protocol (DHCP), which is addressed in the BLFS book.</para>
|
---|
[d781ffb] | 69 |
|
---|
| 70 | <para>The <envar>GATEWAY</envar> variable should contain the default
|
---|
| 71 | gateway IP address, if one is present. If not, then comment out the
|
---|
| 72 | variable entirely.</para>
|
---|
| 73 |
|
---|
[19e4f62] | 74 | <para>The <envar>PREFIX</envar> variable contains the number of
|
---|
[d781ffb] | 75 | bits used in the subnet. Each octet in an IP address is 8 bits. If the
|
---|
| 76 | subnet's netmask is 255.255.255.0, then it is using the first three octets
|
---|
| 77 | (24 bits) to specify the network number. If the netmask is 255.255.255.240,
|
---|
| 78 | it would be using the first 28 bits. Prefixes longer than 24 bits are
|
---|
| 79 | commonly used by DSL and cable-based Internet Service Providers (ISPs).
|
---|
| 80 | In this example (PREFIX=24), the netmask is 255.255.255.0. Adjust the
|
---|
[a3af16f] | 81 | <envar>PREFIX</envar> variable according to your specific subnet.
|
---|
[970a126] | 82 | If omitted, the PREFIX defaults to 24.</para>
|
---|
| 83 |
|
---|
| 84 | <para>For more information see the <command>ifup</command> man page.</para>
|
---|
[d781ffb] | 85 |
|
---|
| 86 | </sect2>
|
---|
| 87 |
|
---|
[94f4fb86] | 88 | <sect2>
|
---|
| 89 | <title>Configuring the Network Interface Card at boot</title>
|
---|
| 90 |
|
---|
| 91 | <para>Enabling of the Network Interface Card configuration is
|
---|
| 92 | done per interface. To enable Network Interface Card
|
---|
| 93 | configuration at boot, run:</para>
|
---|
| 94 |
|
---|
| 95 | <screen><userinput>systemctl enable ifupdown@eth0</userinput></screen>
|
---|
| 96 |
|
---|
| 97 | <para>To disable previously enabled Network Interface
|
---|
| 98 | Card configuration at boot, run:</para>
|
---|
| 99 |
|
---|
| 100 | <screen><userinput>systemctl disable ifupdown@eth0</userinput></screen>
|
---|
| 101 |
|
---|
| 102 | <para>To manually start the Network Interface Card configuration,
|
---|
| 103 | run:</para>
|
---|
| 104 |
|
---|
| 105 | <screen><userinput>systemctl start ifupdown@eth0</userinput></screen>
|
---|
| 106 |
|
---|
| 107 | <para>Replace eth0 with the correct Network Interface Card
|
---|
| 108 | name as described on the beginning of this page.</para>
|
---|
| 109 |
|
---|
| 110 | </sect2>
|
---|
| 111 |
|
---|
[d781ffb] | 112 | <sect2 id="resolv.conf">
|
---|
| 113 | <title>Creating the /etc/resolv.conf File</title>
|
---|
| 114 |
|
---|
| 115 | <indexterm zone="resolv.conf">
|
---|
| 116 | <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
|
---|
| 117 | </indexterm>
|
---|
| 118 |
|
---|
| 119 | <para>If the system is going to be connected to the Internet, it will
|
---|
| 120 | need some means of Domain Name Service (DNS) name resolution to
|
---|
| 121 | resolve Internet domain names to IP addresses, and vice versa. This is
|
---|
| 122 | best achieved by placing the IP address of the DNS server, available
|
---|
| 123 | from the ISP or network administrator, into
|
---|
| 124 | <filename>/etc/resolv.conf</filename>. Create the file by running the
|
---|
| 125 | following:</para>
|
---|
[45340ae] | 126 |
|
---|
[f67f5cf] | 127 | <screen><userinput>cat > /etc/resolv.conf << "EOF"
|
---|
[d72e04a] | 128 | <literal># Begin /etc/resolv.conf
|
---|
[45340ae] | 129 |
|
---|
[4b51ca76] | 130 | domain <replaceable><Your Domain Name></replaceable>
|
---|
[0090db5] | 131 | nameserver <replaceable><IP address of your primary nameserver></replaceable>
|
---|
| 132 | nameserver <replaceable><IP address of your secondary nameserver></replaceable>
|
---|
[45340ae] | 133 |
|
---|
[d72e04a] | 134 | # End /etc/resolv.conf</literal>
|
---|
[f67f5cf] | 135 | EOF</userinput></screen>
|
---|
[45340ae] | 136 |
|
---|
[0cda898] | 137 | <para>The <varname>domain</varname> statement can be omitted
|
---|
| 138 | or replaced with a <varname>search</varname> statement. See the man page for
|
---|
| 139 | resolv.conf for more details.</para>
|
---|
| 140 |
|
---|
[0090db5] | 141 | <para>Replace <replaceable><IP address of the nameserver></replaceable>
|
---|
[d781ffb] | 142 | with the IP address of the DNS most appropriate for the setup. There will
|
---|
| 143 | often be more than one entry (requirements demand secondary servers for
|
---|
| 144 | fallback capability). If you only need or want one DNS server, remove the
|
---|
| 145 | second <emphasis>nameserver</emphasis> line from the file. The IP address
|
---|
| 146 | may also be a router on the local network.</para>
|
---|
[45340ae] | 147 |
|
---|
[0cda898] | 148 | <note><para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para></note>
|
---|
| 149 |
|
---|
[d781ffb] | 150 | </sect2>
|
---|
[81fd230] | 151 |
|
---|
[d781ffb] | 152 | </sect1>
|
---|