]>
Commit | Line | Data |
---|---|---|
16eb4da9 TG |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | ||
5 | <!-- | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2011 Lennart Poettering | |
9 | Copyright 2013 Tom Gundersen | |
10 | ||
11 | systemd is free software; you can redistribute it and/or modify it | |
12 | under the terms of the GNU Lesser General Public License as published by | |
13 | the Free Software Foundation; either version 2.1 of the License, or | |
14 | (at your option) any later version. | |
15 | ||
16 | systemd is distributed in the hope that it will be useful, but | |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | Lesser General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU Lesser General Public License | |
22 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
23 | --> | |
24 | ||
56ba3c78 | 25 | <refentry id="nss-myhostname" conditional='HAVE_MYHOSTNAME'> |
16eb4da9 TG |
26 | |
27 | <refentryinfo> | |
28 | <title>nss-myhostname</title> | |
29 | <productname>systemd</productname> | |
30 | ||
31 | <authorgroup> | |
32 | <author> | |
33 | <contrib>Developer</contrib> | |
34 | <firstname>Lennart</firstname> | |
35 | <surname>Poettering</surname> | |
36 | <email>lennart@poettering.net</email> | |
37 | </author> | |
38 | </authorgroup> | |
39 | </refentryinfo> | |
40 | ||
41 | <refmeta> | |
42 | <refentrytitle>nss-myhostname</refentrytitle> | |
43 | <manvolnum>8</manvolnum> | |
44 | </refmeta> | |
45 | ||
46 | <refnamediv> | |
47 | <refname>nss-myhostname</refname> | |
e9dd9f95 | 48 | <refpurpose>Provide hostname resolution for the locally |
16eb4da9 TG |
49 | configured system hostname.</refpurpose> |
50 | </refnamediv> | |
51 | ||
52 | <refsynopsisdiv> | |
e670b166 | 53 | <para><filename>nss-myhostname.la</filename></para> |
16eb4da9 TG |
54 | </refsynopsisdiv> |
55 | ||
56 | <refsect1> | |
57 | <title>Description</title> | |
58 | ||
59 | <para><command>nss-myhostname</command> is a plugin for the GNU Name Service Switch | |
60 | (NSS) functionality of the GNU C Library (<command>glibc</command>) | |
e9dd9f95 | 61 | providing hostname resolution for the locally configured system |
16eb4da9 TG |
62 | hostname as returned by |
63 | <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>. | |
e9dd9f95 JSJ |
64 | Various software relies on an always-resolvable local hostname. When |
65 | using dynamic hostnames, this is usually achieved by patching | |
16eb4da9 TG |
66 | <filename>/etc/hosts</filename> at the same time as changing the host |
67 | name. This however is not ideal since it requires a writable | |
68 | <filename>/etc</filename> file system and is fragile because the file | |
69 | might be edited by the administrator at the same time. <command>nss-myhostname</command> | |
e9dd9f95 JSJ |
70 | simply returns all locally configured public IP addresses, or, if none |
71 | are configured, the IPv4 address 127.0.0.2 (which is on the local | |
16eb4da9 TG |
72 | loopback) and the IPv6 address ::1 (which is the local host) for |
73 | whatever system hostname is configured locally. Patching | |
74 | <filename>/etc/hosts</filename> is thus no longer necessary.</para> | |
75 | ||
76 | <para>To activate the NSS modules, <option>myhostname</option> | |
77 | has to be added to the line starting with "<varname>hosts:</varname>" in | |
78 | <filename>/etc/nsswitch.conf</filename></para> | |
79 | ||
80 | <para>It is recommended to put <option>myhostname</option> | |
81 | last in the <filename>nsswitch.conf</filename> line to make | |
82 | sure that this mapping is only used as fallback, and any DNS | |
83 | or <filename>/etc/hosts</filename> based mapping takes precedence.</para> | |
84 | </refsect1> | |
85 | ||
86 | <refsect1> | |
87 | <title>Example</title> | |
88 | ||
9fccdb0f | 89 | <programlisting># /etc/nsswitch.conf |
16eb4da9 TG |
90 | |
91 | passwd: compat | |
92 | group: compat | |
93 | shadow: compat | |
94 | ||
95 | hosts: files dns <varname>myhostname</varname> | |
96 | networks: files | |
97 | ||
98 | protocols: db files | |
99 | services: db files | |
100 | ethers: db files | |
101 | rpc: db files | |
102 | ||
9fccdb0f | 103 | netgroup: nis</programlisting> |
16eb4da9 TG |
104 | |
105 | <para>To test, use <command>glibc</command>'s <command>getent</command> tool:</para> | |
106 | ||
9fccdb0f | 107 | <programlisting>$ getent ahosts `hostname` |
16eb4da9 TG |
108 | ::1 STREAM omega |
109 | ::1 DGRAM | |
110 | ::1 RAW | |
111 | 127.0.0.2 STREAM | |
112 | 127.0.0.2 DGRAM | |
9fccdb0f | 113 | 127.0.0.2 RAW</programlisting> |
16eb4da9 | 114 | |
e9dd9f95 | 115 | <para>In this case the local hostname is <varname>omega</varname>.</para> |
16eb4da9 TG |
116 | |
117 | </refsect1> | |
118 | ||
119 | <refsect1> | |
120 | <title>See Also</title> | |
121 | <para> | |
122 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
123 | <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
124 | <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
125 | <citerefentry><refentrytitle>loginctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
126 | <citerefentry><refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
127 | <citerefentry><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
128 | <citerefentry><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
129 | <citerefentry><refentrytitle>pam_loginuid</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
130 | </para> | |
131 | </refsect1> | |
132 | ||
133 | </refentry> |