[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>
|
---|
[abadfc3] | 21 | <title>Network Interface Configuration Files</title>
|
---|
| 22 |
|
---|
| 23 | <para>Starting with version 209, systemd ships a network configuration
|
---|
| 24 | daemon called <command>systemd-networkd</command> which can be used for
|
---|
| 25 | basic network configuration.</para>
|
---|
| 26 |
|
---|
| 27 | <para>Configuration files for <command>systemd-networkd</command> can be
|
---|
| 28 | placed in <filename class="directory">/usr/lib/systemd/network</filename>
|
---|
| 29 | or <filename class="directory">/etc/systemd/network</filename>. Note that
|
---|
| 30 | files in <filename class="directory">/etc/systemd/network</filename> have
|
---|
| 31 | higher priority than the ones in
|
---|
| 32 | <filename class="directory">/usr/lib/systemd/network</filename>.</para>
|
---|
| 33 |
|
---|
| 34 | <para>There are three types of configuration files:
|
---|
| 35 | <filename class="extension">.link</filename>,
|
---|
| 36 | <filename class="extension">.netdev</filename> and
|
---|
| 37 | <filename class="extension">.network</filename> files. For detailed
|
---|
| 38 | explanation about contents of the mentioned
|
---|
[39507e9] | 39 | configuration files, consult <filename>systemd-link(5)</filename>,
|
---|
| 40 | <filename>systemd-netdev(5)</filename> and
|
---|
| 41 | <filename>systemd-network(5)</filename> manual pages.</para>
|
---|
[abadfc3] | 42 |
|
---|
| 43 | <note><para>Udev may assign network card interface names based
|
---|
| 44 | on system physical characteristics such as enp2s1. If you are
|
---|
| 45 | not sure what your interface name is, you can always run
|
---|
| 46 | <command>ip link</command> after you have booted your system.
|
---|
| 47 | </para></note>
|
---|
| 48 |
|
---|
| 49 | <sect3 id="systemd-networkd-static">
|
---|
| 50 | <title>Static IP Configuration</title>
|
---|
| 51 |
|
---|
| 52 | <para>The command below creates a basic configuration file for
|
---|
| 53 | Static IP setup:</para>
|
---|
| 54 |
|
---|
| 55 | <screen role="nodump"><userinput>cat > /etc/systemd/network/10-static-eth0.network << "EOF"
|
---|
| 56 | <literal>[Match]
|
---|
| 57 | Name=eth0
|
---|
| 58 |
|
---|
| 59 | [Network]
|
---|
| 60 | Address=192.168.0.2/24
|
---|
| 61 | Gateway=192.168.0.1
|
---|
| 62 | DNS=192.168.0.1</literal>
|
---|
[f67f5cf] | 63 | EOF</userinput></screen>
|
---|
[00a2bd12] | 64 |
|
---|
[abadfc3] | 65 | <para>More than one DNS entry can be specified in the configuration file.</para>
|
---|
[0cda898] | 66 |
|
---|
[abadfc3] | 67 | </sect3>
|
---|
[d781ffb] | 68 |
|
---|
[abadfc3] | 69 | <sect3 id="systemd-networkd-dhcp">
|
---|
| 70 | <title>DHCP Configuration</title>
|
---|
[d781ffb] | 71 |
|
---|
[abadfc3] | 72 | <para>The command below creates a basic configuration file for
|
---|
| 73 | DHCP setup:</para>
|
---|
[d781ffb] | 74 |
|
---|
[abadfc3] | 75 | <screen role="nodump"><userinput>cat > /etc/systemd/network/10-dhcp-eth0.network << "EOF"
|
---|
| 76 | <literal>[Match]
|
---|
| 77 | Name=eth0
|
---|
[970a126] | 78 |
|
---|
[abadfc3] | 79 | [Network]
|
---|
| 80 | DHCP=yes</literal>
|
---|
| 81 | EOF</userinput></screen>
|
---|
[94f4fb86] | 82 |
|
---|
[abadfc3] | 83 | <para>Note that <command>systemd-networkd</command> can only handle
|
---|
| 84 | DHCPv4. DHCPv6 support is a work in progress.</para>
|
---|
[94f4fb86] | 85 |
|
---|
[abadfc3] | 86 | </sect3>
|
---|
[94f4fb86] | 87 |
|
---|
| 88 | </sect2>
|
---|
| 89 |
|
---|
[d781ffb] | 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 |
|
---|
| 97 | <para>If the system is going to be connected to the Internet, it will
|
---|
| 98 | need some means of Domain Name Service (DNS) name resolution to
|
---|
| 99 | resolve Internet domain names to IP addresses, and vice versa. This is
|
---|
| 100 | best achieved by placing the IP address of the DNS server, available
|
---|
| 101 | from the ISP or network administrator, into
|
---|
[abadfc3] | 102 | <filename>/etc/resolv.conf</filename>.</para>
|
---|
| 103 |
|
---|
| 104 | <para>When using <command>systemd-networkd</command> for network
|
---|
| 105 | configuration, another daemon, <command>systemd-resolved</command>,
|
---|
| 106 | is responsible for creating the <filename>/etc/resolv.conf</filename>
|
---|
| 107 | file. It is, however, placed in a non-standard location which is
|
---|
| 108 | writable since early boot, so it is necessary to create a symlink
|
---|
| 109 | to it by running the following command:</para>
|
---|
| 110 |
|
---|
| 111 | <screen><userinput>ln -sfv /run/systemd/resolve/resolv.conf /etc/resolv.conf</userinput></screen>
|
---|
| 112 |
|
---|
| 113 | <para>If static <filename>/etc/resolv.conf</filename> is desired, create
|
---|
| 114 | it by running the following command:</para>
|
---|
[45340ae] | 115 |
|
---|
[f67f5cf] | 116 | <screen><userinput>cat > /etc/resolv.conf << "EOF"
|
---|
[d72e04a] | 117 | <literal># Begin /etc/resolv.conf
|
---|
[45340ae] | 118 |
|
---|
[4b51ca76] | 119 | domain <replaceable><Your Domain Name></replaceable>
|
---|
[0090db5] | 120 | nameserver <replaceable><IP address of your primary nameserver></replaceable>
|
---|
| 121 | nameserver <replaceable><IP address of your secondary nameserver></replaceable>
|
---|
[45340ae] | 122 |
|
---|
[d72e04a] | 123 | # End /etc/resolv.conf</literal>
|
---|
[f67f5cf] | 124 | EOF</userinput></screen>
|
---|
[45340ae] | 125 |
|
---|
[0cda898] | 126 | <para>The <varname>domain</varname> statement can be omitted
|
---|
| 127 | or replaced with a <varname>search</varname> statement. See the man page for
|
---|
| 128 | resolv.conf for more details.</para>
|
---|
| 129 |
|
---|
[0090db5] | 130 | <para>Replace <replaceable><IP address of the nameserver></replaceable>
|
---|
[d781ffb] | 131 | with the IP address of the DNS most appropriate for the setup. There will
|
---|
| 132 | often be more than one entry (requirements demand secondary servers for
|
---|
| 133 | fallback capability). If you only need or want one DNS server, remove the
|
---|
| 134 | second <emphasis>nameserver</emphasis> line from the file. The IP address
|
---|
| 135 | may also be a router on the local network.</para>
|
---|
[45340ae] | 136 |
|
---|
[0cda898] | 137 | <note><para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para></note>
|
---|
| 138 |
|
---|
[d781ffb] | 139 | </sect2>
|
---|
[81fd230] | 140 |
|
---|
[abadfc3] | 141 | <sect2 id="ch-scripts-hostname">
|
---|
| 142 | <title>Configuring the system hostname</title>
|
---|
| 143 |
|
---|
| 144 | <indexterm zone="ch-scripts-hostname">
|
---|
| 145 | <primary sortas="d-hostname">hostname</primary>
|
---|
| 146 | <secondary>configuring</secondary>
|
---|
| 147 | </indexterm>
|
---|
| 148 |
|
---|
| 149 | <para>During the boot process, the file <filename>/etc/hostname</filename>
|
---|
| 150 | is used for establishing the system's hostname.</para>
|
---|
| 151 |
|
---|
| 152 | <para>Create the <filename>/etc/hostname</filename> file and enter a
|
---|
| 153 | hostname by running:</para>
|
---|
| 154 |
|
---|
| 155 | <screen><userinput>echo "<replaceable><lfs></replaceable>" > /etc/hostname</userinput></screen>
|
---|
| 156 |
|
---|
| 157 | <para><replaceable><lfs></replaceable> needs to be replaced with the
|
---|
| 158 | name given to the computer. Do not enter the Fully Qualified Domain Name
|
---|
| 159 | (FQDN) here. That information is put in the
|
---|
| 160 | <filename>/etc/hosts</filename> file.</para>
|
---|
| 161 |
|
---|
| 162 | </sect2>
|
---|
| 163 |
|
---|
| 164 | <sect2 id="ch-scripts-hosts">
|
---|
| 165 | <title>Customizing the /etc/hosts File</title>
|
---|
| 166 |
|
---|
| 167 | <indexterm zone="ch-scripts-hosts">
|
---|
| 168 | <primary sortas="e-/etc/hosts">/etc/hosts</primary>
|
---|
| 169 | </indexterm>
|
---|
| 170 |
|
---|
| 171 | <indexterm zone="ch-scripts-hosts">
|
---|
| 172 | <primary sortas="d-localnet">localnet</primary>
|
---|
| 173 | <secondary>/etc/hosts</secondary>
|
---|
| 174 | </indexterm>
|
---|
| 175 |
|
---|
| 176 | <indexterm zone="ch-scripts-hosts">
|
---|
| 177 | <primary sortas="d-network">network</primary>
|
---|
| 178 | <secondary>/etc/hosts</secondary>
|
---|
| 179 | </indexterm>
|
---|
| 180 |
|
---|
| 181 | <para>Decide on the IP address, fully-qualified domain name (FQDN), and
|
---|
| 182 | possible aliases for use in the <filename>/etc/hosts</filename> file. The
|
---|
| 183 | syntax is:</para>
|
---|
| 184 |
|
---|
| 185 | <screen><literal>IP_address myhost.example.org aliases</literal></screen>
|
---|
| 186 |
|
---|
| 187 | <para>Unless the computer is to be visible to the Internet (i.e., there is
|
---|
| 188 | a registered domain and a valid block of assigned IP addresses—most
|
---|
| 189 | users do not have this), make sure that the IP address is in the private
|
---|
| 190 | network IP address range. Valid ranges are:</para>
|
---|
| 191 |
|
---|
| 192 | <screen><literal>Private Network Address Range Normal Prefix
|
---|
| 193 | 10.0.0.1 - 10.255.255.254 8
|
---|
| 194 | 172.x.0.1 - 172.x.255.254 16
|
---|
| 195 | 192.168.y.1 - 192.168.y.254 24</literal></screen>
|
---|
| 196 |
|
---|
| 197 | <para>x can be any number in the range 16-31. y can be any number in the
|
---|
| 198 | range 0-255.</para>
|
---|
| 199 |
|
---|
| 200 | <para>A valid private IP address could be 192.168.1.1. A valid FQDN for
|
---|
| 201 | this IP could be lfs.example.org.</para>
|
---|
| 202 |
|
---|
| 203 | <para>Even if not using a network card, a valid FQDN is still required.
|
---|
| 204 | This is necessary for certain programs to operate correctly.</para>
|
---|
| 205 |
|
---|
| 206 | <para>Create the <filename>/etc/hosts</filename> file by running:</para>
|
---|
| 207 |
|
---|
| 208 | <screen><userinput>cat > /etc/hosts << "EOF"
|
---|
| 209 | <literal># Begin /etc/hosts (network card version)
|
---|
| 210 |
|
---|
| 211 | 127.0.0.1 localhost
|
---|
[abfa34b] | 212 | ::1 localhost
|
---|
[abadfc3] | 213 | <replaceable><192.168.0.2></replaceable> <replaceable><HOSTNAME.example.org></replaceable> <replaceable>[alias1] [alias2] ...</replaceable>
|
---|
| 214 |
|
---|
| 215 | # End /etc/hosts (network card version)</literal>
|
---|
| 216 | EOF</userinput></screen>
|
---|
| 217 |
|
---|
| 218 | <para>The <replaceable><192.168.0.2></replaceable> and
|
---|
| 219 | <replaceable><HOSTNAME.example.org></replaceable> values need to be
|
---|
| 220 | changed for specific uses or requirements (if assigned an IP address by a
|
---|
| 221 | network/system administrator and the machine will be connected to an
|
---|
| 222 | existing network). The optional alias name(s) can be omitted.</para>
|
---|
| 223 |
|
---|
| 224 | <para>If a network card is not going to be configured, create the
|
---|
| 225 | <filename>/etc/hosts</filename> file by running:</para>
|
---|
| 226 |
|
---|
| 227 | <screen role="nodump"><userinput>cat > /etc/hosts << "EOF"
|
---|
| 228 | <literal># Begin /etc/hosts (no network card version)
|
---|
| 229 |
|
---|
| 230 | 127.0.0.1 <replaceable><HOSTNAME.example.org></replaceable> <replaceable><HOSTNAME></replaceable> localhost
|
---|
[abfa34b] | 231 | ::1 localhost
|
---|
[abadfc3] | 232 |
|
---|
| 233 | # End /etc/hosts (no network card version)</literal>
|
---|
| 234 | EOF</userinput></screen>
|
---|
| 235 |
|
---|
[abfa34b] | 236 | <para>The ::1 entry is the IPv6 counterpart of 127.0.0.1 and represents the IPv6 loopback interface.</para>
|
---|
| 237 |
|
---|
[abadfc3] | 238 | </sect2>
|
---|
| 239 |
|
---|
[d781ffb] | 240 | </sect1>
|
---|