source: networking/connect/dhcpcd.xml

trunk
Last change on this file was 497d485, checked in by Xi Ruoyao <xry111@…>, 11 days ago

Update or remove broken URLs

Reported-by: rhubarbpieguy@…
Suggested-by: Vladimir Pertsev <info@…>

  • Property mode set to 100644
File size: 15.8 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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 <!ENTITY dhcpcd-download-http "https://github.com/NetworkConfiguration/dhcpcd/releases/download/v&dhcpcd-version;/dhcpcd-&dhcpcd-version;.tar.xz">
8 <!ENTITY dhcpcd-download-ftp " ">
9 <!ENTITY dhcpcd-md5sum "ef8356d711b17701928ead7206d15234">
10 <!ENTITY dhcpcd-size "264 KB">
11 <!ENTITY dhcpcd-buildsize "3.0 MB (with tests)">
12 <!ENTITY dhcpcd-time "less than 0.1 SBU (with tests)">
13]>
14
15<sect1 id="dhcpcd" xreflabel="dhcpcd-&dhcpcd-version;">
16 <?dbhtml filename="dhcpcd.html"?>
17
18
19 <title>dhcpcd-&dhcpcd-version;</title>
20
21 <indexterm zone="dhcpcd">
22 <primary sortas="a-dhcpcd">dhcpcd</primary>
23 </indexterm>
24
25 <sect2 role="package">
26 <title>Introduction to dhcpcd</title>
27
28 <para>
29 <application>dhcpcd</application> is an implementation of the
30 DHCP client specified in RFC2131. A DHCP client is useful for connecting
31 your computer to a network which uses DHCP to assign network
32 addresses. dhcpcd strives to be a fully featured, yet very lightweight
33 DHCP client.
34 </para>
35
36 &lfs121_checked;
37
38 <bridgehead renderas="sect3">Package Information</bridgehead>
39 <itemizedlist spacing="compact">
40 <listitem>
41 <para>
42 Download (HTTP): <ulink url="&dhcpcd-download-http;"/>
43 </para>
44 </listitem>
45 <listitem>
46 <para>
47 Download (FTP): <ulink url="&dhcpcd-download-ftp;"/>
48 </para>
49 </listitem>
50 <listitem>
51 <para>
52 Download MD5 sum: &dhcpcd-md5sum;
53 </para>
54 </listitem>
55 <listitem>
56 <para>
57 Download size: &dhcpcd-size;
58 </para>
59 </listitem>
60 <listitem>
61 <para>
62 Estimated disk space required: &dhcpcd-buildsize;
63 </para>
64 </listitem>
65 <listitem>
66 <para>
67 Estimated build time: &dhcpcd-time;
68 </para>
69 </listitem>
70 </itemizedlist>
71<!--
72
73
74 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
75 <itemizedlist spacing="compact">
76 <listitem>
77 <para>
78 Required patch:
79 <ulink url="&patch-root;/dhcpcd-&dhcpcd-version;-upstream_fixes-1.patch"/>
80 </para>
81 </listitem>
82 </itemizedlist>
83-->
84
85 <bridgehead renderas="sect3">dhcpcd Dependencies</bridgehead>
86
87 <bridgehead renderas="sect4">Optional</bridgehead>
88 <para role="optional">
89 <xref linkend="llvm"/> (with Clang),
90 <xref linkend="ntp"/>,
91 <ulink url="https://chrony-project.org/">chronyd</ulink>, and
92 <ulink url="https://github.com/thkukuk/ypbind-mt/">ypbind</ulink>
93 </para>
94
95 </sect2>
96
97 <sect2 id='dhcpcd-privsep'>
98 <title>Privilege separation</title>
99
100 <para>
101 Recent releases of <application>dhcpcd</application> optionally support
102 privilege separation. As the practical security benefits of this are
103 unclear for a program like <application>dhcpcd</application> and the
104 setup is more complicated, the book currently defaults to disable it.
105 </para>
106 <para>
107 If you however would like to use privilege separation, additional
108 installation steps are necessary to set up the proper environment. Issue
109 the following commands as the
110 <systemitem class="username">root</systemitem> user:
111 </para>
112
113<screen role="root"><userinput>install -v -m700 -d /var/lib/dhcpcd &amp;&amp;
114
115groupadd -g 52 dhcpcd &amp;&amp;
116useradd -c 'dhcpcd PrivSep' \
117 -d /var/lib/dhcpcd \
118 -g dhcpcd \
119 -s /bin/false \
120 -u 52 dhcpcd &amp;&amp;
121chown -v dhcpcd:dhcpcd /var/lib/dhcpcd </userinput></screen>
122
123 </sect2>
124
125 <sect2 role="installation">
126 <title>Installation of dhcpcd</title>
127
128<!--
129 <para>
130 First, fix an issue that occurs when running dhcpcd with the '-b' switch:
131 </para>
132
133<screen><userinput remap="pre">patch -Np1 -i ../dhcpcd-&dhcpcd-version;-upstream_fixes-1.patch</userinput></screen>
134
135-->
136 <para>
137 Build <application>dhcpcd</application> without privilege separation
138 by running the following command:
139 </para>
140
141<screen><userinput>./configure --prefix=/usr \
142 --sysconfdir=/etc \
143 --libexecdir=/usr/lib/dhcpcd \
144 --dbdir=/var/lib/dhcpcd \
145 --runstatedir=/run \
146 --disable-privsep &amp;&amp;
147make</userinput></screen>
148
149 <para>
150 Alternatively, build <application>dhcpcd</application> with privilege
151 separation by running the following commands:
152 </para>
153
154<screen role="nodump"><userinput>./configure --prefix=/usr \
155 --sysconfdir=/etc \
156 --libexecdir=/usr/lib/dhcpcd \
157 --dbdir=/var/lib/dhcpcd \
158 --runstatedir=/run \
159 --privsepuser=dhcpcd &amp;&amp;
160make</userinput></screen>
161
162 <para>
163 To test the results, issue: <command>make test</command>.
164 </para>
165
166 <para>
167 Now, as the <systemitem class="username">root</systemitem> user:
168 </para>
169
170<screen role='root'><userinput>make install</userinput></screen>
171
172<!--
173 <para>
174 By default, a plain text lease info file isn't created but the
175 <application>dhcpcd</application> provides a hook which can be used for
176 creating such a file. Install the hook by running the following commands
177 as the <systemitem class="username">root</systemitem> user:
178 </para>
179
180<screen role='root'><userinput>sed -i "s;/var/lib;/run;g" dhcpcd-hooks/50-dhcpcd-compat &amp;&amp;
181install -v -m 644 dhcpcd-hooks/50-dhcpcd-compat /lib/dhcpcd/dhcpcd-hooks/</userinput></screen>
182-->
183
184 </sect2>
185
186 <sect2 role="commands">
187 <title>Command Explanations</title>
188
189 <para>
190 <parameter>--libexecdir=/usr/lib/dhcpcd</parameter>: This switch sets a
191 better location for the dhcpcd internal libraries.
192 </para>
193
194 <para>
195 <parameter>--dbdir=/var/lib/dhcpcd</parameter>: This switch adjusts the
196 database directory because the default directory,
197 <filename class="directory">/var/db</filename>, is not FHS-compliant.
198 </para>
199
200 <para>
201 <parameter>--runstatedir=/run</parameter>: This switch sets the runtime
202 state directory because the default
203 <filename class="directory">/var/run</filename> is a symbolic
204 link to <filename class="directory">/run</filename>, and using
205 <filename class="directory">/var/run</filename> is deprecated.
206 </para>
207
208 <para>
209 <parameter>--disable-privsep</parameter>: This switch disables privilege
210 separation, which is the default in dhcpcd. This switch is not used in
211 the build configuration where privilege separation is used.
212 </para>
213
214 <para>
215 <parameter>--privsepuser=dhcpcd</parameter>: This switch sets the
216 privilege separation user in the build configuration where privilege
217 escalation is used.
218 </para>
219
220 <para>
221 <option>--with-hook=...</option>: You can optionally install more hooks,
222 for example to install some configuration files such as
223 <filename>ntp.conf</filename>. A set of hooks can be found in the
224 <filename class="directory">dhcpcd-hooks</filename> directory in the
225 build tree.
226 </para>
227 </sect2>
228
229 <sect2 role="configuration">
230 <title>Configuring dhcpcd</title>
231
232 <sect3 id="dhcpcd-config">
233 <title>Config Files</title>
234
235 <para>
236 <filename>/etc/dhcpcd.conf</filename>
237 </para>
238
239 <indexterm zone="dhcpcd dhcpcd-config">
240 <primary sortas="e-etc-dhcpcd-dhcpcd-conf">/etc/dhcpcd/dhcpcd.conf</primary>
241 </indexterm>
242
243 </sect3>
244
245 <sect3 id="dhcpcd-init" revision="sysv">
246 <title>General Configuration Information</title>
247
248 <para>
249 To configure <command>dhcpcd</command>, you need to first install
250 the network service script,
251 <filename>/usr/lib/services/dhcpcd</filename>
252 included in the <xref linkend="bootscripts"/> package
253 (as user <systemitem class="username">root</systemitem>):
254 </para>
255
256 <indexterm zone="dhcpcd dhcpcd-init">
257 <primary sortas="f-dhcpcd">dhcpcd (service script)</primary>
258 </indexterm>
259
260<screen role='root'><userinput>make install-service-dhcpcd</userinput></screen>
261
262 <note>
263 <para id="dhcpcd-config3">
264 The default for <command>dhcpcd</command> is to set the hostname
265 and mtu. It also overwrites <filename>/etc/resolv.conf </filename>
266 and <filename>/etc/ntp.conf</filename>. These
267 modifications to system files are done by hooks which are stored in
268 <filename class="directory">/usr/lib/dhcpcd/dhcpcd-hooks</filename>.
269 You can change this behavior by removing or adding hooks from/to
270 that directory. The execution of hooks can be disabled by using
271 the <option>--nohook</option> (<option>-C</option>) command line
272 option or by the <option>nohook</option> option in the
273 <filename>/etc/dhcpcd.conf</filename> file.
274 </para>
275 </note>
276
277 <para id="dhcpcd-config2">
278 Finally, as the <systemitem class="username">root</systemitem> user
279 create the <filename>/etc/sysconfig/ifconfig.eth0</filename>
280 configuration file using the following commands. Adjust appropriately
281 for additional interfaces:
282 </para>
283
284 <indexterm zone="dhcpcd dhcpcd-config2">
285 <primary sortas="e-etc-sysconfig-dhcpcd">/etc/sysconfig/ifconfig.eth0 (dhcpcd)</primary>
286 </indexterm>
287
288<screen role='root'><userinput>cat &gt; /etc/sysconfig/ifconfig.eth0 &lt;&lt; "EOF"
289<literal>ONBOOT="yes"
290IFACE="eth0"
291SERVICE="dhcpcd"
292DHCP_START="-b -q -h $HOSTNAME <replaceable>&lt;insert appropriate start options here&gt;</replaceable>"
293DHCP_STOP="-k <replaceable>&lt;insert additional stop options here&gt;</replaceable>"</literal>
294EOF</userinput></screen>
295
296 <para>
297 For more information on the appropriate <envar>DHCP_START</envar> and
298 <envar>DHCP_STOP</envar> values, examine the man page for
299 <command>dhcpcd</command>.
300 </para>
301
302 <indexterm zone="dhcpcd dhcpcd-config3">
303 <primary sortas="e-etc-resolv.conf">/etc/resolv.conf</primary>
304 </indexterm>
305 </sect3>
306
307 <sect3 id="dhcpcd-init2" revision="sysv">
308 <title>Configuration Information: fixed ip</title>
309
310 <para id="dhcpcd-config4">
311 Although not usual, it is possible that you need
312 to configure <application>dhcpcd</application> to use a fixed ip. Here,
313 we give an example. As the
314 <systemitem class="username">root</systemitem> user create the
315 <filename>/etc/sysconfig/ifconfig.eth0</filename> configuration file
316 using the following commands. Adjust appropriately for additional
317 interfaces and for the actual ip and router you need:
318 </para>
319
320 <indexterm zone="dhcpcd dhcpcd-config4">
321 <primary sortas="e-etc-sysconfig-dhcpcd">/etc/sysconfig/ifconfig.eth0 (dhcpcd)</primary>
322 </indexterm>
323
324<screen role='nodump'><userinput>cat &gt; /etc/sysconfig/ifconfig.eth0 &lt;&lt; "EOF"
325<literal>ONBOOT="yes"
326IFACE="eth0"
327SERVICE="dhcpcd"
328DHCP_START="-b -q -S ip_address=192.168.0.10/24 -S routers=192.168.0.1"
329DHCP_STOP="-k"</literal>
330EOF</userinput></screen>
331
332 <para>
333 You can either use DNS servers in
334 <filename>/etc/resolv.conf</filename> from another system, your
335 preferred servers, or just the example
336 <filename>/etc/resolv.conf.head</filename> file below as is:
337 </para>
338
339<screen role='nodump'><userinput>cat &gt; /etc/resolv.conf.head &lt;&lt; "EOF"
340<literal># OpenDNS servers
341nameserver 208.67.222.222
342nameserver 208.67.220.220</literal>
343EOF</userinput></screen>
344
345 </sect3>
346
347 <sect3 id="dhcpcd-init3" revision="systemd">
348 <title>General Configuration Information</title>
349
350 <para>
351 If you want to configure network interfaces at boot using
352 <command>dhcpcd</command>, you need to install the
353 systemd unit included in <xref linkend="systemd-units"/>
354 package by running the following command as the
355 <systemitem class="username">root</systemitem> user:
356 </para>
357
358<screen role="root"><userinput>make install-dhcpcd</userinput></screen>
359
360 <indexterm zone="dhcpcd dhcpcd-init3">
361 <primary sortas="f-dhcpcd">dhcpcd</primary>
362 </indexterm>
363
364 <note>
365 <para id="dhcpcd-config5">
366 The default behavior of <command>dhcpcd</command> is to set the
367 hostname and the mtu. It also overwrites <filename>/etc/resolv.conf
368 </filename> and <filename>/etc/ntp.conf</filename>. These
369 modifications to system configuration files are done by hooks which
370 are stored in <filename class="directory">
371 /usr/lib/dhcpcd/dhcpcd-hooks</filename>. You can change this behavior
372 by removing or adding hooks from/to that directory. The execution
373 of hooks can be disabled by using the <option>--nohook</option>
374 (<option>-C</option>) command line option or by the
375 <option>nohook</option> option in the <filename>/etc/dhcpcd.conf
376 </filename> file.
377 </para>
378 </note>
379
380 <indexterm zone="dhcpcd dhcpcd-config5">
381 <primary sortas="e-etc-resolv.conf">/etc/resolv.conf</primary>
382 </indexterm>
383
384 <note>
385 <para>
386 Make sure that you disable the <command>systemd-networkd</command>
387 service or configure it not to manage the interfaces you want to
388 manage with <application>dhcpcd</application>.
389 </para>
390 </note>
391
392 <para>
393 At this point you can test if <command>dhcpcd</command> is
394 behaving as expected by running the following command as the
395 <systemitem class="username">root</systemitem> user:
396 </para>
397
398<screen role="root"><userinput>systemctl start dhcpcd@<replaceable>eth0</replaceable></userinput></screen>
399
400 <para>
401 To start <command>dhcpcd</command> on a specific interface
402 at boot, enable the previously installed systemd unit by
403 running the following command as the
404 <systemitem class="username">root</systemitem> user:
405 </para>
406
407<screen role="root"><userinput>systemctl enable dhcpcd@<replaceable>eth0</replaceable></userinput></screen>
408
409 <para>
410 Replace <replaceable>eth0</replaceable> with the actual interface name.
411 </para>
412
413 </sect3>
414
415 </sect2>
416
417 <sect2 role="content">
418 <title>Contents</title>
419
420 <segmentedlist>
421 <segtitle>Installed Program</segtitle>
422 <segtitle>Installed Library</segtitle>
423 <segtitle>Installed Directory</segtitle>
424
425 <seglistitem>
426 <seg>dhcpcd</seg>
427 <seg>/usr/lib/dhcpcd/dev/udev.so</seg>
428 <seg>/{usr,var}/lib/dhcpcd and /usr/share/dhcpcd</seg>
429 </seglistitem>
430 </segmentedlist>
431
432 <variablelist>
433 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
434 <?dbfo list-presentation="list"?>
435 <?dbhtml list-presentation="table"?>
436
437 <varlistentry id="dhcpcd-prog">
438 <term><command>dhcpcd</command></term>
439 <listitem>
440 <para>
441 is an implementation of the DHCP client specified in RFC2131
442 </para>
443 <indexterm zone="dhcpcd dhcpcd-prog">
444 <primary sortas="b-dhcpcd">dhcpcd</primary>
445 </indexterm>
446 </listitem>
447 </varlistentry>
448
449 <varlistentry id="dhcpcd-udev">
450 <term><filename class="libraryfile">udev.so</filename></term>
451 <listitem>
452 <para>
453 adds udev support for interface arrival and departure; this is
454 because udev likes to rename the interface, which it can't do if
455 dhcpcd grabs it first
456 </para>
457 <indexterm zone="dhcpcd dhcpcd-udev">
458 <primary sortas="c-dhcpcd-udev">udev.so</primary>
459 </indexterm>
460 </listitem>
461 </varlistentry>
462
463 </variablelist>
464
465 </sect2>
466
467</sect1>
Note: See TracBrowser for help on using the repository browser.