source: networking/connect/dhcpcd.xml@ 9f44beb

11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 9f44beb was 9f44beb, checked in by Tim Tassonis <stuff@…>, 16 months ago

Fix setting hostname in dhcpcd service.

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