1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="ch-scripts-network">
|
---|
9 | <?dbhtml filename="network.html"?>
|
---|
10 |
|
---|
11 | <title>General Network Configuration</title>
|
---|
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
|
---|
24 | depends on the files in <filename
|
---|
25 | class="directory">/etc/sysconfig/</filename>. This directory should
|
---|
26 | contain a file for each interface to be configured, such as
|
---|
27 | <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> is
|
---|
28 | required to be a Network Card Interface name (e.g. eth0).
|
---|
29 | Inside this file are attributes to this interface, such as its IP
|
---|
30 | address(es), subnet masks, and so forth. It is necessary that
|
---|
31 | the stem of the filename be <emphasis>ifconfig</emphasis>.</para>
|
---|
32 |
|
---|
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 |
|
---|
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"
|
---|
48 | <literal>IFACE=eth0
|
---|
49 | SERVICE=ipv4-static
|
---|
50 | IP=192.168.1.1
|
---|
51 | GATEWAY=192.168.1.2
|
---|
52 | PREFIX=24
|
---|
53 | BROADCAST=192.168.1.255</literal>
|
---|
54 | EOF</userinput></screen>
|
---|
55 |
|
---|
56 | <para>The values of these variables must be changed in every file to match
|
---|
57 | the proper setup.</para>
|
---|
58 |
|
---|
59 | <para>The <envar>IFACE</envar> variable defines the interface name,
|
---|
60 | for example, eth0. It is required for all network device configuration
|
---|
61 | files.</para>
|
---|
62 |
|
---|
63 | <para>The <envar>SERVICE</envar> variable defines the method used for
|
---|
64 | obtaining the IP address. The LFS-Network-Scripts package has a modular
|
---|
65 | IP assignment format, and creating additional files in the <filename
|
---|
66 | class="directory">/lib/services/</filename> directory allows other IP
|
---|
67 | assignment methods. This is commonly used for Dynamic Host Configuration
|
---|
68 | Protocol (DHCP), which is addressed in the BLFS book.</para>
|
---|
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 |
|
---|
74 | <para>The <envar>PREFIX</envar> variable contains the number of
|
---|
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
|
---|
81 | <envar>PREFIX</envar> variable according to your specific subnet.
|
---|
82 | If omitted, the PREFIX defaults to 24.</para>
|
---|
83 |
|
---|
84 | <para>For more information see the <command>ifup</command> man page.</para>
|
---|
85 |
|
---|
86 | </sect2>
|
---|
87 |
|
---|
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 |
|
---|
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>
|
---|
126 |
|
---|
127 | <screen><userinput>cat > /etc/resolv.conf << "EOF"
|
---|
128 | <literal># Begin /etc/resolv.conf
|
---|
129 |
|
---|
130 | domain <replaceable><Your Domain Name></replaceable>
|
---|
131 | nameserver <replaceable><IP address of your primary nameserver></replaceable>
|
---|
132 | nameserver <replaceable><IP address of your secondary nameserver></replaceable>
|
---|
133 |
|
---|
134 | # End /etc/resolv.conf</literal>
|
---|
135 | EOF</userinput></screen>
|
---|
136 |
|
---|
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 |
|
---|
141 | <para>Replace <replaceable><IP address of the nameserver></replaceable>
|
---|
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>
|
---|
147 |
|
---|
148 | <note><para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para></note>
|
---|
149 |
|
---|
150 | </sect2>
|
---|
151 |
|
---|
152 | </sect1>
|
---|