chiark / gitweb /
Get rid of write_safe
[elogind.git] / man / nss-myhostname.xml
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
25 <refentry id="nss-myhostname" conditional='HAVE_MYHOSTNAME'>
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>
48                 <refpurpose>Provide hostname resolution for the locally
49                 configured system hostname.</refpurpose>
50         </refnamediv>
51
52         <refsynopsisdiv>
53                 <para><filename>nss-myhostname.la</filename></para>
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>)
61                 providing hostname resolution for the locally configured system
62                 hostname as returned by
63                 <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
64                 Various software relies on an always-resolvable local hostname. When
65                 using dynamic hostnames, this is usually achieved by patching
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>
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
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
89                 <programlisting>
90 # /etc/nsswitch.conf
91
92 passwd:         compat
93 group:          compat
94 shadow:         compat
95
96 hosts:          files dns <varname>myhostname</varname>
97 networks:       files
98
99 protocols:      db files
100 services:       db files
101 ethers:         db files
102 rpc:            db files
103
104 netgroup:       nis
105                 </programlisting>
106
107                 <para>To test, use <command>glibc</command>'s <command>getent</command> tool:</para>
108
109                 <programlisting>
110 $ getent ahosts `hostname`
111 ::1             STREAM omega
112 ::1             DGRAM
113 ::1             RAW
114 127.0.0.2       STREAM
115 127.0.0.2       DGRAM
116 127.0.0.2       RAW
117                 </programlisting>
118
119                 <para>In this case the local hostname is <varname>omega</varname>.</para>
120
121         </refsect1>
122
123         <refsect1>
124                 <title>See Also</title>
125                 <para>
126                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
127                         <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
128                         <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
129                         <citerefentry><refentrytitle>loginctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
130                         <citerefentry><refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
131                         <citerefentry><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
132                         <citerefentry><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
133                         <citerefentry><refentrytitle>pam_loginuid</refentrytitle><manvolnum>8</manvolnum></citerefentry>
134                 </para>
135         </refsect1>
136
137 </refentry>