]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/nss-myhostname.xml
TODO: Remove Elapsed Time DHCPv6 option as it is done
[thirdparty/systemd.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># /etc/nsswitch.conf
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
103 netgroup: nis</programlisting>
104
105 <para>To test, use <command>glibc</command>'s <command>getent</command> tool:</para>
106
107 <programlisting>$ getent ahosts `hostname`
108 ::1 STREAM omega
109 ::1 DGRAM
110 ::1 RAW
111 127.0.0.2 STREAM
112 127.0.0.2 DGRAM
113 127.0.0.2 RAW</programlisting>
114
115 <para>In this case the local hostname is <varname>omega</varname>.</para>
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 project='man-pages'><refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
127 <citerefentry project='man-pages'><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
128 <citerefentry project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
129 <citerefentry project='die-net'><refentrytitle>pam_loginuid</refentrytitle><manvolnum>8</manvolnum></citerefentry>
130 </para>
131 </refsect1>
132
133 </refentry>