]> git.proxmox.com Git - systemd.git/blob - man/nss-myhostname.html
Imported Upstream version 204
[systemd.git] / man / nss-myhostname.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>nss-myhostname</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
2 a.headerlink {
3 color: #c60f0f;
4 font-size: 0.8em;
5 padding: 0 4px 0 4px;
6 text-decoration: none;
7 visibility: hidden;
8 }
9
10 a.headerlink:hover {
11 background-color: #c60f0f;
12 color: white;
13 }
14
15 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
16 visibility: visible;
17 }
18 </style><a href="index.html">Index </a>·
19 <a href="systemd.directives.html">Directives </a>·
20 <a href="../python-systemd/index.html">Python </a>·
21 <a href="../libudev/index.html">libudev </a>·
22 <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 204</span><hr><div class="refentry"><a name="nss-myhostname"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>nss-myhostname — Provide host name resolution for the locally
23 configured system hostname.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><p><code class="filename">nss-myhostname.la</code></p></div><div class="refsect1"><a name="idm259768906416"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p><span class="command"><strong>nss-myhostname</strong></span> is a plugin for the GNU Name Service Switch
24 (NSS) functionality of the GNU C Library (<span class="command"><strong>glibc</strong></span>)
25 providing host name resolution for the locally configured system
26 hostname as returned by
27 <a href="gethostname.html"><span class="citerefentry"><span class="refentrytitle">gethostname</span>(2)</span></a>.
28 Various software relies on an always resolvable local host name. When
29 using dynamic hostnames this is usually achieved by patching
30 <code class="filename">/etc/hosts</code> at the same time as changing the host
31 name. This however is not ideal since it requires a writable
32 <code class="filename">/etc</code> file system and is fragile because the file
33 might be edited by the administrator at the same time. <span class="command"><strong>nss-myhostname</strong></span>
34 simply returns all locally configure public IP addresses, or -- if none
35 are configured -- the IPv4 address 127.0.0.2 (which is on the local
36 loopback) and the IPv6 address ::1 (which is the local host) for
37 whatever system hostname is configured locally. Patching
38 <code class="filename">/etc/hosts</code> is thus no longer necessary.</p><p>To activate the NSS modules, <code class="option">myhostname</code>
39 has to be added to the line starting with "<code class="varname">hosts:</code>" in
40 <code class="filename">/etc/nsswitch.conf</code></p><p>It is recommended to put <code class="option">myhostname</code>
41 last in the <code class="filename">nsswitch.conf</code> line to make
42 sure that this mapping is only used as fallback, and any DNS
43 or <code class="filename">/etc/hosts</code> based mapping takes precedence.</p></div><div class="refsect1"><a name="idm259767389856"></a><h2 id="Example">Example<a class="headerlink" title="Permalink to this headline" href="#Example"></a></h2><pre class="programlisting">
44 # /etc/nsswitch.conf
45
46 passwd: compat
47 group: compat
48 shadow: compat
49
50 hosts: files dns <code class="varname">myhostname</code>
51 networks: files
52
53 protocols: db files
54 services: db files
55 ethers: db files
56 rpc: db files
57
58 netgroup: nis
59 </pre><p>To test, use <span class="command"><strong>glibc</strong></span>'s <span class="command"><strong>getent</strong></span> tool:</p><pre class="programlisting">
60 $ getent ahosts `hostname`
61 ::1 STREAM omega
62 ::1 DGRAM
63 ::1 RAW
64 127.0.0.2 STREAM
65 127.0.0.2 DGRAM
66 127.0.0.2 RAW
67 </pre><p>In this case the local host name is <code class="varname">omega</code>.</p></div><div class="refsect1"><a name="idm259767384112"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
68 <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
69 <a href="systemd-logind.service.html"><span class="citerefentry"><span class="refentrytitle">systemd-logind.service</span>(8)</span></a>,
70 <a href="logind.conf.html"><span class="citerefentry"><span class="refentrytitle">logind.conf</span>(5)</span></a>,
71 <a href="loginctl.html"><span class="citerefentry"><span class="refentrytitle">loginctl</span>(1)</span></a>,
72 <a href="pam.conf.html"><span class="citerefentry"><span class="refentrytitle">pam.conf</span>(5)</span></a>,
73 <a href="pam.d.html"><span class="citerefentry"><span class="refentrytitle">pam.d</span>(5)</span></a>,
74 <a href="pam.html"><span class="citerefentry"><span class="refentrytitle">pam</span>(8)</span></a>,
75 <a href="pam_loginuid.html"><span class="citerefentry"><span class="refentrytitle">pam_loginuid</span>(8)</span></a>
76 </p></div></div></body></html>