{"id":3589,"date":"2022-12-20T17:09:06","date_gmt":"2022-12-20T20:09:06","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/nssmymachines-man8\/"},"modified":"2022-12-20T17:09:06","modified_gmt":"2022-12-20T20:09:06","slug":"nssmymachines-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/nssmymachines-man8\/","title":{"rendered":"NSS&minus;MYMACHINES (man8)"},"content":{"rendered":"<h1 align=\"center\">NSS\u2212MYMACHINES<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#CONFIGURATION IN \/ETC\/NSSWITCH.CONF\">CONFIGURATION IN \/ETC\/NSSWITCH.CONF<\/a><br \/> <a href=\"#EXAMPLE: MAPPINGS PROVIDED BY NSS\u2212MYMACHINES\">EXAMPLE: MAPPINGS PROVIDED BY NSS\u2212MYMACHINES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">nss-mymachines, libnss_mymachines.so.2 \u2212 Hostname resolution for local container instances<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">libnss_mymachines.so.2<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>nss\u2212mymachines<\/b> is a plug\u2212in module for the GNU Name Service Switch (NSS) functionality of the GNU C Library (<b>glibc<\/b>), providing hostname resolution for the names of containers running locally that are registered with <b>systemd-machined.service<\/b>(8). The container names are resolved to the IP addresses of the specific container, ordered by their scope. This functionality only applies to containers using network namespacing (see the description of <b>\u2212\u2212private\u2212network<\/b> in <b>systemd-nspawn<\/b>(1)). Note that the name that is resolved is the one registered with <b>systemd\u2212machined<\/b>, which may be different than the hostname configured inside of the container.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To activate the NSS module, add &#8220;mymachines&#8221; to the line starting with &#8220;hosts:&#8221; in \/etc\/nsswitch.conf.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It is recommended to place &#8220;mymachines&#8221; after the &#8220;files&#8221; or &#8220;compat&#8221; entry of the \/etc\/nsswitch.conf line to make sure that its mappings are preferred over other resolvers such as DNS, but so that \/etc\/hosts based mappings take precedence.<\/p>\n<h2>CONFIGURATION IN \/ETC\/NSSWITCH.CONF <a name=\"CONFIGURATION IN \/ETC\/NSSWITCH.CONF\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Here is an example \/etc\/nsswitch.conf file that enables <b>nss\u2212mymachines<\/b> correctly:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">passwd: compat systemd <br \/> group: compat systemd <br \/> shadow: compat<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">hosts: <b>mymachines<\/b> resolve [!UNAVAIL=return] myhostname files dns <br \/> networks: files<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">protocols: db files <br \/> services: db files <br \/> ethers: db files <br \/> rpc: db files<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">netgroup: nis<\/p>\n<h2>EXAMPLE: MAPPINGS PROVIDED BY NSS\u2212MYMACHINES <a name=\"EXAMPLE: MAPPINGS PROVIDED BY NSS\u2212MYMACHINES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The container &#8220;rawhide&#8221; is spawned using <b>systemd-nspawn<\/b>(1):<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"># systemd\u2212nspawn \u2212M rawhide \u2212\u2212boot \u2212\u2212network\u2212veth \u2212\u2212private\u2212users=pick <br \/> Spawning container rawhide on \/var\/lib\/machines\/rawhide. <br \/> Selected user namespace base 20119552 and range 65536. <br \/> &#8230;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ machinectl \u2212\u2212max\u2212addresses=3 <br \/> MACHINE CLASS SERVICE OS VERSION ADDRESSES <br \/> rawhide container systemd\u2212nspawn fedora 30 169.254.40.164 fe80::94aa:3aff:fe7b:d4b9<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ ping \u2212c1 rawhide <br \/> PING rawhide(fe80::94aa:3aff:fe7b:d4b9%ve\u2212rawhide (fe80::94aa:3aff:fe7b:d4b9%ve\u2212rawhide)) 56 data bytes <br \/> 64 bytes from fe80::94aa:3aff:fe7b:d4b9%ve\u2212rawhide (fe80::94aa:3aff:fe7b:d4b9%ve\u2212rawhide): icmp_seq=1 ttl=64 time=0.045 ms <br \/> &#8230; <br \/> $ ping \u2212c1 \u22124 rawhide <br \/> PING rawhide (169.254.40.164) 56(84) bytes of data. <br \/> 64 bytes from 169.254.40.164 (169.254.40.164): icmp_seq=1 ttl=64 time=0.064 ms <br \/> &#8230;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"># machinectl shell rawhide \/sbin\/ip a <br \/> Connected to machine rawhide. Press ^] three times within 1s to exit session. <br \/> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 <br \/> &#8230; <br \/> 2: host0@if21: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 <br \/> link\/ether 96:aa:3a:7b:d4:b9 brd ff:ff:ff:ff:ff:ff link\u2212netnsid 0 <br \/> inet 169.254.40.164\/16 brd 169.254.255.255 scope link host0 <br \/> valid_lft forever preferred_lft forever <br \/> inet6 fe80::94aa:3aff:fe7b:d4b9\/64 scope link <br \/> valid_lft forever preferred_lft forever <br \/> Connection to machine rawhide terminated.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>systemd<\/b>(1), <b>systemd-machined.service<\/b>(8), <b>machinectl<\/b>(1), <b>nss-systemd<\/b>(8), <b>nss-resolve<\/b>(8), <b>nss-myhostname<\/b>(8), <b>nsswitch.conf<\/b>(5), <b>getent<\/b>(1)<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  nss-mymachines, libnss_mymachines.so.2 \u2212 Hostname resolution for local container instances <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,706],"class_list":["post-3589","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-nss-mymachines"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3589"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3589\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}