[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>If static <filename>/etc/resolv.conf</filename> is desired, create
|
---|
| 105 | it by running the following command:</para>
|
---|
[45340ae] | 106 |
|
---|
[acbb08f] | 107 | <screen role="nodump"><userinput>cat > /etc/resolv.conf << "EOF"
|
---|
[d72e04a] | 108 | <literal># Begin /etc/resolv.conf
|
---|
[45340ae] | 109 |
|
---|
[4b51ca76] | 110 | domain <replaceable><Your Domain Name></replaceable>
|
---|
[0090db5] | 111 | nameserver <replaceable><IP address of your primary nameserver></replaceable>
|
---|
| 112 | nameserver <replaceable><IP address of your secondary nameserver></replaceable>
|
---|
[45340ae] | 113 |
|
---|
[d72e04a] | 114 | # End /etc/resolv.conf</literal>
|
---|
[f67f5cf] | 115 | EOF</userinput></screen>
|
---|
[45340ae] | 116 |
|
---|
[0cda898] | 117 | <para>The <varname>domain</varname> statement can be omitted
|
---|
| 118 | or replaced with a <varname>search</varname> statement. See the man page for
|
---|
| 119 | resolv.conf for more details.</para>
|
---|
| 120 |
|
---|
[0090db5] | 121 | <para>Replace <replaceable><IP address of the nameserver></replaceable>
|
---|
[d781ffb] | 122 | with the IP address of the DNS most appropriate for the setup. There will
|
---|
| 123 | often be more than one entry (requirements demand secondary servers for
|
---|
| 124 | fallback capability). If you only need or want one DNS server, remove the
|
---|
| 125 | second <emphasis>nameserver</emphasis> line from the file. The IP address
|
---|
| 126 | may also be a router on the local network.</para>
|
---|
[45340ae] | 127 |
|
---|
[0cda898] | 128 | <note><para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para></note>
|
---|
| 129 |
|
---|
[acbb08f] | 130 | <para>When using <command>systemd-networkd</command> for network
|
---|
| 131 | configuration, another daemon, <command>systemd-resolved</command>,
|
---|
| 132 | is responsible for creating the <filename>/etc/resolv.conf</filename>
|
---|
| 133 | file. It is, however, placed in a non-standard location which is
|
---|
| 134 | writable since early boot, so it is necessary to create a symlink
|
---|
| 135 | to it by running the following command:</para>
|
---|
| 136 |
|
---|
| 137 | <screen><userinput>ln -sfv /run/systemd/resolve/resolv.conf /etc/resolv.conf</userinput></screen>
|
---|
| 138 |
|
---|
| 139 | <para>This is required if you are specifying DNS entries in <filename
|
---|
| 140 | class="extension">.network</filename> files or using the built in
|
---|
| 141 | DHCP client to obtain DNS addresses.</para>
|
---|
| 142 |
|
---|
[d781ffb] | 143 | </sect2>
|
---|
[81fd230] | 144 |
|
---|
[abadfc3] | 145 | <sect2 id="ch-scripts-hostname">
|
---|
| 146 | <title>Configuring the system hostname</title>
|
---|
| 147 |
|
---|
| 148 | <indexterm zone="ch-scripts-hostname">
|
---|
| 149 | <primary sortas="d-hostname">hostname</primary>
|
---|
| 150 | <secondary>configuring</secondary>
|
---|
| 151 | </indexterm>
|
---|
| 152 |
|
---|
| 153 | <para>During the boot process, the file <filename>/etc/hostname</filename>
|
---|
| 154 | is used for establishing the system's hostname.</para>
|
---|
| 155 |
|
---|
| 156 | <para>Create the <filename>/etc/hostname</filename> file and enter a
|
---|
| 157 | hostname by running:</para>
|
---|
| 158 |
|
---|
| 159 | <screen><userinput>echo "<replaceable><lfs></replaceable>" > /etc/hostname</userinput></screen>
|
---|
| 160 |
|
---|
| 161 | <para><replaceable><lfs></replaceable> needs to be replaced with the
|
---|
| 162 | name given to the computer. Do not enter the Fully Qualified Domain Name
|
---|
| 163 | (FQDN) here. That information is put in the
|
---|
| 164 | <filename>/etc/hosts</filename> file.</para>
|
---|
| 165 |
|
---|
| 166 | </sect2>
|
---|
| 167 |
|
---|
| 168 | <sect2 id="ch-scripts-hosts">
|
---|
| 169 | <title>Customizing the /etc/hosts File</title>
|
---|
| 170 |
|
---|
| 171 | <indexterm zone="ch-scripts-hosts">
|
---|
| 172 | <primary sortas="e-/etc/hosts">/etc/hosts</primary>
|
---|
| 173 | </indexterm>
|
---|
| 174 |
|
---|
| 175 | <indexterm zone="ch-scripts-hosts">
|
---|
| 176 | <primary sortas="d-localnet">localnet</primary>
|
---|
| 177 | <secondary>/etc/hosts</secondary>
|
---|
| 178 | </indexterm>
|
---|
| 179 |
|
---|
| 180 | <indexterm zone="ch-scripts-hosts">
|
---|
| 181 | <primary sortas="d-network">network</primary>
|
---|
| 182 | <secondary>/etc/hosts</secondary>
|
---|
| 183 | </indexterm>
|
---|
| 184 |
|
---|
| 185 | <para>Decide on the IP address, fully-qualified domain name (FQDN), and
|
---|
| 186 | possible aliases for use in the <filename>/etc/hosts</filename> file. The
|
---|
| 187 | syntax is:</para>
|
---|
| 188 |
|
---|
| 189 | <screen><literal>IP_address myhost.example.org aliases</literal></screen>
|
---|
| 190 |
|
---|
| 191 | <para>Unless the computer is to be visible to the Internet (i.e., there is
|
---|
| 192 | a registered domain and a valid block of assigned IP addresses—most
|
---|
| 193 | users do not have this), make sure that the IP address is in the private
|
---|
| 194 | network IP address range. Valid ranges are:</para>
|
---|
| 195 |
|
---|
| 196 | <screen><literal>Private Network Address Range Normal Prefix
|
---|
| 197 | 10.0.0.1 - 10.255.255.254 8
|
---|
| 198 | 172.x.0.1 - 172.x.255.254 16
|
---|
| 199 | 192.168.y.1 - 192.168.y.254 24</literal></screen>
|
---|
| 200 |
|
---|
| 201 | <para>x can be any number in the range 16-31. y can be any number in the
|
---|
| 202 | range 0-255.</para>
|
---|
| 203 |
|
---|
| 204 | <para>A valid private IP address could be 192.168.1.1. A valid FQDN for
|
---|
| 205 | this IP could be lfs.example.org.</para>
|
---|
| 206 |
|
---|
| 207 | <para>Even if not using a network card, a valid FQDN is still required.
|
---|
| 208 | This is necessary for certain programs to operate correctly.</para>
|
---|
| 209 |
|
---|
| 210 | <para>Create the <filename>/etc/hosts</filename> file by running:</para>
|
---|
| 211 |
|
---|
| 212 | <screen><userinput>cat > /etc/hosts << "EOF"
|
---|
| 213 | <literal># Begin /etc/hosts (network card version)
|
---|
| 214 |
|
---|
| 215 | 127.0.0.1 localhost
|
---|
[abfa34b] | 216 | ::1 localhost
|
---|
[abadfc3] | 217 | <replaceable><192.168.0.2></replaceable> <replaceable><HOSTNAME.example.org></replaceable> <replaceable>[alias1] [alias2] ...</replaceable>
|
---|
| 218 |
|
---|
| 219 | # End /etc/hosts (network card version)</literal>
|
---|
| 220 | EOF</userinput></screen>
|
---|
| 221 |
|
---|
| 222 | <para>The <replaceable><192.168.0.2></replaceable> and
|
---|
| 223 | <replaceable><HOSTNAME.example.org></replaceable> values need to be
|
---|
| 224 | changed for specific uses or requirements (if assigned an IP address by a
|
---|
| 225 | network/system administrator and the machine will be connected to an
|
---|
| 226 | existing network). The optional alias name(s) can be omitted.</para>
|
---|
| 227 |
|
---|
| 228 | <para>If a network card is not going to be configured, create the
|
---|
| 229 | <filename>/etc/hosts</filename> file by running:</para>
|
---|
| 230 |
|
---|
| 231 | <screen role="nodump"><userinput>cat > /etc/hosts << "EOF"
|
---|
| 232 | <literal># Begin /etc/hosts (no network card version)
|
---|
| 233 |
|
---|
| 234 | 127.0.0.1 <replaceable><HOSTNAME.example.org></replaceable> <replaceable><HOSTNAME></replaceable> localhost
|
---|
[abfa34b] | 235 | ::1 localhost
|
---|
[abadfc3] | 236 |
|
---|
| 237 | # End /etc/hosts (no network card version)</literal>
|
---|
| 238 | EOF</userinput></screen>
|
---|
| 239 |
|
---|
[abfa34b] | 240 | <para>The ::1 entry is the IPv6 counterpart of 127.0.0.1 and represents the IPv6 loopback interface.</para>
|
---|
| 241 |
|
---|
[abadfc3] | 242 | </sect2>
|
---|
| 243 |
|
---|
[d781ffb] | 244 | </sect1>
|
---|